public function add_style_load_url($urls)
 {
     $hub = Upfront_PublicStylesheets_Registry::get_instance();
     $styles = $hub->get_all();
     if (empty($styles)) {
         return $urls;
     }
     $ckey = $this->_cache->key(self::TYPE_STYLE, $styles);
     $raw_cache_key = $ckey->get_hash();
     $cache = $this->_debugger->is_active() ? false : $this->_cache->get($ckey);
     if (empty($cache)) {
         foreach ($styles as $key => $frags) {
             //$path = upfront_element_dir($frags[0], $frags[1]);
             //if (file_exists($path)) $cache .= "/* {$key} */\n" . file_get_contents($path) . "\n";
             if (empty($frags)) {
                 continue;
             }
             $style = $this->_get_style_contents($frags);
             if (!empty($style)) {
                 $cache .= "/* {$key} */\n{$style}\n";
             }
         }
         if (!$this->_debugger->is_active(Upfront_Debug::STYLE)) {
             $cache = Upfront_StylePreprocessor::compress($cache);
         }
         $this->_cache->set($ckey, $cache);
     }
     $url = Upfront_VirtualPage::get_url(join('/', array('upfront-dependencies', 'styles', $raw_cache_key)));
     $urls[] = $url;
     return $urls;
 }
Exemplo n.º 2
0
 public static function get_instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 3
0
/**
 * Adds element style resource.
 * @param string $slug Stylesheet ID to be keyed under (hopefully unique)
 * @param array $path_info Two-member array, describing resource location. The members are like arguments for upfront_element_dir/upfront_element_url
 * @return bool False on failure/invalid arguments, true on success
 */
function upfront_add_element_style($slug, $path_info)
{
    if (empty($slug) || empty($path_info)) {
        return false;
    }
    if (!is_array($path_info)) {
        return false;
    }
    if (count($path_info) != 2) {
        return false;
    }
    if (current_theme_supports($slug)) {
        return true;
    }
    // Current theme supports this style
    if (empty($_GET['dev']) && empty($_GET['debug'])) {
        // Yeah, so re-intorduce the hacks
        $hub = Upfront_PublicStylesheets_Registry::get_instance();
        return $hub->set($slug, $path_info);
    } else {
        wp_enqueue_style($slug, upfront_element_url($path_info[0], $path_info[1]));
    }
}