![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mets-rebuild.corals.io/wp-content/plugins/favorites/app/Entities/Post/ |
<?php namespace Favorites\Entities\Post; use Favorites\Config\SettingsRepository; use Favorites\Entities\Favorite\FavoriteButton; /** * Post Actions and Filters */ class PostHooks { /** * Settings Repository */ private $settings_repo; /** * The Content */ private $content; /** * The Post Object */ private $post; public function __construct() { $this->settings_repo = new SettingsRepository; add_filter('the_content', [$this, 'filterContent']); } /** * Filter the Content */ public function filterContent($content) { global $post; if ( !$post ) return $content; $this->post = $post; $this->content = $content; $display = $this->settings_repo->displayInPostType($post->post_type); if ( !$display ) return $content; return $this->addFavoriteButton($display); } /** * Add the Favorite Button * @todo add favorite button html */ private function addFavoriteButton($display_in) { $output = ''; if ( isset($display_in['before_content']) && $display_in['before_content'] == 'true' ){ $output .= get_favorites_button(); } $output .= $this->content; if ( isset($display_in['after_content']) && $display_in['after_content'] == 'true' ){ $output .= get_favorites_button(); } return $output; } }