Exemplo n.º 1
0
 public function register_locations()
 {
     global $post;
     if (is_admin()) {
         return;
     }
     if ($this->general_options['reset_postdata']) {
         wp_reset_postdata();
     }
     // @since version 3.1 CSS hide of mobile buttons
     $mobile_css_activate = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_css_activate');
     if ($mobile_css_activate) {
         essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_mobile_compatibility(), 'essb-mobile-compatibility');
     }
     $this->list_of_activated_locations = array();
     $current_post_content_locations = $this->general_options['content_position'];
     $current_post_button_position = $this->general_options['button_position'];
     // different button placement by post type is only avaiable in full interface
     if (!defined('ESSB3_LIGHTMODE')) {
         $positions_by_pt = ESSBOptionValuesHelper::options_bool_value($this->options, 'positions_by_pt');
         if ($positions_by_pt && isset($post)) {
             $current_post_type = $post->post_type;
             $content_position_by_pt = ESSBOptionValuesHelper::options_value($this->options, 'content_position_' . $current_post_type);
             $button_position_by_pt = ESSBOptionValuesHelper::options_value($this->options, 'button_position_' . $current_post_type);
             if (!empty($content_position_by_pt)) {
                 $current_post_content_locations = $content_position_by_pt;
                 $this->general_options['content_position'] = $content_position_by_pt;
             }
             if (is_array($button_position_by_pt)) {
                 if (count($button_position_by_pt) > 0) {
                     $current_post_button_position = $button_position_by_pt;
                     $this->general_options['button_position'] = $button_position_by_pt;
                 }
             }
         }
     }
     if ($current_post_content_locations != '' && $current_post_content_locations != 'content_manual') {
         add_filter('the_content', array($this, 'display_inline'), $this->general_options['priority_of_buttons']);
         $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'display_inline', "priority" => $this->general_options['priority_of_buttons'], 'position' => 'content_position');
     }
     if (is_array($current_post_button_position)) {
         foreach ($current_post_button_position as $position) {
             if (method_exists($this, 'display_' . $position)) {
                 if ($position == "postfloat") {
                     add_filter('the_content', array($this, 'display_postfloat'));
                     add_filter('the_content', array($this, 'trigger_bottom_mark'), 9999);
                     $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'display_postfloat', "priority" => "", 'position' => 'button_position');
                     $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'trigger_bottom_mark', "priority" => "9999", 'position' => 'button_position');
                 } else {
                     if ($position == "onmedia") {
                         add_filter('the_content', array($this, 'display_onmedia'), 9999);
                         $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'display_onmedia', "priority" => "9999", 'position' => 'button_position');
                     } else {
                         if ($position == "popup" && ESSBOptionValuesHelper::options_bool_value($this->options, 'popup_display_comment')) {
                             add_filter('comment_post_redirect', array($this, 'after_comment_trigger'));
                             $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "comment_post_redirect", "function" => 'after_comment_trigger', "priority" => "", 'position' => 'button_position');
                         }
                         if ($position == "flyin" && ESSBOptionValuesHelper::options_bool_value($this->options, 'flyin_display_comment')) {
                             add_filter('comment_post_redirect', array($this, 'after_comment_trigger'));
                             $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "comment_post_redirect", "function" => 'after_comment_trigger', "priority" => "", 'position' => 'button_position');
                         }
                         if ($position == 'postbar') {
                             add_filter('the_content', array($this, 'trigger_postbar_readbar'));
                             $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'trigger_postbar_readbar', "priority" => "", 'position' => 'button_position');
                         }
                         add_filter('the_content', array($this, 'trigger_bottom_mark'), 9999);
                         add_action('wp_footer', array($this, "display_{$position}"));
                         $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_content", "function" => 'trigger_bottom_mark', "priority" => "9999", 'position' => 'button_position');
                         $this->list_of_activated_locations[] = array("type" => "action", "hook" => "wp_footer", "function" => "display_{$position}", "priority" => "", 'position' => 'button_position');
                     }
                 }
             }
         }
     }
     // excerpt display
     if ($this->general_options['display_excerpt']) {
         // @since verion 3.0.4 - build in Avada theme bridge
         if (class_exists('FusionCore_Plugin')) {
             // detected Avada theme
             if ($this->general_options['display_excerpt_pos'] == "top") {
                 add_action('fusion_blog_shortcode_loop_content', array($this, 'display_excerpt_avada'), $this->general_options['priority_of_buttons']);
                 $this->list_of_activated_locations[] = array("type" => "action", "hook" => "fusion_blog_shortcode_loop_content", "function" => 'display_excerpt_avada', "priority" => $this->general_options['priority_of_buttons']);
                 add_action('avada_blog_post_content', array($this, 'display_excerpt_avada'), 1);
                 $this->list_of_activated_locations[] = array("type" => "action", "hook" => "avada_blog_post_content", "function" => 'display_excerpt_avada', "priority" => "1");
             } else {
                 add_action('fusion_blog_shortcode_loop_footer', array($this, 'display_excerpt_avada'), $this->general_options['priority_of_buttons']);
                 $this->list_of_activated_locations[] = array("type" => "action", "hook" => "fusion_blog_shortcode_loop_content", "function" => 'display_excerpt_avada', "priority" => $this->general_options['priority_of_buttons']);
                 add_action('avada_blog_post_content', array($this, 'display_excerpt_avada'), 20);
                 $this->list_of_activated_locations[] = array("type" => "action", "hook" => "avada_blog_post_content", "function" => 'display_excerpt_avada', "priority" => "20");
             }
         } else {
             add_filter('the_excerpt', array($this, 'display_excerpt'), $this->general_options['priority_of_buttons']);
             $this->list_of_activated_locations[] = array("type" => "filter", "hook" => "the_excerpt", "function" => 'display_excerpt', "priority" => $this->general_options['priority_of_buttons']);
         }
     }
     // clean buttons
     if ($this->general_options['apply_clean_buttons']) {
         if ($this->general_options['apply_clean_buttons_method'] == "actionremove") {
             add_filter('get_the_excerpt', array($this, 'remove_buttons_excerpts_method2'), -999);
         } else {
             if ($this->general_options['apply_clean_buttons_method'] == "remove2") {
                 // do nothing
             } else {
                 if ($this->general_options['apply_clean_buttons_method'] == "clean2") {
                     add_filter('get_the_excerpt', array($this, 'remove_buttons_excerpts_method3'));
                 } else {
                     add_filter('get_the_excerpt', array($this, 'remove_buttons_excerpts'));
                 }
             }
         }
     }
     if (!defined('ESSB3_LIGHTMODE')) {
         // additional module integraton hooks
         //-- WooCommerce
         $woocommece_share = ESSBOptionValuesHelper::options_bool_value($this->options, 'woocommece_share');
         $woocommece_beforeprod = ESSBOptionValuesHelper::options_bool_value($this->options, 'woocommece_beforeprod');
         $woocommece_afterprod = ESSBOptionValuesHelper::options_bool_value($this->options, 'woocommece_afterprod');
         if ($woocommece_share) {
             add_action('woocommerce_share', array($this, 'handle_woocommerce_integration'));
         }
         if ($woocommece_beforeprod) {
             add_action('woocommerce_before_single_product', array($this, 'handle_woocommerce_integration'));
         }
         if ($woocommece_afterprod) {
             add_action('woocommerce_after_single_product', array($this, 'handle_woocommerce_integration'));
         }
         //-- WP eCommerce
         $wpec_before_desc = ESSBOptionValuesHelper::options_bool_value($this->options, 'wpec_before_desc');
         $wpec_after_desc = ESSBOptionValuesHelper::options_bool_value($this->options, 'wpec_after_desc');
         $wpec_theme_footer = ESSBOptionValuesHelper::options_bool_value($this->options, 'wpec_theme_footer');
         if ($wpec_before_desc) {
             add_action('wpsc_product_before_description', array($this, 'handle_wpecommerce_integration'));
         }
         if ($wpec_after_desc) {
             add_action('wpsc_product_addons', array($this, 'handle_wpecommerce_integration'));
         }
         if ($wpec_theme_footer) {
             add_action('wpsc_theme_footer', array($this, 'handle_wpecommerce_integration'));
         }
         // JigoShop
         $jigoshop_top = ESSBOptionValuesHelper::options_bool_value($this->options, 'jigoshop_top');
         $jigoshop_bottom = ESSBOptionValuesHelper::options_bool_value($this->options, 'jigoshop_bottom');
         if ($jigoshop_top) {
             add_action('jigoshop_before_single_product_summary', array($this, 'handle_jigoshop_integration'));
         }
         if ($jigoshop_bottom) {
             add_action('jigoshop_after_main_content', array($this, 'handle_jigoshop_integration'));
         }
         // BBPress
         $bbpress_forum = ESSBOptionValuesHelper::options_bool_value($this->options, 'bbpress_forum');
         $bbpress_topic = ESSBOptionValuesHelper::options_bool_value($this->options, 'bbpress_topic');
         if ($bbpress_topic) {
             add_action('bbp_template_before_topics_loop', array($this, 'handle_bbpress_integration'));
         }
         if ($bbpress_forum) {
             add_action('bbp_template_before_replies_loop', array($this, 'handle_bbpress_integration'));
         }
         // iThemes Exchange
         $ithemes_after_title = ESSBOptionValuesHelper::options_bool_value($this->options, 'ithemes_after_title');
         $ithemes_before_desc = ESSBOptionValuesHelper::options_bool_value($this->options, 'ithemes_before_desc');
         $ithemes_after_desc = ESSBOptionValuesHelper::options_bool_value($this->options, 'ithemes_after_desc');
         $ithemes_after_product = ESSBOptionValuesHelper::options_bool_value($this->options, 'ithemes_after_product');
         $ithemes_after_purchase = ESSBOptionValuesHelper::options_bool_value($this->options, 'ithemes_after_purchase');
         if ($ithemes_after_title) {
             add_action('it_exchange_content_product_before_wrap', array($this, 'handle_ithemes_integration'));
         }
         if ($ithemes_before_desc) {
             add_action('it_exchange_content_product_before_description_element', array($this, 'handle_ithemes_integration'));
         }
         if ($ithemes_after_desc) {
             add_action('it_exchange_content_product_after_description_element', array($this, 'handle_ithemes_integration'));
         }
         if ($ithemes_after_product) {
             add_action('it_exchange_content_product_end_wrap', array($this, 'handle_ithemes_integration'));
         }
         if ($ithemes_after_purchase) {
             add_action('it_exchange_content_confirmation_after_product_title', array($this, 'handle_ithemes_purchase_integration'));
         }
         // BuddyPress
         $buddypress_group = ESSBOptionValuesHelper::options_bool_value($this->options, 'buddypress_group');
         $buddypress_activity = ESSBOptionValuesHelper::options_bool_value($this->options, 'buddypress_activity');
         if ($buddypress_group) {
             add_action('bp_before_group_home_content', array($this, 'handle_buddypress_group_integration'));
         }
         if ($buddypress_activity) {
             add_action('bp_activity_entry_meta', array($this, 'handle_buddypress_activity_integration'));
         }
     }
 }