Ticket #30797: 30797.diff
File 30797.diff, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/theme.php
209 209 } 210 210 211 211 /** 212 * Retrieve URI ofcurrent theme stylesheet.212 * Retrieves the URI of the current theme stylesheet. 213 213 * 214 * The stylesheet file name is 'style.css' which is appended to {@link 215 * get_stylesheet_directory_uri() stylesheet directory URI} path. 214 * If `$type` is 'child' (default), 'style.css' is appended to the get_stylesheet_directory_uri() 215 * path. If 'parent', it is appended to get_template_directory_uri(). If the parent theme doesn't 216 * exist, it falls back to the current theme (the same as if the default 'child' value were chosen). 216 217 * 217 218 * @since 1.5.0 219 * @since 4.4.0 Introduced the optional `$type` parameter. 218 220 * 219 * @return string 221 * @param string $type Optional. Type of stylesheet to retrieve. Accepts 'child' or 'parent'. 222 * Default 'child'. 223 * @return string If `$type` is 'parent' and a parent theme exists, the parent theme stylesheet URI. 224 * In all other cases, the current theme stylesheet URI will be returned. 220 225 */ 221 function get_stylesheet_uri( ) {226 function get_stylesheet_uri( $type = 'child' ) { 222 227 $stylesheet_dir_uri = get_stylesheet_directory_uri(); 228 229 // Normalize on two choices for the benefit of the 'stylesheet_uri' filter. 230 if ( ! in_array( $type, array( 'child', 'parent' ) ) ) { 231 $type = 'child'; 232 } 233 234 if ( 'parent' === $type ) { 235 $stylesheet_dir_uri = get_template_directory_uri(); 236 } 237 223 238 $stylesheet_uri = $stylesheet_dir_uri . '/style.css'; 239 224 240 /** 225 241 * Filter the URI of the current theme stylesheet. 226 242 * 227 243 * @since 1.5.0 244 * @since 4.4.0 Added the `$type` parameter. 228 245 * 229 246 * @param string $stylesheet_uri Stylesheet URI for the current theme/child theme. 230 247 * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme. 248 * @param string $type Type of stylesheet URI being retrieved. Can be either 'child' 249 * or 'parent'. Default 'child'. 231 250 */ 232 return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );251 return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri, $type ); 233 252 } 234 253 235 254 /**