public static function get_instance()
 {
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
0
 public function __construct()
 {
     global $essb_stats;
     $this->stats = $essb_stats;
     $essb_options = EasySocialShareButtons_Options::get_instance();
     $this->options = $essb_options->options;
     // @since 1.3.9.8 - new Social Share Optimization Engine
     EasySocialShareButtons_SocialShareOptimization::get_instance();
     // @since 2.0 After Share Close User Actions
     ESSBAfterCloseShare::instance();
     $this->essb_css_builder = new ESSB_CSS_Builder();
     $this->essb_js_builder = ESSB_JS_Buider::get_instance();
     $option = $this->options;
     $this->social_privacy = ESSB_Social_Privacy::get_instance();
     $remove_ver_resource = ESSBOptionsHelper::optionsBoolValue($option, 'remove_ver_resource');
     //isset($option['remove_ver_resource']) ? $option['remove_ver_resource'] : 'false';
     if ($remove_ver_resource) {
         $this->version = '';
     }
     $new_priority = isset($option['priority_of_buttons']) ? $option['priority_of_buttons'] : '';
     if (trim($new_priority) != '') {
         $new_priority = trim($new_priority);
         $new_priority = intval($new_priority);
         if ($new_priority != 0) {
             $this->custom_priority = $new_priority;
             $this->custom_priority_active = true;
         }
     }
     // @since 1.3.9.8 - GA tracking mode
     $this->ga_tracking = ESSBOptionsHelper::optionsBoolValue($option, 'activate_ga_tracking');
     //$activate_ga_tracking = isset($option['activate_ga_tracking']) ? $option['activate_ga_tracking'] : '';
     if ($this->ga_tracking == 'true') {
         //$this->ga_tracking = true;
         //$ga_tracking_mode = isset($option['ga_tracking_mode']) ? $option['ga_tracking_mode'] : '';
         $ga_tracking_mode = ESSBOptionsHelper::optionsValue($option, 'ga_tracking_mode');
         $this->essb_js_builder->include_ga_tracking_code($ga_tracking_mode);
     }
     $this->mobile_options_active = ESSBOptionsHelper::optionsBoolValue($option, 'activate_opt_by_mp');
     //$activate_opt_by_mp = isset($option['activate_opt_by_mp']) ? $option['activate_opt_by_mp'] : 'false';
     //if ($activate_opt_by_mp == 'true') {
     //	$this->mobile_options_active = true;
     //}
     $module_off_lv = isset($option['module_off_lv']) ? $option['module_off_lv'] : 'false';
     if ($module_off_lv != 'true') {
         $this->love = ESSB_LoveYou::get_instance();
     }
     $this->avoid_next_page = ESSBOptionsHelper::optionsBoolValue($option, 'avoid_nextpage');
     //$avoid_nextpage = isset($option['avoid_nextpage']) ? $option['avoid_nextpage'] : 'false';
     //if ($avoid_nextpage == "true") { $this->avoid_next_page = true; }
     // @since 1.3.9.5 - we can have specific post type options
     $this->options_by_pt_active = ESSBOptionsHelper::optionsBoolValue($option, 'activate_opt_by_pt');
     //$activate_opt_by_pt = isset($option['activate_opt_by_pt']) ? $option['activate_opt_by_pt'] : 'false';
     //if ($activate_opt_by_pt == "true") {
     //	$this->options_by_pt_active = true;
     //}
     // @since 1.3.9.5 - we can have specific post type options
     //$activate_opt_by_bp = isset($option['activate_opt_by_bp']) ? $option['activate_opt_by_bp'] : 'false';
     $this->options_by_bp_active = ESSBOptionsHelper::optionsBoolValue($option, 'activate_opt_by_bp');
     //if ($activate_opt_by_bp == "true") {
     //	$this->options_by_bp_active = true;
     //}
     $this->load_js_async = ESSBOptionsHelper::optionsBoolValue($option, 'load_js_async');
     //$load_js_async = isset($option['load_js_async']) ? $option['load_js_async'] : 'false';
     //$this->load_js_async = ($load_js_async == "true") ? true: false;
     $this->load_js_defer = ESSBOptionsHelper::optionsBoolValue($option, 'load_js_defer');
     //$load_js_defer = isset($option['load_js_defer']) ? $option['load_js_defer'] : 'false';
     //load_js_async = ($load_js_defer == "true") ? true: false;
     if ($this->load_js_defer) {
         $this->load_js_async = true;
     }
     $this->essb_js_builder->load_async = $this->load_js_async;
     $this->essb_js_builder->load_defer = $this->load_js_defer;
     add_action('wp_enqueue_scripts', array($this, 'register_front_assets'), 1);
     $this->skinned_social = ESSBOptionsHelper::optionsBoolValue($option, 'skin_native');
     //$skin_native = isset($option['skin_native']) ? $option['skin_native'] : 'false';
     //$skin_native_skin = isset($option['skin_native_skin']) ? $option['skin_native_skin'] : '';
     if ($this->skinned_social) {
         //$this->skinned_social = true;
         $this->skinned_social_selected_skin = ESSBOptionsHelper::optionsBoolValue($option, 'skin_native_skin');
     }
     if ($this->custom_priority_active) {
         add_action('the_content', array($this, 'print_share_links'), $this->custom_priority, 1);
     } else {
         add_action('the_content', array($this, 'print_share_links'), 10, 1);
     }
     $is_excerpt_active = isset($option['display_excerpt']) ? $option['display_excerpt'] : 'false';
     $apply_clean_buttons = isset($option['apply_clean_buttons']) ? $option['apply_clean_buttons'] : 'false';
     $apply_clean_buttons_method = ESSBOptionsHelper::optionsValue($option, 'apply_clean_buttons_method');
     if ($apply_clean_buttons == "true") {
         $apply_clean_buttons_method = ESSBOptionsHelper::optionsValue($option, 'apply_clean_buttons_method');
         if ($apply_clean_buttons_method != 'action') {
             add_filter('get_the_excerpt', array($this, 'remove_buttons_excerpts_method2'), -999);
         } else {
             add_filter('get_the_excerpt', array($this, 'remove_buttons_excerpts'));
         }
         //add_filter( 'the_excerpt', array( $this, 'remove_buttons_excerpts'), -999);
     }
     // @since 1.1.9
     if ($is_excerpt_active == "true") {
         if ($this->custom_priority_active) {
             add_action('the_excerpt', array($this, 'print_share_links_excerpt'), $this->custom_priority, 1);
         } else {
             add_action('the_excerpt', array($this, 'print_share_links_excerpt'), 10, 1);
         }
     }
     add_shortcode('essb', array($this, 'handle_essb_shortcode'));
     add_shortcode('easy-share', array($this, 'handle_essb_shortcode'));
     add_shortcode('easy-social-share-buttons', array($this, 'handle_essb_shortcode'));
     // @since 1.3.9.2
     add_shortcode('easy-social-like', array($this, 'handle_essb_like_buttons_shortcode'));
     add_shortcode('easy-social-like-simple', array($this, 'handle_essb_like_buttons_shortcode'));
     add_shortcode('easy-social-share', array($this, 'handle_essb_shortcode_vk'));
     // @since 1.3.9.3
     add_shortcode('easy-total-shares', array($this, 'handle_essb_total_shortcode'));
     $included_fb_api = isset($option['facebook_like_button_api']) ? $option['facebook_like_button_api'] : '';
     $facebook_advanced_sharing = isset($option['facebookadvanced']) ? $option['facebookadvanced'] : 'false';
     $facebook_like_button = isset($option['facebook_like_button']) ? $option['facebook_like_button'] : 'false';
     if ($included_fb_api != 'true' && $facebook_like_button == 'true') {
         if ($this->social_privacy->is_activated('facebook')) {
             $this->essb_js_builder->include_fb_script();
             $this->fb_api_loaded = true;
         }
     }
     $plusbutton = isset($option['googleplus']) ? $option['googleplus'] : 'false';
     if ($plusbutton == 'true') {
         //add_action ( 'wp_footer', array ($this, 'init_gplus_script' ) );
         if ($this->social_privacy->is_activated('google')) {
             $this->essb_js_builder->include_gplus_script();
             $this->gplus_loaded = true;
         }
     }
     // @since 1.0.4
     $include_vk_api = isset($option['vklike']) ? $option['vklike'] : '';
     if ($include_vk_api == 'true') {
         //add_action ( 'wp_footer', array ($this, 'init_vk_script' ) );
         if ($this->social_privacy->is_activated('vk')) {
             $this->vk_application_id = isset($option['vklikeappid']) ? $option['vklikeappid'] : '';
             //include_vk_script
             add_action('wp_head', array($this, 'include_vk_script'));
         }
     }
     // @since 1.0.7 fix for mobile devices don't to pop network names
     $hidden_network_names = isset($option['hide_social_name']) && $option['hide_social_name'] == 1 ? true : false;
     // @since 1.3.9.2
     $always_hide_names_mobile = isset($option['always_hide_names_mobile']) ? $option['always_hide_names_mobile'] : 'false';
     if ($always_hide_names_mobile == 'true' && $this->isMobile()) {
         $hidden_network_names = true;
     }
     if ($hidden_network_names && $this->isMobile()) {
         $this->essb_css_builder->fix_css_mobile_hidden_network_names();
     }
     if ($hidden_network_names && !$this->isMobile()) {
         $force_hide = isset($option['force_hide_social_name']) ? $option['force_hide_social_name'] : 'false';
         if ($force_hide == 'true') {
             $this->essb_css_builder->fix_css_mobile_hidden_network_names();
             $this->always_hidden_names = true;
         }
     }
     $hidden_buttons_on_lowres_mobile = isset($option['force_hide_buttons_on_mobile']) ? $option['force_hide_buttons_on_mobile'] : 'false';
     if ($hidden_buttons_on_lowres_mobile == 'true' && $this->isMobile()) {
         $this->essb_css_builder->fix_css_mobile_hidden_buttons();
     }
     $force_hide_icons = isset($option['force_hide_icons']) ? $option['force_hide_icons'] : 'false';
     if ($force_hide_icons == 'true') {
         $this->essb_css_builder->fix_css_hide_icons();
     }
     // @since 1.3.9.3
     $force_hide_buttons_on_all_mobile = isset($option['force_hide_buttons_on_all_mobile']) ? $option['force_hide_buttons_on_all_mobile'] : 'false';
     if ($force_hide_buttons_on_all_mobile == "true") {
         $this->deactive_content_filters();
     }
     // @since 1.1
     //add_action ( 'wp_ajax_nopriv_essb_action', array ($this, 'send_email' ) );
     //add_action ( 'wp_ajax_essb_action', array ($this, 'send_email' ) );
     // @since 1.3.1
     add_action('wp_ajax_nopriv_essb_counts', array($this, 'get_share_counts'));
     add_action('wp_ajax_essb_counts', array($this, 'get_share_counts'));
     add_action('wp_ajax_nopriv_essb_self_postcount', array($this, 'essb_self_updatepost_count'));
     add_action('wp_ajax_essb_self_postcount', array($this, 'essb_self_updatepost_count'));
     if (ESSB_SELF_ENABLED) {
         //add_action ( 'wp_ajax_nopriv_essb_self_counts', array ($this, 'get_self_share_counts' ) );
         //add_action ( 'wp_ajax_essb_self_counts', array ($this, 'get_self_share_counts' ) );
         //add_action ( 'wp_ajax_nopriv_essb_self_docount', array ($this, 'essb_self_docount' ) );
         //add_action ( 'wp_ajax_essb_self_docount', array ($this, 'essb_self_docount' ) );
         //$activate_self_hosted_counters = isset ( $option ['activate_self_hosted_counters'] ) ? $option ['activate_self_hosted_counters'] : 'false';
         //if ($activate_self_hosted_counters == 'true') {
         //	add_action ( 'wp_footer', array ($this, 'essb_self_docount_code' ) );
         $this->using_self_counters = true;
         //}
     }
     //$sidebar_draw_in_footer = isset ( $option ['sidebar_draw_in_footer'] ) ? $option ['sidebar_draw_in_footer'] : 'false';
     // since 1.3.9.9
     $sidebar_draw_in_footer = 'true';
     if ($sidebar_draw_in_footer == 'true') {
         add_action('wp_footer', array($this, 'display_sidebar_in_footer'));
     }
     $woocommerce_share = isset($option['woocommece_share']) ? $option['woocommece_share'] : 'false';
     if ($woocommerce_share == "true") {
         add_action('woocommerce_share', array($this, 'handle_woocommerce_share'));
     }
     $wpec_before_desc = isset($option['wpec_before_desc']) ? $option['wpec_before_desc'] : 'false';
     $wpec_after_desc = isset($option['wpec_after_desc']) ? $option['wpec_after_desc'] : 'false';
     $wpec_theme_footer = isset($option['wpec_theme_footer']) ? $option['wpec_theme_footer'] : 'false';
     if ($wpec_before_desc == "true") {
         add_action('wpsc_product_before_description', array($this, 'handle_wpecommerce_share'));
     }
     if ($wpec_after_desc == "true") {
         add_action('wpsc_product_addons', array($this, 'handle_wpecommerce_share'));
     }
     if ($wpec_theme_footer == "true") {
         add_action('wpsc_theme_footer', array($this, 'handle_wpecommerce_share'));
     }
     // @since 1.3.9.8 JigoShop
     $jigoshop_top = isset($option['jigoshop_top']) ? $option['jigoshop_top'] : 'false';
     $jigoshop_bottom = isset($option['jigoshop_bottom']) ? $option['jigoshop_bottom'] : 'false';
     if ($jigoshop_top == 'true') {
         add_action('jigoshop_before_single_product_summary', array($this, 'handle_jigoshop_share'));
     }
     if ($jigoshop_bottom == 'true') {
         add_action('jigoshop_after_main_content', array($this, 'handle_jigoshop_share'));
     }
     // @since 1.2.6
     $bbpress_forum = isset($option['bbpress_forum']) ? $option['bbpress_forum'] : 'false';
     $bbpress_topic = isset($option['bbpress_topic']) ? $option['bbpress_topic'] : 'false';
     $buddypress_group = isset($option['buddypress_group']) ? $option['buddypress_group'] : 'false';
     $buddypress_activity = isset($option['buddypress_activity']) ? $option['buddypress_activity'] : 'false';
     $display_where = isset($option['display_where']) ? $option['display_where'] : '';
     if ($bbpress_topic == 'true') {
         if ('top' == $display_where || 'both' == $display_where || 'float' == $display_where || 'sidebar' == $display_where || 'likeshare' == $display_where || 'sharelike' == $display_where) {
             add_action('bbp_template_before_replies_loop', array($this, 'bbp_show_before_replies'));
         }
         if ('bottom' == $display_where || 'both' == $display_where || 'popup' == $display_where || 'likeshare' == $display_where || 'sharelike' == $display_where) {
             add_action('bbp_template_after_replies_loop', array($this, 'bbp_show_after_replies'));
         }
     }
     if ($bbpress_forum == "true") {
         if ('top' == $display_where || 'both' == $display_where || 'float' == $display_where || 'sidebar' == $display_where || 'likeshare' == $display_where || 'sharelike' == $display_where) {
             add_action('bbp_template_before_topics_loop', array($this, 'bbp_show_before_topics'));
         }
         if ('bottom' == $display_where || 'both' == $display_where || 'popup' == $display_where || 'likeshare' == $display_where || 'sharelike' == $display_where) {
             add_action('bbp_template_after_topics_loop', array($this, 'bbp_show_after_topics'));
         }
     }
     if ($buddypress_group == 'true') {
         add_action('bp_before_group_home_content', array($this, 'buddy_social_button_group_filter'));
     }
     if ($buddypress_activity == 'true') {
         add_action('bp_activity_entry_meta', array($this, 'buddy_social_button_activity_filter'), 999);
     }
     // @since 2.0 myCred Integration
     $this->mycred_active = ESSBOptionsHelper::optionsBoolValue($option, 'mycred_activate');
     if ($this->mycred_active) {
         $this->mycred_group = ESSBOptionsHelper::optionsValue($option, 'mycred_group');
         $this->mycred_points = ESSBOptionsHelper::optionsValue($option, 'mycred_points');
     }
     // @since 1.2.7
     /*$opengraph_tags = isset ( $option ['opengraph_tags'] ) ? $option ['opengraph_tags'] : 'false';
     		
     		if ($opengraph_tags == 'true') {
     			// @since 1.3.9.8
     			$opengraph = ESSB_OpenGraph::get_instance();
     			// @since 1.3.7.3
     			$opengraph->fbadmins = isset ( $option ['opengraph_tags_fbadmins'] ) ? $option ['opengraph_tags_fbadmins'] : '';
     			$opengraph->fbpage = isset ( $option ['opengraph_tags_fbpage'] ) ? $option ['opengraph_tags_fbpage'] : '';
     			$opengraph->fbapp = isset ( $option ['opengraph_tags_fbapp'] ) ? $option ['opengraph_tags_fbapp'] : '';
     			$opengraph->default_image = isset ( $option ['sso_default_image'] ) ? $option ['sso_default_image'] : '';
     			
     			$opengraph->activate_opengraph_metatags ();
     		}
     		
     		// @since 1.3.6
     		$twitter_card_active = isset ( $option ['twitter_card'] ) ? $option ['twitter_card'] : 'false';
     		
     		if ($twitter_card_active == "true") {
     			// @since 1.3.9.8 moved to singleton pattern
     			$twitter_cards = ESSB_TwitterCards::get_instance();
     			$twitter_cards->card_type = isset ( $option ['twitter_card_type'] ) ? $option ['twitter_card_type'] : '';
     			$twitter_cards->twitter_user = isset ( $option ['twitter_card_user'] ) ? $option ['twitter_card_user'] : '';
     			$twitter_cards->default_image = isset ( $option ['sso_default_image'] ) ? $option ['sso_default_image'] : '';
     			
     			$twitter_cards->activate_twittercards_metatags ();
     		}
     		*/
     // @since 1.3.9.5
     $this->essb_css_builder->insert_total_shares_text();
     $this->essb_css_builder->handle_postfloat_custom_css();
     $this->essb_css_builder->customizer_compile_css($this->skinned_social);
     $encode_url_nonlatin = isset($option['encode_url_nonlatin']) ? $option['encode_url_nonlatin'] : 'false';
     if ($encode_url_nonlatin == "true") {
         add_action('template_redirect', array($this, 'essb_sharing_process_requests'), 9);
     }
 }