Changeset 26501
- Timestamp:
- 12/01/2013 05:23:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/theme.php
r26352 r26501 142 142 * 143 143 * @since 1.5.0 144 * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name.145 144 * 146 145 * @return string Stylesheet name. 147 146 */ 148 147 function get_stylesheet() { 149 return apply_filters('stylesheet', get_option('stylesheet')); 148 /** 149 * Filter the name of current stylesheet. 150 * 151 * @since 1.5.0 152 * 153 * @param string $stylesheet Name of the current stylesheet. 154 */ 155 return apply_filters( 'stylesheet', get_option( 'stylesheet' ) ); 150 156 } 151 157 … … 154 160 * 155 161 * @since 1.5.0 156 * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name.157 162 * 158 163 * @return string Path to current theme directory. … … 163 168 $stylesheet_dir = "$theme_root/$stylesheet"; 164 169 170 /** 171 * Filter the stylesheet directory path for current theme. 172 * 173 * @since 1.5.0 174 * 175 * @param string $stylesheet_dir Absolute path to the current them. 176 * @param string $stylesheet Directory name of the current theme. 177 * @param string $theme_root Absolute path to themes directory. 178 */ 165 179 return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root ); 166 180 } … … 178 192 $stylesheet_dir_uri = "$theme_root_uri/$stylesheet"; 179 193 194 /** 195 * Filter the stylesheet directory URI. 196 * 197 * @since 1.5.0 198 * 199 * @param string $stylesheet_dir_uri Stylesheet directory URI. 200 * @param string $stylesheet Name of the activated theme's directory. 201 * @param string $theme_root_uri Themes root URI. 202 */ 180 203 return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri ); 181 204 } … … 188 211 * 189 212 * @since 1.5.0 190 * @uses apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.191 213 * 192 214 * @return string … … 195 217 $stylesheet_dir_uri = get_stylesheet_directory_uri(); 196 218 $stylesheet_uri = $stylesheet_dir_uri . '/style.css'; 197 return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); 219 /** 220 * Filter the URI of the current theme stylesheet. 221 * 222 * @since 1.5.0 223 * 224 * @param string $stylesheet_uri Stylesheet URI for the current theme/child theme. 225 * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme. 226 */ 227 return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri ); 198 228 } 199 229 … … 213 243 * 214 244 * @since 2.1.0 215 * @uses apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.216 245 * 217 246 * @return string … … 228 257 else 229 258 $stylesheet_uri = ''; 230 return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); 259 /** 260 * Filter the localized stylesheet URI. 261 * 262 * @since 2.1.0 263 * 264 * @param string $stylesheet_uri Localized stylesheet URI. 265 * @param string $stylesheet_dir_uri Stylesheet directory URI. 266 */ 267 return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri ); 231 268 } 232 269 … … 240 277 */ 241 278 function get_template() { 242 return apply_filters('template', get_option('template')); 279 /** 280 * Filter the name of the current theme. 281 * 282 * @since 1.5.0 283 * 284 * @param string $template Current theme's directory name. 285 */ 286 return apply_filters( 'template', get_option( 'template' ) ); 243 287 } 244 288 … … 247 291 * 248 292 * @since 1.5.0 249 * @uses apply_filters() Calls 'template_directory' filter on template directory path and template name.250 293 * 251 294 * @return string Template directory path. … … 256 299 $template_dir = "$theme_root/$template"; 257 300 301 /** 302 * Filter the current theme directory path. 303 * 304 * @since 1.5.0 305 * 306 * @param string $template_dir The URI of the current theme directory. 307 * @param string $template Directory name of the current theme. 308 * @param string $theme_root Absolute path to the themes directory. 309 */ 258 310 return apply_filters( 'template_directory', $template_dir, $template, $theme_root ); 259 311 } … … 263 315 * 264 316 * @since 1.5.0 265 * @uses apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name.266 317 * 267 318 * @return string Template directory URI. … … 272 323 $template_dir_uri = "$theme_root_uri/$template"; 273 324 325 /** 326 * Filter the current theme directory URI. 327 * 328 * @since 1.5.0 329 * 330 * @param string $template_dir_uri The URI of the current theme directory. 331 * @param string $template Directory name of the current theme. 332 * @param string $theme_root_uri The themes root URI. 333 */ 274 334 return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri ); 275 335 } … … 351 411 } 352 412 413 /** 414 * Filter whether to get the cache of the registered theme directories. 415 * 416 * @since 3.4.0 417 * 418 * @param bool $cache_expiration Whether to get the cache of the theme directories. Default false. 419 * @param string $cache_directory Directory to be searched for the cache. 420 */ 353 421 if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) { 354 422 $cached_roots = get_site_transient( 'theme_roots' ); … … 442 510 * 443 511 * @since 1.5.0 444 * @uses apply_filters() Calls 'theme_root' filter on path.445 512 * 446 513 * @param string $stylesheet_or_template The stylesheet or template name of the theme … … 459 526 } 460 527 528 /** 529 * Filter the absolute path to the themes directory. 530 * 531 * @since 1.5.0 532 * 533 * @param string $theme_root Absolute path to themes directory. 534 */ 461 535 return apply_filters( 'theme_root', $theme_root ); 462 536 } … … 499 573 } 500 574 501 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template ); 575 /** 576 * Filter the URI for themes directory. 577 * 578 * @since 1.5.0 579 * 580 * @param string $theme_root_uri The URI for themes directory. 581 * @param string $siteurl WordPress web address which is set in General Options. 582 * @param string $stylesheet_or_template Stylesheet or template name of the theme. 583 */ 584 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option( 'siteurl' ), $stylesheet_or_template ); 502 585 } 503 586 … … 666 749 * 667 750 * @since 2.5.0 668 * @uses do_action() Calls 'switch_theme' action, passing the new theme.669 751 * 670 752 * @param string $stylesheet Stylesheet name … … 707 789 708 790 update_option( 'theme_switched', $old_theme->get_stylesheet() ); 791 /** 792 * Fires after the theme is switched. 793 * 794 * @since 1.5.0 795 * 796 * @param string $new_name Name of the new theme. 797 * @param WP_Theme $new_theme WP_Theme instance of the new theme. 798 */ 709 799 do_action( 'switch_theme', $new_name, $new_theme ); 710 800 } … … 724 814 */ 725 815 function validate_current_theme() { 726 // Don't validate during an install/upgrade. 727 if ( defined('WP_INSTALLING') || !apply_filters( 'validate_current_theme', true ) ) 816 /** 817 * Filter whether to validate the current theme. 818 * 819 * @since 2.7.0 820 * 821 * @param bool true Validation flag to check the current theme. 822 */ 823 if ( defined('WP_INSTALLING') || ! apply_filters( 'validate_current_theme', true ) ) 728 824 return true; 729 825 … … 777 873 * 778 874 * @since 2.1.0 779 * @uses apply_filters() Calls 'theme_mod_$name' filter on the value.780 875 * 781 876 * @param string $name Theme modification name. … … 786 881 $mods = get_theme_mods(); 787 882 788 if ( isset( $mods[ $name ] ) ) 789 return apply_filters( "theme_mod_$name", $mods[ $name ] ); 883 if ( isset( $mods[$name] ) ) { 884 /** 885 * Filter the theme modification, or 'theme_mod', value. 886 * 887 * The dynamic portion of the hook name, $name, refers to 888 * the key name of the modification array. For example, 889 * 'header_textcolor', 'header_image', and so on depending 890 * on the theme options. 891 * 892 * @since 2.2.0 893 * 894 * @param string $current_mod The value of the current theme modification. 895 */ 896 return apply_filters( "theme_mod_{$name}", $mods[$name] ); 897 } 790 898 791 899 if ( is_string( $default ) ) 792 900 $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); 793 901 794 return apply_filters( "theme_mod_$name", $default ); 902 /** This filter is documented in wp-includes/theme.php */ 903 return apply_filters( "theme_mod_{$name}", $default ); 795 904 } 796 905 … … 1594 1703 } 1595 1704 1596 return apply_filters('current_theme_supports-' . $feature, true, $args, $_wp_theme_features[$feature]); 1705 /** 1706 * Filter whether the current theme supports a specific feature. 1707 * 1708 * The dynamic portion of the hook name, $feature, refers to 1709 * the specific theme feature. Possible values include 'post-formats', 1710 * 'post-thumbnails', 'custom-background', 'custom-header', 'menus', 1711 * 'automatic-feed-links', and 'html5'. 1712 * 1713 * @since 3.4.0 1714 * 1715 * @param bool true Whether the current theme supports the given feature. Default true. 1716 * @param array $args Array of arguments for the feature. 1717 * @param string $feature The theme feature. 1718 */ 1719 return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); 1597 1720 } 1598 1721 … … 1642 1765 $old_theme = wp_get_theme( $stylesheet ); 1643 1766 1644 if ( $old_theme->exists() ) 1645 do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme ); 1646 else 1767 if ( $old_theme->exists() ) { 1768 /** 1769 * Fires on the first WP load after a theme switch if the old theme still exists. 1770 * 1771 * This action fires multiple times and the parameters differs 1772 * according to the context, if the old theme exists or not. 1773 * If the old theme is missing, the parameter will be the slug 1774 * of the old theme. 1775 * 1776 * @since 3.3.0 1777 * 1778 * @param string $old_name Old theme name. 1779 * @param WP_Theme $old_theme WP_Theme instance of the old theme. 1780 */ 1781 do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme ); 1782 } else { 1783 /** This action is documented in wp-includes/theme.php */ 1647 1784 do_action( 'after_switch_theme', $stylesheet ); 1785 } 1648 1786 1649 1787 update_option( 'theme_switched', false );
Note: See TracChangeset
for help on using the changeset viewer.