Exemplo n.º 1
0
 /**
  * 
  * a must function. you can not use it, but the function must stay there!
  */
 public static function onAddScripts()
 {
     global $wp_version;
     $slver = apply_filters('revslider_remove_version', RevSliderGlobals::SLIDER_REVISION);
     $style_pre = '';
     $style_post = '';
     if ($wp_version < 3.7) {
         $style_pre = '<style type="text/css">';
         $style_post = '</style>';
     }
     $operations = new RevSliderOperations();
     $arrValues = $operations->getGeneralSettingsValues();
     $includesGlobally = RevSliderFunctions::getVal($arrValues, "includes_globally", "on");
     $includesFooter = RevSliderFunctions::getVal($arrValues, "js_to_footer", "off");
     $strPutIn = RevSliderFunctions::getVal($arrValues, "pages_for_includes");
     $isPutIn = RevSliderOutput::isPutIn($strPutIn, true);
     //put the includes only on pages with active widget or shortcode
     // if the put in match, then include them always (ignore this if)
     if ($isPutIn == false && $includesGlobally == "off") {
         $isWidgetActive = is_active_widget(false, false, "rev-slider-widget", true);
         $hasShortcode = RevSliderFunctionsWP::hasShortcode("rev_slider");
         if ($isWidgetActive == false && $hasShortcode == false) {
             return false;
         }
     }
     wp_enqueue_style('rs-plugin-settings', RS_PLUGIN_URL . 'public/assets/css/settings.css', array(), $slver);
     $custom_css = RevSliderOperations::getStaticCss();
     $custom_css = RevSliderCssParser::compress_css($custom_css);
     if (trim($custom_css) == '') {
         $custom_css = '#rs-demo-id {}';
     }
     wp_add_inline_style('rs-plugin-settings', $style_pre . $custom_css . $style_post);
     $setBase = is_ssl() ? "https://" : "http://";
     wp_enqueue_script(array('jquery'));
     //add icon sets
     //wp_register_style('rs-icon-set-fa-icon-', RS_PLUGIN_URL .'public/assets/fonts/font-awesome/css/font-awesome.css', array(), $slver);
     //wp_register_style('rs-icon-set-pe-7s-', RS_PLUGIN_URL .'public/assets/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css', array(), $slver);
     if ($includesFooter == "off") {
         $waitfor = array('jquery');
         $enable_logs = RevSliderFunctions::getVal($arrValues, "enable_logs", 'off');
         if ($enable_logs == 'on') {
             wp_enqueue_script('enable-logs', RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.enablelog.js', $waitfor, $slver);
             $waitfor[] = 'enable-logs';
         }
         wp_enqueue_script('tp-tools', RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.tools.min.js', $waitfor, $slver);
         wp_enqueue_script('revmin', RS_PLUGIN_URL . 'public/assets/js/jquery.themepunch.revolution.min.js', 'tp-tools', $slver);
     } else {
         //put javascript to footer
         add_action('wp_footer', array('RevSliderFront', 'putJavascript'));
     }
     add_action('wp_head', array('RevSliderFront', 'add_meta_generator'));
     add_action("wp_footer", array('RevSliderFront', "load_icon_fonts"));
     // Async JS Loading
     $js_defer = RevSliderBase::getVar($arrValues, 'js_defer', 'off');
     if ($js_defer != 'off') {
         add_filter('clean_url', array('RevSliderFront', 'add_defer_forscript'), 11, 1);
     }
     add_action('wp_before_admin_bar_render', array('RevSliderFront', 'add_admin_menu_nodes'));
     add_action('wp_footer', array('RevSliderFront', 'putAdminBarMenus'));
 }