Changeset 343747
- Timestamp:
- 02/10/2011 06:26:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
template-provisioning/trunk/template-provisioning.php
r273732 r343747 32 32 { 33 33 static $template_basename; 34 35 function initialize() 34 static $asset_host; 35 36 static function initialize() 36 37 { 37 38 // WE ONLY WANT THIS ON THE FRONT-END, NOT ADMIN … … 42 43 Template_Provisioning::$template_basename = 'index'; 43 44 45 // INITIALIZE ASSET HOST 46 Template_Provisioning::$asset_host = get_bloginfo('template_directory'); 47 44 48 // DELAY TILL PLUGINS LOADED TO BE REASONABLY SURE FILTER IS ADDED LAST, 45 49 // TAKING ADVANTAGE OF OTHER COOL TEMPLATE PLUGINS LIKE post-templates-by-cat.php … … 56 60 } 57 61 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() 59 68 { 60 69 … … 89 98 // WHEN WORDPRESS DECIDES WHICH TEMPLATE TO USE, AND FILTERS THE PATH, 90 99 // 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 = '') 92 101 { 93 102 if ('' != $template_filepath) { … … 97 106 } 98 107 99 function filter_style_link_tags_for_less_js($tag, $handle)108 static function filter_style_link_tags_for_less_js($tag, $handle) 100 109 { 101 110 global $wp_styles; … … 109 118 } 110 119 111 function helpful_comment()120 static function helpful_comment() 112 121 { 113 122 $template_basename = Template_Provisioning::$template_basename; … … 119 128 } 120 129 121 function enqueue_css()122 { 123 global $ is_IE;130 static function enqueue_css() 131 { 132 global $wp_styles; 124 133 125 134 $extensions = array('css','less'); … … 127 136 $stylesheets = array(); 128 137 $stylesheets[] = 'global'; 129 if ($is_IE)$stylesheets[] = 'ie/global';138 $stylesheets[] = 'ie/global'; 130 139 $stylesheets[] = Template_Provisioning::$template_basename; 131 if ($is_IE)$stylesheets[] = 'ie/'.Template_Provisioning::$template_basename;140 $stylesheets[] = 'ie/'.Template_Provisioning::$template_basename; 132 141 133 142 foreach($stylesheets as $stylesheet) { 134 143 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 136 149 if (file_exists($file_path)) { 137 150 … … 143 156 144 157 // prevent loading of admin styles 145 wp_deregister_style($ stylesheet.'.'.$extension);146 158 wp_deregister_style($file_name); 159 147 160 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, 150 163 $dependencies = $dependencies, 151 164 $version = filemtime($file_path), 152 165 $media = false 153 166 ); 167 168 // ie conditional 169 if (preg_match('/^ie\//', $stylesheet)) { 170 $wp_styles->add_data($file_name, 'conditional', 'ie'); 171 } 154 172 } 155 173 } … … 157 175 } 158 176 159 function enqueue_js($scripts = '')177 static function enqueue_js($scripts = '') 160 178 { 161 179 // if string passed in, explode to array … … 186 204 wp_enqueue_script( 187 205 $handle = $script, 188 $src = get_bloginfo('template_directory').'/js/'.$script.'.js',206 $src = Template_Provisioning::$asset_host.'/js/'.$script.'.js', 189 207 $dependencies = $dependencies, 190 208 $version = filemtime($file_path), … … 195 213 } 196 214 197 function get_dependencies($file_path)215 static function get_dependencies($file_path) 198 216 { 199 217 $dependencies = array(); … … 208 226 } 209 227 210 function is_dependency($line)228 static function is_dependency($line) 211 229 { 212 230 // return true if line begins with // NEEDS:
Note: See TracChangeset
for help on using the changeset viewer.