From 56a6443b6dfc5c1c89b29317fae62b8f4cea2803 Mon Sep 17 00:00:00 2001 From: Paul Kirby Date: Thu, 1 Nov 2018 12:33:18 -0500 Subject: [PATCH] placeholder lbry published banner --- classes/lbrypress.php | 26 ++++++++++++++++++++++++++ templates/published_on_lbry_banner.php | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 templates/published_on_lbry_banner.php diff --git a/classes/lbrypress.php b/classes/lbrypress.php index 8247212..d3c8ee7 100644 --- a/classes/lbrypress.php +++ b/classes/lbrypress.php @@ -151,6 +151,10 @@ class LBRYPress { register_activation_hook(LBRY_PLUGIN_FILE, array($this, 'activate')); register_deactivation_hook(LBRY_PLUGIN_FILE, array($this, 'deactivate')); + + // Banner output for published posts + // NOTE: move this to its own class to reduce clutter? + add_action('the_content', array($this, 'published_on_lbry_banner'), 12, 1); } /** @@ -198,6 +202,28 @@ class LBRYPress error_log('Deactivated'); } + public function published_on_lbry_banner($content) + { + if (!is_single() || !in_the_loop() || !is_main_query()) { + return $content; + } + + global $post; + if ($post->post_type != 'post') { + return $content; + } + + if (!get_post_meta($post->ID, LBRY_WILL_PUBLISH, true)) { + return $content; + } + + ob_start(); + require(LBRY_ABSPATH . 'templates/published_on_lbry_banner.php'); + $banner = ob_get_clean(); + + return $content .= $banner; + } + /* * Utility Functions */ diff --git a/templates/published_on_lbry_banner.php b/templates/published_on_lbry_banner.php new file mode 100644 index 0000000..d85b9c5 --- /dev/null +++ b/templates/published_on_lbry_banner.php @@ -0,0 +1,4 @@ +
+
This post has also been published to the LBRY blockchain network.
+
Click Here to learn more about the benefits of content freedom.
+
\ No newline at end of file