Plugin Directory

Changeset 343747


Ignore:
Timestamp:
02/10/2011 06:26:55 PM (15 years ago)
Author:
jasontremblay
Message:
  • Added static keyword to static functions
  • Support for configurable asset host
  • Remove global $is_IE dependency
  • Using conditional tags for IE styles
File:
1 edited

Legend:

Unmodified
Added
Removed
  • template-provisioning/trunk/template-provisioning.php

    r273732 r343747  
    3232{
    3333    static $template_basename;
    34    
    35     function initialize()
     34    static $asset_host;
     35   
     36    static function initialize()
    3637    {
    3738      // WE ONLY WANT THIS ON THE FRONT-END, NOT ADMIN
     
    4243        Template_Provisioning::$template_basename = 'index';
    4344       
     45        // INITIALIZE ASSET HOST
     46        Template_Provisioning::$asset_host = get_bloginfo('template_directory');
     47       
    4448        // DELAY TILL PLUGINS LOADED TO BE REASONABLY SURE FILTER IS ADDED LAST,
    4549        // TAKING ADVANTAGE OF OTHER COOL TEMPLATE PLUGINS LIKE post-templates-by-cat.php
     
    5660    }
    5761   
    58     function add_template_filters()
     62    static function set_asset_host($host)
     63    {
     64        Template_Provisioning::$asset_host = $host;
     65    }
     66   
     67    static function add_template_filters()
    5968    {
    6069       
     
    8998    // WHEN WORDPRESS DECIDES WHICH TEMPLATE TO USE, AND FILTERS THE PATH,
    9099    // STORE THAT PATH IN AN INSTANCE VARIABLE FOR LATER USE
    91     function store_template_filename($template_filepath = '')
     100    static function store_template_filename($template_filepath = '')
    92101    {
    93102        if ('' != $template_filepath) {
     
    97106    }
    98107   
    99     function filter_style_link_tags_for_less_js($tag, $handle)
     108    static function filter_style_link_tags_for_less_js($tag, $handle)
    100109    {
    101110    global $wp_styles;
     
    109118    }
    110119   
    111     function helpful_comment()
     120    static function helpful_comment()
    112121    {
    113122        $template_basename = Template_Provisioning::$template_basename;
     
    119128    }
    120129   
    121     function enqueue_css()
    122     {
    123         global $is_IE;
     130    static function enqueue_css()
     131    {
     132        global $wp_styles;
    124133       
    125134        $extensions = array('css','less');
     
    127136        $stylesheets = array();
    128137        $stylesheets[] = 'global';
    129         if ($is_IE) $stylesheets[] = 'ie/global';
     138        $stylesheets[] = 'ie/global';
    130139        $stylesheets[] = Template_Provisioning::$template_basename;
    131         if ($is_IE) $stylesheets[] = 'ie/'.Template_Provisioning::$template_basename;
     140        $stylesheets[] = 'ie/'.Template_Provisioning::$template_basename;
    132141       
    133142        foreach($stylesheets as $stylesheet) {
    134143          foreach($extensions as $extension) {
    135           $file_path = TEMPLATEPATH.'/css/'.$stylesheet.'.'.$extension;
     144       
     145        // asset file name
     146        $file_name = $stylesheet.'.'.$extension;
     147          $file_path = TEMPLATEPATH.'/css/'.$file_name;
     148         
    136149            if (file_exists($file_path)) {
    137150         
     
    143156
    144157                // prevent loading of admin styles
    145                 wp_deregister_style($stylesheet.'.'.$extension);
    146 
     158                wp_deregister_style($file_name);
     159         
    147160                wp_enqueue_style(
    148                     $handle = $stylesheet.'.'.$extension,
    149                     $src = get_bloginfo('template_directory').'/css/'.$stylesheet.'.'.$extension,
     161                    $handle = $file_name,
     162                    $src = Template_Provisioning::$asset_host.'/css/'.$file_name,
    150163                    $dependencies = $dependencies,
    151164                    $version = filemtime($file_path),
    152165                    $media = false
    153166                );
     167               
     168          // ie conditional
     169          if (preg_match('/^ie\//', $stylesheet)) {
     170            $wp_styles->add_data($file_name, 'conditional', 'ie');
     171          }
    154172            }
    155173          }
     
    157175    }
    158176   
    159     function enqueue_js($scripts = '')
     177    static function enqueue_js($scripts = '')
    160178    {
    161179      // if string passed in, explode to array
     
    186204                wp_enqueue_script(
    187205                    $handle = $script,
    188                     $src = get_bloginfo('template_directory').'/js/'.$script.'.js',
     206                    $src = Template_Provisioning::$asset_host.'/js/'.$script.'.js',
    189207                    $dependencies = $dependencies,
    190208                    $version = filemtime($file_path),
     
    195213    }
    196214   
    197     function get_dependencies($file_path)
     215    static function get_dependencies($file_path)
    198216    {
    199217        $dependencies = array();
     
    208226    }
    209227   
    210     function is_dependency($line)
     228    static function is_dependency($line)
    211229    {
    212230        // return true if line begins with // NEEDS:
Note: See TracChangeset for help on using the changeset viewer.