public function register_assets() { global $post, $essb_options; if ($this->general_options['reset_postdata']) { wp_reset_postdata(); } if ($this->is_plugin_deactivated_on() || ESSBCoreHelper::is_module_deactivate_on('share')) { $this->deactivate_stored_filter_and_actions(); return; } $this->register_locations(); $essb_post_template = ""; $essb_post_animations = ""; $essb_post_content_position = ""; $essb_post_button_position = array(); $essb_post_native = ""; $essb_post_native_skin = ""; // @since 3.3 - this check will be done only if the option is not turned off if (isset($post) && !$this->advanced_visual_on_post_off) { // @since version 3.4 - code is moved to extender to allow running in light mode if (class_exists('ESSBCoreExtenderPostVisualOptions')) { $post_visual_options = ESSBCoreExtenderPostVisualOptions::get($post, $this->general_options['button_position']); foreach ($post_visual_options as $single_callback_option) { $param_name = $single_callback_option['param']; if ($single_callback_option['type'] == 'general_options') { $this->general_options[$param_name] = $single_callback_option['value']; } else { if ($single_callback_option['type'] == 'design_options') { $this->design_options[$param_name] = $single_callback_option['value']; } else { if ($single_callback_option['type'] == 'button_style') { $this->button_style[$param_name] = $single_callback_option['value']; } else { if ($param_name == 'modified_locations') { if ($single_callback_option['value']) { $this->deactivate_stored_filters_and_actions_by_group('button_position'); $this->reactivate_button_position_filters(); } } else { if ($param_name == 'post_template') { $essb_post_template = $single_callback_option['value']; } else { if ($param_name == 'post_animations') { $essb_post_animations = $single_callback_option['value']; } } } } } } } } // end of on post visual options } // non cachable - required for generation of proper ajax requests essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_admin_ajax_access_code(), false, 'essb-head-ajax', 'head'); essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_window_open_code(), true, 'essb-window-code'); if (ESSBOptionValuesHelper::options_bool_value($this->options, 'activate_ga_tracking')) { essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_ga_tracking_code(), true, 'essb-ga-tracking-code'); } if (in_array('print', $this->network_options['networks']) && !ESSBOptionValuesHelper::options_bool_value($this->options, 'print_use_printfriendly')) { essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_window_print_code(), true, 'essb-printing-code'); $this->activated_resources['print'] = 'true'; } // loading aminations $css_animations = ESSBOptionValuesHelper::options_value($this->options, 'css_animations'); if (!empty($essb_post_animations)) { $css_animations = $essb_post_animations; } if ($css_animations != '' && $css_animations != "no") { //@since 3.5 - animations come from external css $animate_url = ESSB3_PLUGIN_URL . '/assets/css/essb-animations.min.css'; essb_resource_builder()->add_static_resource($animate_url, 'easy-social-share-buttons-animations', 'css'); $this->activated_resources['animations'] = 'true'; //essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_animation_code($css_animations), 'essb-css-animations'); } essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_counter_style(), 'essb-counter-style'); essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_generate_column_width(), 'essb-column-width-style'); essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_sidebar_options(), 'essb-sidebar-style'); essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_compile_display_locations_code(), 'essb-locations-css'); // activate the fixer for mobiles $mobile_sharebuttonsbar_fix = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_fix'); if ($mobile_sharebuttonsbar_fix) { essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_mobilesharebar_fix_code(), 'essb-mobilesharebar-fix-css'); } $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $use_minifed_js = $this->general_options['use_minified_js'] ? ".min" : ""; $this->use_minified_css = $use_minifed_css; $this->use_minified_js = $use_minifed_js; // main theme CSS $template_id = $this->design_options['template']; $template_slug = ESSBCoreHelper::template_folder($template_id); if (!empty($essb_post_template)) { $template_slug = $essb_post_template; $this->design_options['template'] = $template_slug; } $this->design_options['template_slug'] = $template_slug; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_resource($template_url, 'easy-social-share-buttons', 'css'); // counter script if ($this->button_style['show_counter']) { if (!defined('ESSB3_COUNTER_LOADED') && !defined('ESSB3_CACHED_COUNTERS')) { $script_url = ESSB3_PLUGIN_URL . '/assets/js/easy-social-share-buttons' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'easy-social-share-buttons', 'js'); $this->activated_resources['counters'] = 'true'; define('ESSB3_COUNTER_LOADED', true); } } $display_locations_script = false; // float from content top $content_postion = $this->general_options['content_position']; if (!empty($essb_post_content_position)) { $content_postion = $essb_post_content_position; $this->general_options['content_position'] = $content_postion; } if ($content_postion == "content_float" || $content_postion == "content_floatboth") { //$script_url = ESSB3_PLUGIN_URL .'/assets/js/essb-float'.$use_minifed_js.'.js'; //essb_resource_builder()->add_static_resource($script_url, 'essb-float', 'js'); $this->activated_resources['float'] = 'true'; $display_locations_script = true; } // mobile CSS load if ($this->is_mobile_safecss() && (in_array('sharebar', $this->general_options['button_position']) || in_array('sharepoint', $this->general_options['button_position']) || in_array('sharebottom', $this->general_options['button_position']))) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-mobile' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-mobile', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-mobile' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-mobile', 'js'); $this->activated_resources['mobile'] = 'true'; } // post vertical float or sidebar // @since 3.5 - load styles from single file $display_locations_style = false; if (in_array('sidebar', $this->general_options['button_position']) || in_array('postfloat', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-sidebar'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-sidebar', 'css'); $display_locations_style = true; $this->activated_resources['sidebar'] = 'true'; if (in_array('postfloat', $this->general_options['button_position'])) { //$script_url = ESSB3_PLUGIN_URL .'/assets/js/essb-postfloat'.$use_minifed_js.'.js'; //essb_resource_builder()->add_static_resource($script_url, 'essb-postfloat', 'js'); $this->activated_resources['postfloat'] = 'true'; $display_locations_script = true; } } if (in_array('topbar', $this->general_options['button_position']) || in_array('bottombar', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-topbottom-bar'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-topbottom-bar', 'css'); $this->activated_resources['topbottombar'] = 'true'; $display_locations_style = true; } if (in_array('popup', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-popup'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-popup', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-popup' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-popup', 'js', true); $this->activated_resources['popup'] = 'true'; $display_locations_style = true; } if (in_array('heroshare', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-heroshare'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-heroshare', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-heroshare' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-heroshare', 'js', true); $this->activated_resources['heroshare'] = 'true'; $display_locations_style = true; } // @since 3.5 if (in_array('postbar', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-postbar'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-postbar', 'css'); //$script_url = ESSB3_PLUGIN_URL .'/assets/js/essb-postbar'.$use_minifed_js.'.js'; //essb_resource_builder()->add_static_resource($script_url, 'essb-postbar', 'js', true); if (!isset($this->activated_resources['postbar'])) { essb_resource_builder()->add_css(ESSBResourceBuilderSnippets::css_build_postbar_customizations(), 'essb-postbar-custom-style'); } $display_locations_style = true; $this->activated_resources['postbar'] = 'true'; $display_locations_script = true; } if (in_array('flyin', $this->general_options['button_position'])) { //$style_url = ESSB3_PLUGIN_URL .'/assets/css/essb-flyin'.$use_minifed_css.'.css'; //essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-flyin', 'css'); $display_locations_style = true; $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-flyin' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-flyin', 'js'); $this->activated_resources['flyin'] = 'true'; } // @since 3.5 // loading of display settings style if ($display_locations_style) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-display-methods' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-display-methods', 'css'); $this->activated_resources['display_positions_style'] = 'true'; } if ($display_locations_script) { $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-display-methods' . $use_minifed_js . '.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-display-methods', 'js'); $this->activated_resources['display_positions_script'] = 'true'; } $this->general_options['included_mail'] = false; if (in_array('mail', $this->network_options['networks'])) { if ($this->network_options['mail_function'] == "form") { $this->general_options['included_mail'] = true; $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-mailform' . $use_minifed_css . '.css'; essb_resource_builder()->add_static_resource($style_url, 'easy-social-share-buttons-mailform', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-mailform.js'; essb_resource_builder()->add_static_resource($script_url, 'essb-mailform', 'js', true); $this->activated_resources['mail'] = 'true'; } } }
public function register_assets() { global $post, $essb_options, $essb_available_button_positions; if ($this->general_options['reset_postdata']) { wp_reset_postdata(); } if ($this->is_plugin_deactivated_on() || ESSBCoreHelper::is_module_deactivate_on('share')) { $this->deactivate_stored_filter_and_actions(); return; } $essb_post_button_style = ""; $essb_post_template = ""; $essb_post_counters = ""; $essb_post_counter_pos = ""; $essb_post_total_counter_pos = ""; $essb_post_customizer = ""; $essb_post_animations = ""; $essb_post_content_position = ""; $essb_post_button_position = array(); $essb_post_native = ""; $essb_post_native_skin = ""; if (isset($post)) { $essb_post_button_style = get_post_meta($post->ID, 'essb_post_button_style', true); $essb_post_template = get_post_meta($post->ID, 'essb_post_template', true); $essb_post_counters = get_post_meta($post->ID, 'essb_post_counters', true); $essb_post_counter_pos = get_post_meta($post->ID, 'essb_post_counter_pos', true); $essb_post_total_counter_pos = get_post_meta($post->ID, 'essb_post_total_counter_pos', true); $essb_post_animations = get_post_meta($post->ID, 'essb_post_animations', true); $essb_post_optionsbp = get_post_meta($post->ID, 'essb_post_optionsbp', true); $essb_post_content_position = get_post_meta($post->ID, 'essb_post_content_position', true); $essb_post_button_position = array(); foreach ($essb_available_button_positions as $position => $name) { $position_value = get_post_meta($post->ID, 'essb_post_button_position_' . $position, true); if ($position_value != '') { $essb_post_button_position[$position] = $position_value; } } $essb_post_native = get_post_meta($post->ID, 'essb_post_native', true); $essb_post_native_skin = get_post_meta($post->ID, 'essb_post_native_skin', true); // apply to general settings if (!empty($essb_post_button_style)) { $this->design_options['button_style'] = $essb_post_button_style; } if (!empty($essb_post_counters)) { $this->button_style['show_counter'] = ESSBOptionValuesHelper::unified_true($essb_post_counters); } if (!empty($essb_post_counter_pos)) { $this->button_style['counter_pos'] = $essb_post_counter_pos; } if (!empty($essb_post_total_counter_pos)) { $this->button_style['total_counter_pos'] = $essb_post_total_counter_pos; } if (!empty($essb_post_optionsbp)) { define('ESSB3_POST_OPTIONSBP', $essb_post_optionsbp); } if (!empty($essb_post_native)) { $essb_options['native_active'] = ESSBOptionValuesHelper::unified_true($essb_post_native); if ($essb_options['native_active']) { // manually activate and deactivate native buttons if (!defined('ESSB3_NATIVE_ACTIVE')) { include_once ESSB3_PLUGIN_ROOT . 'lib/core/native-buttons/essb-skinned-native-button.php'; include_once ESSB3_PLUGIN_ROOT . 'lib/core/native-buttons/essb-social-privacy.php'; include_once ESSB3_PLUGIN_ROOT . 'lib/core/native-buttons/essb-native-buttons-helper.php'; define('ESSB3_NATIVE_ACTIVE', true); $essb_spb = ESSBSocialPrivacyNativeButtons::get_instance(); ESSBNativeButtonsHelper::$essb_spb = $essb_spb; foreach ($essb_spb->resource_files as $key => $object) { $this->resource_builder->add_static_resource($object["file"], $object["key"], $object["type"]); } foreach (ESSBSkinnedNativeButtons::get_assets() as $key => $object) { $this->resource_builder->add_static_resource($object["file"], $object["key"], $object["type"]); } $this->resource_builder->add_css(ESSBSkinnedNativeButtons::generate_skinned_custom_css(), 'essb-skinned-native-buttons'); // asign instance of native buttons privacy class to helper // register active social network apis foreach (ESSBNativeButtonsHelper::get_list_of_social_apis() as $key => $code) { $this->resource_builder->add_social_api($key); } } } else { define('ESSB3_NATIVE_DEACTIVE', true); } } if (!empty($essb_post_native_skin)) { $essb_options['skin_native'] = ESSBOptionValuesHelper::unified_true($essb_post_native_skin); } // change active button positions $modified_global_button_position = false; $new_button_positions_set = array(); foreach ($essb_post_button_position as $position => $active) { if (ESSBOptionValuesHelper::unified_true($active)) { $new_button_positions_set[] = $position; $modified_global_button_position = true; } } foreach ($this->general_options['button_position'] as $settings_position) { if (!isset($essb_post_button_position[$settings_position])) { $new_button_positions_set[] = $settings_position; } } $this->general_options['button_position'] = $new_button_positions_set; /// TODO: register proper display locations after post settings (or unregister not used); if ($modified_global_button_position) { $this->deactivate_stored_filters_and_actions_by_group('button_position'); $this->reactivate_button_position_filters(); } } // non cachable - required for generation of proper ajax requests $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_admin_ajax_access_code(), false, 'essb-head-ajax', 'head'); $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_window_open_code(), true, 'essb-window-code'); if (ESSBOptionValuesHelper::options_bool_value($this->options, 'activate_ga_tracking')) { $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_ga_tracking_code(), true, 'essb-ga-tracking-code'); } if (in_array('print', $this->network_options['networks']) && !ESSBOptionValuesHelper::options_bool_value($this->options, 'print_use_printfriendly')) { $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_window_print_code(), true, 'essb-printing-code'); $this->activated_resources['print'] = 'true'; } // loading aminations $css_animations = ESSBOptionValuesHelper::options_value($this->options, 'css_animations'); if (!empty($essb_post_animations)) { $css_animations = $essb_post_animations; } if ($css_animations != '' && $css_animations != "no") { $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_animation_code($css_animations), 'essb-css-animations'); } $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_counter_style(), 'essb-counter-style'); $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_generate_column_width(), 'essb-column-width-style'); $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_sidebar_options(), 'essb-sidebar-style'); $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_compile_display_locations_code(), 'essb-locations-css'); // activate the fixer for mobiles $mobile_sharebuttonsbar_fix = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_fix'); if ($mobile_sharebuttonsbar_fix) { $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_mobilesharebar_fix_code(), 'essb-mobilesharebar-fix-css'); } $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : ""; $use_minifed_js = $this->general_options['use_minified_js'] ? ".min" : ""; $this->use_minified_css = $use_minifed_css; $this->use_minified_js = $use_minifed_js; // main theme CSS $template_id = $this->design_options['template']; $template_slug = ESSBCoreHelper::template_folder($template_id); if (!empty($essb_post_template)) { $template_slug = $essb_post_template; $this->design_options['template'] = $template_slug; } $this->design_options['template_slug'] = $template_slug; $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($template_url, 'easy-social-share-buttons', 'css'); // counter script if ($this->button_style['show_counter']) { if (!defined('ESSB3_COUNTER_LOADED')) { $script_url = ESSB3_PLUGIN_URL . '/assets/js/easy-social-share-buttons' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'easy-social-share-buttons', 'js'); $this->activated_resources['counters'] = 'true'; define('ESSB3_COUNTER_LOADED', true); } } // float from content top $content_postion = $this->general_options['content_position']; if (!empty($essb_post_content_position)) { $content_postion = $essb_post_content_position; $this->general_options['content_position'] = $content_postion; } if ($content_postion == "content_float" || $content_postion == "content_floatboth") { $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-float' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'essb-float', 'js'); $this->activated_resources['float'] = 'true'; } // mobile CSS load if ($this->is_mobile_safecss() && (in_array('sharebar', $this->general_options['button_position']) || in_array('sharepoint', $this->general_options['button_position']) || in_array('sharebottom', $this->general_options['button_position']))) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-mobile' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-mobile', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-mobile' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'essb-mobile', 'js'); $this->activated_resources['mobile'] = 'true'; } // post vertical float or sidebar if (in_array('sidebar', $this->general_options['button_position']) || in_array('postfloat', $this->general_options['button_position'])) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-sidebar' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-sidebar', 'css'); $this->activated_resources['sidebar'] = 'true'; if (in_array('postfloat', $this->general_options['button_position'])) { $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-postfloat' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'essb-postfloat', 'js'); $this->activated_resources['postfloat'] = 'true'; } /*if ($display_where == "postfloat") { $postfloat_limitfooter = ESSBOptionsHelper::optionsBoolValue($this->options, 'postfloat_limitfooter'); if ($postfloat_limitfooter) { $this->essb_js_builder->include_postfloat_stick_script(); } }*/ } if (in_array('topbar', $this->general_options['button_position']) || in_array('bottombar', $this->general_options['button_position'])) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-topbottom-bar' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-topbottom-bar', 'css'); $this->activated_resources['topbottombar'] = 'true'; //$script_url = ESSB3_PLUGIN_URL .'/assets/js/essb-topbottom-bar'.$use_minifed_js.'.js'; //$this->resource_builder->add_static_resource($script_url, 'essb-topbottom-bar', 'js'); } if (in_array('popup', $this->general_options['button_position'])) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-popup' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-popup', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-popup' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'essb-popup', 'js', true); $this->activated_resources['popup'] = 'true'; } if (in_array('flyin', $this->general_options['button_position'])) { $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-flyin' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-flyin', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-flyin' . $use_minifed_js . '.js'; $this->resource_builder->add_static_resource($script_url, 'essb-flyin', 'js'); $this->activated_resources['flyin'] = 'true'; } $this->general_options['included_mail'] = false; if (in_array('mail', $this->network_options['networks'])) { if ($this->network_options['mail_function'] == "form") { $this->general_options['included_mail'] = true; $style_url = ESSB3_PLUGIN_URL . '/assets/css/essb-mailform' . $use_minifed_css . '.css'; $this->resource_builder->add_static_resource($style_url, 'easy-social-share-buttons-mailform', 'css'); $script_url = ESSB3_PLUGIN_URL . '/assets/js/essb-mailform.js'; $this->resource_builder->add_static_resource($script_url, 'essb-mailform', 'js', true); $this->activated_resources['mail'] = 'true'; } } }