public static function activate($cache_mode) { $upload_dir = wp_upload_dir(); $base_path = $upload_dir['basedir'] . '/essb_cache/'; $base_url = $upload_dir['baseurl'] . '/essb_cache/'; if (is_ssl()) { $base_url = str_replace('http://', 'https://', $base_url); } if (!is_dir($base_path)) { if (!mkdir($base_path, 0777)) { return false; } } self::$cacheFolder = $base_path; self::$cacheURL = $base_url; if ($cache_mode == "buttons") { define('ESSB3_CACHE_ACTIVE', true); } else { if ($cache_mode == 'resource') { define('ESSB3_CACHE_ACTIVE_RESOURCE', true); } else { define('ESSB3_CACHE_ACTIVE', true); define('ESSB3_CACHE_ACTIVE_RESOURCE', true); } } self::$isActive = true; return true; }
printf('<div class="essb-information-box"><div class="icon"><i class="fa fa-gear"></i></div><div class="inner">%1$s</div></div>', __('Plugin settings are restored to default.' . $cache_plugin_message, ESSB3_TEXT_DOMAIN)); } if ($is_cache_active) { $cache_clear_address = esc_url_raw(add_query_arg(array('purge-cache' => 'true'), wp_get_referer())); printf('<div class="essb-information-box"><div class="icon blue"><i class="fa fa-database"></i></div><div class="inner">%1$s: <b>%2$s</b><a href="%3$s" class="button float_right">%4$s</a></div></div>', __('Easy Social Share Buttons cache is running:', ESSB3_TEXT_DOMAIN), $display_cache_mode, $cache_clear_address, __('Purge Cache', ESSB3_TEXT_DOMAIN)); } if ($general_precompiled_resources) { $cache_clear_address = esc_url_raw(add_query_arg(array('rebuild-resource' => 'true'), wp_get_referer())); printf('<div class="essb-information-box"><div class="icon blue"><i class="fa fa-history"></i></div><div class="inner"><b>%1$s</b><a href="%2$s" class="button float_right">%3$s</a></div></div>', __('Easy Social Share Buttons is using precompiled static resources', ESSB3_TEXT_DOMAIN), $cache_clear_address, __('Rebuild resources', ESSB3_TEXT_DOMAIN)); } if ($backup == 'true') { printf('<div class="essb-information-box"><div class="icon"><i class="fa fa-gear"></i></div><div class="inner">%1$s</div></div>', __('Backup of your current settings is generated. Copy generated configuration string and save it on your computer. You can use it to restore settings or transfer them to other site.', ESSB3_TEXT_DOMAIN)); } if ($purge_cache == 'true') { if (class_exists('ESSBDynamicCache')) { ESSBDynamicCache::flush(); } if (function_exists('purge_essb_cache_static_cache')) { purge_essb_cache_static_cache(); } printf('<div class="essb-information-box"><div class="icon"><i class="fa fa-info-circle"></i></div><div class="inner">%1$s</div></div>', __('Easy Social Share Buttons for WordPress Cache is purged!', ESSB3_TEXT_DOMAIN)); } if ($rebuild_resource == "true") { if (class_exists('ESSBPrecompiledResources')) { ESSBPrecompiledResources::flush(); } } if ($current_tab == "analytics") { $settings_url = esc_url_raw(get_admin_url() . 'admin.php?page=essb_options&tab=social§ion=sharing&subsection=sharing-6'); if (!ESSBOptionValuesHelper::is_active_module('ssanalytics')) { printf('<div class="essb-information-box"><div class="icon orange"><i class="fa fa-info-circle"></i></div><div class="inner">%1$s<a href="%2$s" class="button float_right">%3$s</a></div></div>', __('Statistics function in not activated!', ESSB3_TEXT_DOMAIN), $settings_url, __('Click here to go to settings and activte it', ESSB3_TEXT_DOMAIN));
public function handle_save_settings() { if (@$_POST && isset($_POST['option_page'])) { $changed = false; if ('essb_settings_group' == $this->getval($_POST, 'option_page')) { $this->update_optons(); $this->update_fanscounter_options(); $this->restore_settings(); $this->apply_readymade(); //$this->apply_import(); $changed = true; if (class_exists('ESSBDynamicCache')) { ESSBDynamicCache::flush(); } if (class_exists('ESSBPrecompiledResources')) { ESSBPrecompiledResources::flush(); } if (function_exists('purge_essb_cache_static_cache')) { purge_essb_cache_static_cache(); } } if ($changed) { if (defined('ESSB3_SOCIALFANS_ACTIVE')) { if (class_exists('ESSBSocialFollowersCounter')) { essb_followers_counter()->settle_immediate_update(); $current_options = get_option(ESSB3_OPTIONS_NAME); $fanscounter_clear_on_save = ESSBOptionValuesHelper::options_bool_value($current_options, 'fanscounter_clear_on_save'); if ($fanscounter_clear_on_save) { essb_followers_counter()->clear_stored_values(); //print "clear active"; } } } $user_section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $user_subsection = isset($_REQUEST['subsection']) ? $_REQUEST['subsection'] : ''; //$goback = add_query_arg ( 'settings-updated', 'true', wp_get_referer () ); $goback = esc_url_raw(add_query_arg(array('settings-updated' => 'true', 'section' => $user_section, 'subsection' => $user_subsection), wp_get_referer())); //$goback = str_replace('#038;', '', $goback); wp_redirect($goback); die; } } if (@$_REQUEST && isset($_REQUEST['import2x'])) { $this->apply_import(); $user_section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $user_subsection = isset($_REQUEST['subsection']) ? $_REQUEST['subsection'] : ''; //$goback = add_query_arg ( 'settings-updated', 'true', wp_get_referer () ); $goback = remove_query_arg('import2x'); $goback = esc_url_raw(add_query_arg(array('settings-imported' => 'true', 'section' => $user_section, 'subsection' => $user_subsection), wp_get_referer())); //$goback = str_replace('#038;', '', $goback); wp_redirect($goback); die; } if (@$_REQUEST && isset($_REQUEST['ready_style'])) { $this->apply_readymade(); $user_section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $user_subsection = isset($_REQUEST['subsection']) ? $_REQUEST['subsection'] : ''; //$goback = add_query_arg ( 'settings-updated', 'true', wp_get_referer () ); $goback = remove_query_arg('ready_style'); $goback = esc_url_raw(add_query_arg(array('settings-imported' => 'true', 'section' => $user_section, 'subsection' => $user_subsection), wp_get_referer())); //$goback = str_replace('#038;', '', $goback); wp_redirect($goback); die; } }
function generate_custom_footer_js() { global $post; if ($this->is_plugin_deactivated_on()) { return; } $cache_slug = "essb-js-footer"; if (count($this->js_social_apis) > 0) { if (!ESSBCoreHelper::is_module_deactivate_on('native')) { foreach ($this->js_social_apis as $network => $loaded) { $this->load_social_api_code($network); } } } // load of static scripts async or deferred if (count($this->js_static) > 0) { if ($this->js_defer || $this->js_async) { $js_code_patterns = array(); $load_mode = $this->js_async ? "po.async=true;" : "po.defer=true;"; foreach ($this->js_static as $key => $file) { $js_code_patterns[] = sprintf(' (function() { var po = document.createElement(\'script\'); po.type = \'text/javascript\'; %2$s; po.src = \'%1$s\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s); })();', $file, $load_mode); } printf('<script type="text/javascript">%1$s</script>', implode(" ", $js_code_patterns)); } else { if ($this->js_delayed) { // delayed script loading $js_code_patterns = array(); $load_mode = "po.async=true;"; foreach ($this->js_static as $key => $file) { $js_code_patterns[] = sprintf(' (function() { var po = document.createElement(\'script\'); po.type = \'text/javascript\'; %2$s; po.src = \'%1$s\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s); })();', $file, $load_mode); } printf('<script type="text/javascript">jQuery( document ).ready(function() { setTimeout(function() { %1$s }, 2000); });</script>', implode(" ", $js_code_patterns)); } } } if (count($this->js_static_footer)) { if ($this->js_defer || $this->js_async) { $js_code_patterns = array(); $load_mode = $this->js_async ? "po.async=true;" : "po.defer=true;"; foreach ($this->js_static_footer as $key => $file) { $js_code_patterns[] = sprintf(' (function() { var po = document.createElement(\'script\'); po.type = \'text/javascript\'; %2$s; po.src = \'%1$s\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s); })();', $file, $load_mode); } printf('<script type="text/javascript">%1$s</script>', implode(" ", $js_code_patterns)); } else { if ($this->js_delayed) { // delayed script loading $js_code_patterns = array(); $load_mode = "po.async=true;"; foreach ($this->js_static_footer as $key => $file) { $js_code_patterns[] = sprintf(' (function() { var po = document.createElement(\'script\'); po.type = \'text/javascript\'; %2$s; po.src = \'%1$s\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s); })();', $file, $load_mode); } printf('<script type="text/javascript">jQuery( document ).ready(function() { setTimeout(function() { %1$s }, 2000); });</script>', implode(" ", $js_code_patterns)); } else { foreach ($this->js_static_footer as $key => $file) { //wp_enqueue_script ( $key, $file, array ( 'jquery' ), $this->resource_version, false ); $this->manual_script_load($key, $file); } } } } if (count($this->js_static_noasync_footer)) { foreach ($this->js_static_noasync_footer as $key => $file) { //wp_enqueue_script ( $key, $file, array ( 'jquery' ), $this->resource_version, true ); $this->manual_script_load($key, $file); } } if (count($this->js_code_noncachable)) { // load non cachable javascript code echo implode(" ", $this->js_code_noncachable); } // dynamic footer javascript that can be cached $cache_slug = "essb-js-footer"; if (isset($post)) { if (defined('ESSB3_CACHE_ACTIVE_RESOURCE')) { $cache_key = $cache_slug . $post->ID; $cached_data = ESSBDynamicCache::get_resource($cache_key, 'js'); if ($cached_data != '') { echo "<script type='text/javascript' src='" . $cached_data . "' defer></script>"; return; } } } //$js_code = implode(" ", $this->js_code); $js_code = ''; foreach ($this->js_code as $single) { $js_code .= $single; } if (isset($post)) { if (defined('ESSB3_CACHE_ACTIVE_RESOURCE')) { $cache_key = $cache_slug . $post->ID; ESSBDynamicCache::put_resource($cache_key, $js_code, 'js'); $cached_data = ESSBDynamicCache::get_resource($cache_key, 'js'); if ($cached_data != '') { echo "<script type='text/javascript' src='" . $cached_data . "' defer></script>"; return; } } } echo '<script type="text/javascript">'; echo $js_code; echo '</script>'; }
function generate_share_buttons($position, $likeshare = 'share', $share_options = array(), $is_shortcode = false, $shortcode_options = array(), $media_url = '') { global $post; //timer_start(); // @since 3.5 - runtime cache $cache_key_runtime = ""; if (ESSBGlobalSettings::$cache_runtime) { if (isset($post) && !$is_shortcode) { $cache_key_runtime = sprintf('essb_cache_share_%1$s_%2$s', $post->ID, $position); $cached_data = wp_cache_get($cache_key_runtime); if (false !== $cached_data) { return $cached_data; } } } $only_share = ESSBOptionValuesHelper::options_bool_value($share_options, 'only_share'); $post_type = ESSBOptionValuesHelper::options_value($share_options, 'post_type'); if ($this->general_options['reset_postdata']) { wp_reset_postdata(); } $cache_key = ""; if (isset($post) && defined('ESSB3_CACHE_ACTIVE') && !$is_shortcode) { $cache_key = sprintf('essb_cache_share_%1$s_%2$s', $post->ID, $position); $cached_data = ESSBDynamicCache::get($cache_key); if (!empty($cached_data)) { return $cached_data; } } if (empty($post_type) && isset($post)) { $post_type = $post->post_type; } // -- getting main share details based on current post $post_share_details = $this->get_post_share_details($position); // generate native button main settings $post_native_details = $this->get_native_button_settings($position, $only_share); $post_native_details['order'] = $post_native_details['active'] ? ESSBNativeButtonsHelper::active_native_buttons() : array(); // apply shortcode options if ($is_shortcode) { if ($shortcode_options['forceurl']) { $post_share_details['url'] = ESSBUrlHelper::get_current_page_url(); } if ($shortcode_options['url'] != '') { $post_share_details['url'] = $shortcode_options['url']; } if ($shortcode_options['title'] != '') { $post_share_details['title'] = $shortcode_options['title']; $post_share_details['title_plain'] = $shortcode_options['title']; } if ($shortcode_options['image'] != '') { $post_share_details['image'] = $shortcode_options['image']; } if ($shortcode_options['description'] != '') { $post_share_details['description'] = $shortcode_options['description']; } // customize tweet message if ($shortcode_options['twitter_user'] != '') { $post_share_details['twitter_user'] = $shortcode_options['twitter_user']; } if ($shortcode_options['twitter_hashtags'] != '') { $post_share_details['twitter_hashtags'] = $shortcode_options['twitter_hashtags']; } if ($shortcode_options['twitter_tweet'] != '') { $post_share_details['twitter_tweet'] = $shortcode_options['twitter_tweet']; } else { if ($shortcode_options['title'] != '') { $post_share_details['twitter_tweet'] = $shortcode_options['title']; } } $affwp_active_shortcode = ESSBOptionValuesHelper::options_bool_value($this->options, 'affwp_active_shortcode'); if ($affwp_active_shortcode) { $post_share_details['url'] = ESSBUrlHelper::generate_affiliatewp_referral_link($post_share_details['url']); } $affs_active_shortcode = ESSBOptionValuesHelper::options_bool_value($this->options, 'affs_active_shortcode'); if ($affs_active_shortcode) { $post_share_details['url'] = do_shortcode('[affiliates_url]' . $post_share_details['url'] . '[/affiliates_url]'); } if (isset($shortcode_options['query'])) { $post_share_details['query'] = $shortcode_options['query']; } } else { // activate short url and custom campaign tracking codes // apply custom share options if (!empty($share_options['url'])) { $post_share_details['url'] = $share_options['url']; } if (!empty($share_options['title'])) { $post_share_details['title'] = $share_options['title']; $post_share_details['title_plain'] = $share_options['title_plain']; } if (!empty($share_options['image'])) { $post_share_details['image'] = $share_options['image']; } if (!empty($share_options['description'])) { $post_share_details['description'] = $share_options['description']; } // customize tweet message if (!empty($share_options['twitter_user'])) { $post_share_details['twitter_user'] = $share_options['twitter_user']; } if (!empty($share_options['twitter_hashtags'])) { $post_share_details['twitter_hashtags'] = $share_options['twitter_hashtags']; } if (!empty($share_options['twitter_tweet'])) { $post_share_details['twitter_tweet'] = $share_options['twitter_tweet']; } if ($media_url != '') { $post_share_details['image'] = $media_url; $post_share_details['user_image_url'] = $media_url; } if (!defined('ESSB3_LIGHTMODE')) { // Google Campaign Tracking code $ga_campaign_tracking = $this->general_options['activate_ga_campaign_tracking']; $post_ga_campaign_tracking = get_post_meta(get_the_ID(), 'essb_activate_ga_campaign_tracking', true); if ($post_ga_campaign_tracking != '') { $ga_campaign_tracking = $post_ga_campaign_tracking; } if ($ga_campaign_tracking != '') { $post_share_details['url'] = ESSBUrlHelper::attach_tracking_code($post_share_details['url'], $ga_campaign_tracking); } } } // @since 3.1.2 exist filter to control the share address if (has_filter('essb3_share_url')) { $post_share_details['url'] = apply_filters('essb3_share_url', $post_share_details['url']); } // -- short url code block // code refactor @since 3.4.2 $post_share_details['full_url'] = $post_share_details['url']; if ($this->general_options['shorturl_activate']) { $global_provider = $this->general_options['shorturl_type']; // generating short urls only for selected networks if ($this->network_options['twitter_shareshort']) { $generated_shorturl = ESSBUrlHelper::short_url($post_share_details['url'], $global_provider, get_the_ID(), $this->general_options['shorturl_bitlyuser'], $this->general_options['shorturl_bitlyapi']); $post_share_details['short_url_twitter'] = $generated_shorturl; $post_share_details['short_url_whatsapp'] = $generated_shorturl; } else { // generate short url for all networks $post_share_details['short_url'] = ESSBUrlHelper::short_url($post_share_details['url'], $global_provider, get_the_ID(), $this->general_options['shorturl_bitlyuser'], $this->general_options['shorturl_bitlyapi']); $post_share_details['short_url_twitter'] = $post_share_details['short_url']; $post_share_details['short_url_whatsapp'] = $post_share_details['short_url']; } if (empty($post_share_details['short_url'])) { $post_share_details['short_url'] = $post_share_details['url']; } if (empty($post_share_details['short_url_twitter'])) { $post_share_details['short_url_twitter'] = $post_share_details['url']; } if (empty($post_share_details['short_url_whatsapp'])) { $post_share_details['short_url_whatsapp'] = $post_share_details['url']; } } else { $post_share_details['short_url'] = $post_share_details['url']; $post_share_details['short_url_twitter'] = $post_share_details['url']; $post_share_details['short_url_whatsapp'] = $post_share_details['url']; } //-- end: short url code block // -- main button design $button_style = $this->get_buttons_visual_options($position); $social_networks = $this->network_options['networks']; $social_networks_order = $this->network_options['networks_order']; $social_networks_names = $this->network_options['default_names']; // apply settings based on position when active $check_position_settings_key = $position; if (essb_is_mobile() && ESSBOptionValuesHelper::is_active_position_settings('mobile')) { $check_position_settings_key = 'mobile'; } if (essb_is_mobile()) { if (ESSBGlobalSettings::$mobile_networks_active) { $social_networks = ESSBGlobalSettings::$mobile_networks; } if (ESSBGlobalSettings::$mobile_networks_order_active) { $social_networks_order = ESSBGlobalSettings::$mobile_networks_order; } } // double check to avoid missconfiguration based on mobile specific settings if ($check_position_settings_key != 'sharebar' && $check_position_settings_key != 'sharepoint' && $check_position_settings_key != 'sharebottom') { // first check for post type settins - if there are such that will be the settings key. If nothing is active switch to button position // settings if (!defined('ESSB3_LIGHTMODE')) { if (!empty($post_type)) { if (ESSBOptionValuesHelper::is_active_position_settings(sprintf('post-type-%1$s', $post_type))) { $check_position_settings_key = sprintf('post-type-%1$s', $post_type); } } } // postbar settings that are over the setup if ($position == 'postbar') { $button_style = ESSBOptionValuesHelper::apply_postbar_position_style_settings('postbar', $button_style); $instance_template = $button_style['template']; $instance_template_slug = ESSBCoreHelper::template_folder($instance_template); // @since 3.4.2 - add check to avoid load of blank templates if ($instance_template_slug != $this->design_options['template_slug'] && !empty($instance_template_slug)) { $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug); } } if (ESSBOptionValuesHelper::is_active_position_settings($check_position_settings_key)) { $button_style = ESSBOptionValuesHelper::apply_position_style_settings($check_position_settings_key, $button_style); $instance_template = $button_style['template']; $instance_template_slug = ESSBCoreHelper::template_folder($instance_template); // @since 3.4.2 - add check to avoid load of blank templates if ($instance_template_slug != $this->design_options['template_slug'] && !empty($instance_template_slug)) { $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug); } if ($check_position_settings_key != 'mobile') { $personalized_networks = ESSBOptionValuesHelper::get_active_social_networks_by_position($check_position_settings_key); $personalized_network_order = ESSBOptionValuesHelper::get_order_of_social_networks_by_position($check_position_settings_key); if (is_array($personalized_networks) && count($personalized_networks) > 0) { $social_networks = $personalized_networks; } if (is_array($personalized_network_order) && count($personalized_network_order) > 0) { $social_networks_order = $personalized_network_order; } } $social_networks_names = ESSBOptionValuesHelper::apply_position_network_names($check_position_settings_key, $social_networks_names); } else { if (defined('ESSB3_LIGHTMODE')) { if (ESSBLightModeHelper::position_with_predefined_options($position)) { $button_style = ESSBLightModeHelper::apply_position_predefined_settings($position, $button_style); } } } } // apply safe default of mobile styles to avoid miss configured display $share_bottom_networks = array(); if ($position == 'sharebar' || $position == 'sharepoint' || $position == 'sharebottom') { $post_native_details['active'] = false; // apply mobile personalizations by display methods if (ESSBOptionValuesHelper::is_active_position_settings($position)) { $button_style = ESSBOptionValuesHelper::apply_mobile_position_style_settings($position, $button_style); $instance_template = $button_style['template']; $instance_template_slug = ESSBCoreHelper::template_folder($instance_template); if ($instance_template_slug != $this->design_options['template_slug']) { $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug); } $personalized_networks = ESSBOptionValuesHelper::get_active_social_networks_by_position($position); $personalized_network_order = ESSBOptionValuesHelper::get_order_of_social_networks_by_position($position); if (is_array($personalized_networks) && count($personalized_networks) > 0) { $social_networks = $personalized_networks; } if (is_array($personalized_network_order) && count($personalized_network_order) > 0) { $social_networks_order = $personalized_network_order; } $social_networks_names = ESSBOptionValuesHelper::apply_position_network_names($position, $social_networks_names); } // apply sharebar and sharepoint default styles if ($position == 'sharebar' || $position == 'sharepoint') { // for those display methods the more buttons is not needed if (in_array('more', $social_networks)) { if (($key = array_search('more', $social_networks)) !== false) { unset($social_networks[$key]); } } $button_style['button_style'] = "button"; if ($button_style['show_counter']) { if (strpos($button_style['counter_pos'], 'inside') === false && strpos($button_style['counter_pos'], 'hidden') === false) { $button_style['counter_pos'] = "insidename"; } if ($button_style['total_counter_pos'] != 'hidden' && $button_style['total_counter_pos'] != 'after') { $button_style['total_counter_pos'] = "before"; } } $button_style['button_width'] = "column"; $button_style['button_width_columns'] = "1"; } if ($position == 'sharebottom') { if (in_array('more', $social_networks)) { if (($key = array_search('more', $social_networks)) !== false) { unset($social_networks[$key]); } } $button_style['button_style'] = "icon"; $button_style['show_counter'] = false; $button_style['nospace'] = true; $button_style['button_width'] = "column"; $available_networks_count = ESSBOptionValuesHelper::options_value($this->options, 'mobile_sharebuttonsbar_count'); $mobile_sharebuttonsbar_names = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_names'); if ($mobile_sharebuttonsbar_names) { $button_style['button_style'] = 'button'; } if (intval($available_networks_count) == 0) { $available_networks_count = 4; } if (count($social_networks) > intval($available_networks_count)) { $share_bottom_networks = $social_networks; array_splice($social_networks, intval($available_networks_count) - 1); $social_networks[] = "more"; //$button_style['more_button_icon'] = "dots"; } $button_style['button_width_columns'] = intval($available_networks_count); } } if (!is_array($social_networks)) { $social_networks = array(); } if (!is_array($social_networks_order) || count($social_networks_order) == 0) { $social_networks_order = ESSBCoreHelper::generate_network_list(); } // apply shortcode customizations if ($is_shortcode) { // apply personalization of social networks if set from shortcode if (count($shortcode_options['networks']) > 0) { $social_networks = $shortcode_options['networks']; $social_networks_order = $shortcode_options['networks']; } if ($shortcode_options['customize_texts']) { $social_networks_names = $shortcode_options['network_texts']; } // apply shortcode counter options if ($shortcode_options['counters'] == 1) { $button_style['show_counter'] = true; } else { $button_style['show_counter'] = false; } if (!empty($shortcode_options['style'])) { $button_style['button_style'] = $shortcode_options['style']; } if (!empty($shortcode_options['counters_pos'])) { $button_style['counter_pos'] = $shortcode_options['counters_pos']; } if (!empty($shortcode_options['total_counter_pos'])) { $button_style['total_counter_pos'] = $shortcode_options['total_counter_pos']; } if ($shortcode_options['hide_total']) { $button_style['total_counter_pos'] = "hidden"; } if ($shortcode_options['fullwidth']) { $button_style['button_width'] = "full"; if (!empty($shortcode_options['fullwidth_fix'])) { $button_style['button_width_full_button'] = $shortcode_options['fullwidth_fix']; } if (!empty($shortcode_options['fullwidth_align'])) { $button_style['fullwidth_align'] = $shortcode_options['fullwidth_align']; } if (!empty($shortcode_options['fullwidth_first'])) { $button_style['button_width_full_first'] = $shortcode_options['fullwidth_first']; } if (!empty($shortcode_options['fullwidth_second'])) { $button_style['button_width_full_second'] = $shortcode_options['fullwidth_second']; } } if ($shortcode_options['fixedwidth']) { $button_style['button_width'] = "fixed"; if (!empty($shortcode_options['fixedwidth_px'])) { $button_style['button_width_fixed_value'] = $shortcode_options['fixedwidth_px']; } if (!empty($shortcode_options['fixedwidth_align'])) { $button_style['button_width_fixed_align'] = $shortcode_options['fixedwidth_align']; } } if (!empty($shortcode_options['morebutton'])) { $button_style['more_button_func'] = $shortcode_options['morebutton']; } if (!empty($shortcode_options['morebutton_icon'])) { $button_style['more_button_icon'] = $shortcode_options['morebutton_icon']; } if ($shortcode_options['column']) { $button_style['button_width'] = "column"; if (!empty($shortcode_options['columns'])) { $button_style['button_width_columns'] = $shortcode_options['columns']; } } if (!empty($shortcode_options['template'])) { $instance_template_slug = $shortcode_options['template']; if ($instance_template_slug != $this->design_options['template_slug']) { $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug); } $button_style['template'] = $shortcode_options['template']; } if (!empty($shortcode_options['sidebar_pos'])) { $button_style['sidebar_pos'] = $shortcode_options['sidebar_pos']; } $button_style['nospace'] = $shortcode_options['nospace']; $button_style['nostats'] = $shortcode_options['nostats']; if (!empty($shortcode_options['animation'])) { $button_style['button_animation'] = $shortcode_options['animation']; } if (!empty($shortcode_options['fblike'])) { $post_native_details['facebook_url'] = $shortcode_options['fblike']; } if (!empty($shortcode_options['plusone'])) { $post_native_details['google_url'] = $shortcode_options['plusone']; } if (!$shortcode_options['message']) { $button_style['message_share_buttons'] = ""; $button_style['message_before_share_buttons'] = ""; } //apply again mobile settings for the mobile buttons bar if ($position == 'sharebottom') { if (in_array('more', $social_networks)) { if (($key = array_search('more', $social_networks)) !== false) { unset($social_networks[$key]); } } $button_style['button_style'] = "icon"; $button_style['show_counter'] = false; $button_style['nospace'] = true; $button_style['button_width'] = "column"; $available_networks_count = ESSBOptionValuesHelper::options_value($this->options, 'mobile_sharebuttonsbar_count'); $mobile_sharebuttonsbar_names = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_names'); if ($mobile_sharebuttonsbar_names) { $button_style['button_style'] = 'button'; } if (intval($available_networks_count) == 0) { $available_networks_count = 4; } if (count($social_networks) > intval($available_networks_count)) { $share_bottom_networks = $social_networks; array_splice($social_networks, intval($available_networks_count) - 1); $social_networks[] = "more"; $social_networks_order[] = "more"; //$button_style['more_button_icon'] = "dots"; } $button_style['button_width_columns'] = intval($available_networks_count); } // @since 3.5 Integration with post views add-on via shortcode option if (!empty($shortcode_options['postviews'])) { $button_style['postviews'] = $shortcode_options['postviews']; } } // generate unique instance key $salt = mt_rand(); // attache compliled mail message data if (in_array("mail", $social_networks)) { //if ($this->network_options['mail_function'] == "form") { $base_subject = $this->network_options['mail_subject']; $base_body = $this->network_options['mail_body']; $base_subject = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_subject); $base_body = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_body); $post_share_details['mail_subject'] = $base_subject; $post_share_details['mail_body'] = $base_body; $ga_tracking = ESSBOptionValuesHelper::options_value($this->options, 'activate_ga_campaign_tracking'); if ($ga_tracking != '') { $post_share_details['mail_subject'] = str_replace('{network}', 'mail', $post_share_details['mail_subject']); $post_share_details['mail_body'] = str_replace('{title}', $post_share_details['title_plain'], $post_share_details['mail_body']); $post_share_details['mail_body'] = str_replace('{network}', 'mail', $post_share_details['mail_body']); } //} //else { // $post_share_details['mail_subject'] = ''; // $post_share_details['mail_body'] = ''; //} essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_generate_popup_mailform(), true, 'essb-mailform'); essb_resource_builder()->add_js(ESSBButtonHelper::print_mailer_code($post_share_details['mail_subject'], $post_share_details['mail_body'], $salt, $post_share_details["post_id"], $position), true, 'essb-mailform-' . $salt); } $button_style['included_button_count'] = count($social_networks); if ($button_style['show_counter']) { if (isset($button_style['total_counter_pos'])) { if ($button_style['total_counter_pos'] != 'hidden') { $button_style['included_button_count']++; } } } $intance_morebutton_func = $this->network_options['more_button_func']; if ($position == "sidebar" || $position == "postfloat") { //$intance_morebutton_func = "2"; if ($button_style['more_button_func'] == '1') { $button_style['more_button_func'] = "2"; } } if ($position == "sharebottom") { //$intance_morebutton_func = "3"; $button_style['more_button_func'] = "3"; } //$button_style['more_button_func'] = $intance_morebutton_func; // sidebar close button option if activated into settings if ($this->design_options['sidebar_leftright_close'] && $position == "sidebar") { $social_networks[] = "sidebar-close"; $social_networks_order[] = "sidebar-close"; } // apply additional native button options if ($post_native_details['active']) { $post_native_details['url'] = $post_share_details['url']; $post_native_details['text'] = $post_share_details['title']; } // @since 3.0 beta 4 - check if on post settings we have set counters that are not active generally if ($button_style['show_counter']) { if (!isset($this->activated_resources['counters'])) { if (!defined('ESSB3_COUNTER_LOADED') && !defined('ESSB3_CACHED_COUNTERS')) { $script_url = ESSB3_PLUGIN_URL . '/assets/js/easy-social-share-buttons' . $this->use_minified_js . '.js'; essb_resource_builder()->add_static_resource_footer($script_url, 'easy-social-share-buttons', 'js'); $this->activated_resources['counters'] = true; define('ESSB3_COUNTER_LOADED', true); } } } // @since 3.0.3 fix for the mail function $button_style['mail_function'] = $this->network_options['mail_function']; // @since 3.2 - passing mobile state to button style to allow deactivate advaned share on mobile (does not work); $button_style['is_mobile'] = essb_is_mobile(); $ssbuttons = ESSBButtonHelper::draw_share_buttons($post_share_details, $button_style, $social_networks, $social_networks_order, $social_networks_names, $position, $salt, $likeshare, $post_native_details); //print_r($post_native_details); if (!defined('ESSB3_LIGHTMODE')) { if ($post_native_details['active']) { if (!$post_native_details['sameline']) { $post_native_details['withshare'] = true; //@fixed display of native for float in 3.0beta5 $native_buttons_code = ESSBNativeButtonsHelper::draw_native_buttons($post_native_details, $post_native_details['order'], $post_native_details['counters'], $post_native_details['sameline'], $post_native_details['skinned']); $ssbuttons = str_replace('<!--native--></div>', $native_buttons_code . '</div>', $ssbuttons); } } } if ($button_style['button_width'] == "fixed") { //print "fixed button code adding"; $fixedwidth_key = $button_style['button_width_fixed_value'] . "-" . $button_style['button_width_fixed_align']; essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_fixedwidth_button($salt, $button_style['button_width_fixed_value'], $button_style['button_width_fixed_align']), 'essb-fixed-width-' . $fixedwidth_key, 'footer'); } if ($button_style['button_width'] == "full") { //print_r($button_style); //print "fixed button code adding"; $count_of_social_networks = count($social_networks); if ($button_style['show_counter']) { if (isset($button_style['total_counter_pos'])) { if ($button_style['total_counter_pos'] != 'hidden') { $count_of_social_networks++; } } } $container_width = $button_style['button_width_full_container']; $single_button_width = intval($container_width) / $count_of_social_networks; $single_button_width = floor($single_button_width); //essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_fullwidth_button($single_button_width, $button_style['button_width_full_button'], $button_style['button_width_full_container']), 'essb-full-width-'.$single_button_width.'-'.$button_style['button_width_full_button'].'-'.$button_style['button_width_full_container'], 'footer'); essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_fullwidth_buttons($count_of_social_networks, $button_style['button_width_full_container'], $button_style['button_width_full_button'], $button_style['button_width_full_first'], $button_style['button_width_full_second']), 'essb-full-width-' . $single_button_width . '-' . $button_style['button_width_full_button'] . '-' . $button_style['button_width_full_container'], 'footer'); } // more buttons code append if (in_array("more", $social_networks)) { //print "position = ".$position. ", more button = ".$intance_morebutton_func; $user_set_morebutton_func = $button_style['more_button_func']; // @since 3.3 - option to change more button style on each display position if (isset($button_style['location_more_button_func'])) { if (!empty($button_style['location_more_button_func'])) { $user_set_morebutton_func = $button_style['location_more_button_func']; } } if ($user_set_morebutton_func == '1') { essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_generate_more_button_inline(), true, 'essb-inlinemore-code'); } if ($user_set_morebutton_func == '2' || $user_set_morebutton_func == '3') { essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_generate_more_button_popup(), true, 'essb-popupmore-code'); $listAllNetworks = $user_set_morebutton_func == '2' ? true : false; $more_social_networks = ESSBCoreHelper::generate_list_networks($listAllNetworks); $more_social_networks_order = ESSBCoreHelper::generate_network_list(); if ($position == "sharebottom") { $more_social_networks = $share_bottom_networks; $more_social_networks_order = $social_networks_order; //$button_style['more_button_icon'] = "dots"; } $button_style['button_style'] = "button"; $button_style['show_counter'] = false; $button_style['button_width'] = "column"; $button_style['button_width_columns'] = essb_is_mobile() ? "1" : "3"; $button_style['counter_pos'] = "left"; if ($position == "sharebottom") { $button_style['button_width_columns'] = "1"; } $more_salt = mt_rand(); $ssbuttons .= sprintf('<div class="essb_morepopup essb_morepopup_%1$s" style="display:none;"> <a href="#" class="essb_morepopup_close" onclick="essb_toggle_less_popup(\'%1$s\'); return false;"></a> <div class="essb_morepopup_content essb_morepopup_content_%1$s">%2$s</div></div> <div class="essb_morepopup_shadow essb_morepopup_shadow_%1$s" onclick="essb_toggle_less_popup(\'%1$s\'); return false;"></div>', $salt, ESSBButtonHelper::draw_share_buttons($post_share_details, $button_style, $more_social_networks, $more_social_networks_order, $social_networks_names, "more_popup", $more_salt, 'share')); //print $more_salt."|"; // fix for not workin mail in more button if (!isset($post_share_details['mail_subject'])) { $base_subject = $this->network_options['mail_subject']; $base_body = $this->network_options['mail_body']; $base_subject = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_subject); $base_body = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_body); $post_share_details['mail_subject'] = $base_subject; $post_share_details['mail_body'] = $base_body; $ga_tracking = ESSBOptionValuesHelper::options_value($this->options, 'activate_ga_campaign_tracking'); if ($ga_tracking != '') { $post_share_details['mail_subject'] = str_replace('{network}', 'mail', $post_share_details['mail_subject']); $post_share_details['mail_body'] = str_replace('{title}', $post_share_details['title_plain'], $post_share_details['mail_body']); $post_share_details['mail_body'] = str_replace('{network}', 'mail', $post_share_details['mail_body']); } } essb_resource_builder()->add_js(ESSBButtonHelper::print_mailer_code($post_share_details['mail_subject'], $post_share_details['mail_body'], $more_salt, $post_share_details["post_id"], $position), true, 'essb-mailform-' . $more_salt); essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_morepopup_css(), 'essb-morepopup-css', 'footer'); } } // apply clean of new lines if (!empty($ssbuttons)) { $ssbuttons = trim(preg_replace('/\\s+/', ' ', $ssbuttons)); } if (!empty($cache_key)) { ESSBDynamicCache::put($cache_key, $ssbuttons); } if (!empty($cache_key_runtime) && ESSBGlobalSettings::$cache_runtime) { wp_cache_set($cache_key_runtime, $ssbuttons); } //print "generated in ".timer_stop(0, 5); return $ssbuttons; }
// update relted to WordPress 4.4 changes if (!$disable_admin_menu) { include_once ESSB3_PLUGIN_ROOT . 'lib/core/essb-adminbar-menu.php'; add_action("init", "ESSBAdminMenuInit3"); function ESSBAdminMenuInit3() { global $essb_adminmenu; if (is_admin_bar_showing()) { $essb_adminmenu = new ESSBAdminBarMenu3(); } } } if (ESSBOptionValuesHelper::is_active_module('cachedynamic')) { include_once ESSB3_PLUGIN_ROOT . 'lib/core/cache/essb-dynamic-cache.php'; $cache_mode = ESSBOptionValuesHelper::options_value($essb_options, 'essb_cache_mode'); ESSBDynamicCache::activate($cache_mode); } if (ESSBOptionValuesHelper::is_active_module('precompiled')) { include_once ESSB3_PLUGIN_ROOT . 'lib/core/cache/essb-precompiled.php'; ESSBPrecompiledResources::activate(); } if (ESSBOptionValuesHelper::is_active_module('cachestatic')) { include_once ESSB3_PLUGIN_ROOT . 'lib/core/cache/essb-static-cache.php'; } // dynamic resource builder include_once ESSB3_PLUGIN_ROOT . 'lib/core/essb-resource-builder.php'; include_once ESSB3_PLUGIN_ROOT . 'lib/core/essb-resource-builder-snippets.php'; include_once ESSB3_PLUGIN_ROOT . 'lib/external/mobile-detect/mobile-detect.php'; // include social network related plugin classes if (ESSBOptionValuesHelper::is_active_module('loveyou')) { include_once ESSB3_PLUGIN_ROOT . 'lib/networks/essb-loveyou.php';
public function handle_save_settings() { if (@$_POST && isset($_POST['option_page'])) { $changed = false; if ('essb_settings_group' == $this->getval($_POST, 'option_page')) { $this->update_optons(); $this->update_fanscounter_options(); $this->restore_settings(); $this->apply_readymade(); //$this->apply_import(); $changed = true; if (class_exists('ESSBDynamicCache')) { ESSBDynamicCache::flush(); } if (function_exists('purge_essb_cache_static_cache')) { purge_essb_cache_static_cache(); } } if ($changed) { if (defined('ESSB3_SOCIALFANS_ACTIVE')) { ESSBSocialFansCounter::clear_cached_data(); } $user_section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $user_subsection = isset($_REQUEST['subsection']) ? $_REQUEST['subsection'] : ''; //$goback = add_query_arg ( 'settings-updated', 'true', wp_get_referer () ); $goback = esc_url_raw(add_query_arg(array('settings-updated' => 'true', 'section' => $user_section, 'subsection' => $user_subsection), wp_get_referer())); //$goback = str_replace('#038;', '', $goback); wp_redirect($goback); die; } } if (@$_REQUEST && isset($_REQUEST['import2x'])) { $this->apply_import(); $user_section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $user_subsection = isset($_REQUEST['subsection']) ? $_REQUEST['subsection'] : ''; //$goback = add_query_arg ( 'settings-updated', 'true', wp_get_referer () ); $goback = remove_query_arg('import2x'); $goback = esc_url_raw(add_query_arg(array('settings-imported' => 'true', 'section' => $user_section, 'subsection' => $user_subsection), wp_get_referer())); //$goback = str_replace('#038;', '', $goback); wp_redirect($goback); die; } }