function _filter_scripts()
 {
     $store =& $this->stores['scripts'];
     // get deps
     $deps_global = array();
     $deps_plugin = array();
     foreach ($store as $script) {
         extract($script);
         $pieces = explode('.', $file);
         $len = count($pieces);
         // library handle
         if ($len >= 2 and !in_array($pieces[0], $deps_global)) {
             $deps_global[] = $pieces[0];
         }
         // plugin handle
         if ($len >= 3 and !in_array($pieces[1], $deps_plugin) and !WPHF::has_segment('widgets', $url)) {
             $deps_plugin[] = $file;
         }
     }
     foreach ($store as &$script) {
         extract($script);
         $pieces = explode('.', basename($file));
         $len = count($pieces);
         if ($len >= 2) {
             $script['deps'] = array_merge($script['deps'], $deps_global);
         }
         if ($len < 3) {
             $script['deps'] = array_merge($script['deps'], $deps_plugin);
         }
     }
     // add ie substore
     $store_new = array('normal' => array(), 'ie' => array());
     foreach ($store as &$script) {
         extract($script);
         $vars = array_keys($script);
         $store_sub = 'normal';
         $is_ie_script = ($matches = $this->is_ie_script($url) and $matches !== FALSE);
         if ($is_ie_script) {
             list(, $ie_op, $ie_ver, $ie_plugin) = $matches;
             if ($ie_plugin == 'png') {
                 $ie_op = 'lte';
                 $ie_ver = 6;
             }
             $vars = array_merge($vars, array('ie_op', 'ie_ver'));
             $store_sub = 'ie';
             // make tag
             $vars[] = 'tag';
             $tag = WPOT::tag('script', '', array('src' => $url . '?ver=' . $ver, 'type' => 'text/javascript', 'charset' => 'UTF-8')) . PHP_EOL;
         }
         $store_new[$store_sub][] = compact($vars);
     }
     $store = $store_new;
 }
Example #2
0
 function check_script($file, $url, $deps, $ver)
 {
     if (WPHF::has_segment('widgets', $url)) {
         wp_deregister_script(basename($file, '.js'));
     }
 }