Ticket #25588: 25588-2.diff
File 25588-2.diff, 9.5 KB (added by , 10 years ago) |
---|
-
src/wp-includes/theme.php
146 146 * @return string Stylesheet name. 147 147 */ 148 148 function get_stylesheet() { 149 return apply_filters('stylesheet', get_option('stylesheet')); 149 $stylesheet = get_option( 'stylesheet' ); 150 /** 151 * Filter the name of current stylesheet. 152 * 153 * @since 1.5.0 154 * 155 * @param string $stylesheet Name of the current stylesheet. 156 */ 157 return apply_filters( 'stylesheet', $stylesheet ); 150 158 } 151 159 152 160 /** … … 162 170 $theme_root = get_theme_root( $stylesheet ); 163 171 $stylesheet_dir = "$theme_root/$stylesheet"; 164 172 173 /** 174 * Filter stylesheet directory path for current theme. 175 * 176 * @since 1.5.0 177 * 178 * @param type $stylesheet_dir Absolute path to the current them. 179 * @param type $stylesheet Directory name of the current theme. 180 * @param type $theme_root Absolute path to themes directory. 181 */ 165 182 return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root ); 166 183 } 167 184 … … 177 194 $theme_root_uri = get_theme_root_uri( $stylesheet ); 178 195 $stylesheet_dir_uri = "$theme_root_uri/$stylesheet"; 179 196 197 /** 198 * Filter stylesheet directory URI. 199 * 200 * @since 1.5.0 201 * 202 * @param string $stylesheet_dir_uri Stylesheet directory URI. 203 * @param string $stylesheet Name of the activated theme's directory. 204 * @param string $theme_root_uri Themes uri. http://example.com/wp-content/themes. 205 */ 180 206 return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri ); 181 207 } 182 208 … … 194 220 function get_stylesheet_uri() { 195 221 $stylesheet_dir_uri = get_stylesheet_directory_uri(); 196 222 $stylesheet_uri = $stylesheet_dir_uri . '/style.css'; 197 return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); 223 /** 224 * Filter URI of current theme stylesheet. 225 * 226 * @since 1.5.0 227 * 228 * @param type $stylesheet_uri Stylesheet URI for the current theme/child theme. 229 * @param type $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme. 230 */ 231 return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri ); 198 232 } 199 233 200 234 /** … … 227 261 $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css"; 228 262 else 229 263 $stylesheet_uri = ''; 230 return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); 264 /** 265 * Filter localized stylesheet URI. 266 * 267 * @since 2.1.0 268 * 269 * @param type $stylesheet_uri Localized stylesheet URI. 270 * @param type $stylesheet_dir_uri Stylesheet directory URI. 271 */ 272 return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri ); 231 273 } 232 274 233 275 /** … … 239 281 * @return string Template name. 240 282 */ 241 283 function get_template() { 242 return apply_filters('template', get_option('template')); 284 $template = get_option( 'template' ); 285 /** 286 * Short description. (use period) 287 * 288 * @since 1.5.0 289 * 290 * @param type $template Current theme's directory name. 291 */ 292 return apply_filters( 'template', $template ); 243 293 } 244 294 245 295 /** … … 255 305 $theme_root = get_theme_root( $template ); 256 306 $template_dir = "$theme_root/$template"; 257 307 308 /** 309 * Filter the current theme directory path. 310 * 311 * @since 1.5.0 312 * 313 * @param string $template_dir The URI of the current theme directory. 314 * @param string $template Directory name of the current theme. 315 * @param string $theme_root Absolute path to the themes directory. 316 */ 258 317 return apply_filters( 'template_directory', $template_dir, $template, $theme_root ); 259 318 } 260 319 … … 271 330 $theme_root_uri = get_theme_root_uri( $template ); 272 331 $template_dir_uri = "$theme_root_uri/$template"; 273 332 333 /** 334 * Filter the current theme directory URI. 335 * 336 * $theme_root_uri is for example, http://example.com/wp-content/themes 337 * and is connected with the name of the current theme name into $template_dir_uri. 338 * 339 * @since 1.5.0 340 * 341 * @param string $template_dir_uri The URI of the current theme directory. 342 * @param string $template Directory name of the current theme. 343 * @param string $theme_root_uri The themes uri. 344 */ 274 345 return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri ); 275 346 } 276 347 … … 350 421 $relative_theme_roots[ $theme_root ] = $theme_root; 351 422 } 352 423 353 if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) { 424 $cache_expiration = false; 425 $cache_place = 'search_theme_directories'; 426 /** 427 * Filter whether to get the cache of the registered theme directories. 428 * 429 * @since 3.4.0 430 * 431 * @param bool $cache_expiration Boolean whether to get the cache of the theme directories. Defaults to false. 432 * @param string $cache_place Directory to be searched for the cache. 433 */ 434 if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', $cache_expiration, $cache_place ) ) { 354 435 $cached_roots = get_site_transient( 'theme_roots' ); 355 436 if ( is_array( $cached_roots ) ) { 356 437 foreach ( $cached_roots as $theme_dir => $theme_root ) { … … 458 539 $theme_root = WP_CONTENT_DIR . '/themes'; 459 540 } 460 541 542 /** 543 * Filter the absolute path to themes directory. 544 * 545 * @since 1.5.0 546 * 547 * @param string $theme_root Absolute path to themes directory. 548 */ 461 549 return apply_filters( 'theme_root', $theme_root ); 462 550 } 463 551 … … 498 586 $theme_root_uri = content_url( 'themes' ); 499 587 } 500 588 501 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template ); 589 $siteurl = get_option( 'siteurl' ); 590 /** 591 * Filter the URI for themes directory. 592 * 593 * @since 1.5.0 594 * 595 * @param type $theme_root_uri The URI for themes directory. 596 * @param type $siteurl WordPress web address which is set in General Options. 597 * @param type $stylesheet_or_template Stylesheet or template name of the theme. 598 */ 599 return apply_filters( 'theme_root_uri', $theme_root_uri, $siteurl, $stylesheet_or_template ); 502 600 } 503 601 504 602 /** … … 706 804 } 707 805 708 806 update_option( 'theme_switched', $old_theme->get_stylesheet() ); 807 /** 808 * Fires after the theme switch. 809 * 810 * @since 1.5.0 811 * 812 * @param string $new_name Name of the new theme. 813 * @param object $new_theme The instance of the WP_Theme object of the new theme. 814 */ 709 815 do_action( 'switch_theme', $new_name, $new_theme ); 710 816 } 711 817 … … 723 829 * @return bool 724 830 */ 725 831 function validate_current_theme() { 726 // Don't validate during an install/upgrade. 832 /** 833 * Filter whether to validate the current theme. 834 * 835 * @since 2.7.0 836 * 837 * @param bool true Validation flag to check the current theme. 838 */ 727 839 if ( defined('WP_INSTALLING') || !apply_filters( 'validate_current_theme', true ) ) 728 840 return true; 729 841 … … 785 897 function get_theme_mod( $name, $default = false ) { 786 898 $mods = get_theme_mods(); 787 899 788 if ( isset( $mods[ $name ] ) ) 789 return apply_filters( "theme_mod_$name", $mods[ $name ] ); 900 if ( isset( $mods[ $name ] ) ) { 901 $current_mod = $mods[ $name ]; 902 /** 903 * Filter the theme modification value. 904 * 905 * The $name is the key name of the modification array. 906 * Ex: 'header_textcolor', 'header_image' and so on depending 907 * on the themes. You can specify which theme modification 908 * value to filter by using this key. 909 * 910 * @since 2.2.0 911 * 912 * @param string $current_mod The value of the modification. 913 */ 914 return apply_filters( "theme_mod_$name", $current_mod ); 915 } 790 916 791 917 if ( is_string( $default ) ) 792 918 $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); 793 919 920 /** This filter is documented in wp-includes/theme.php */ 794 921 return apply_filters( "theme_mod_$name", $default ); 795 922 } 796 923 … … 1590 1717 break; 1591 1718 } 1592 1719 1593 return apply_filters('current_theme_supports-' . $feature, true, $args, $_wp_theme_features[$feature]); 1720 /** 1721 * Filter whether the theme supports a specific feature. 1722 * 1723 * $feature variable is the name of feature themes can support 1724 * such as 'post-thumbnails', 'custom-header' and so on. 1725 * You can specify which feature to filter. 1726 * 1727 * @since 3.4.0 1728 * 1729 * @param bool true Boolean if current theme supports the given feature. Defaults to true. 1730 * @param bool $args Feature's option. 1731 * @param bool $_wp_theme_features[$feature] Array of the features' parameters 1732 */ 1733 return apply_filters( 'current_theme_supports-' . $feature, true, $args, $_wp_theme_features[$feature] ); 1594 1734 } 1595 1735 1596 1736 /** … … 1638 1778 if ( $stylesheet = get_option( 'theme_switched' ) ) { 1639 1779 $old_theme = wp_get_theme( $stylesheet ); 1640 1780 1641 if ( $old_theme->exists() ) 1642 do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme ); 1643 else 1781 if ( $old_theme->exists() ) { 1782 $old_name = $old_theme->get('Name'); 1783 /** 1784 * Fires on the first WP load after a theme switch. 1785 * 1786 * This action fires multiple times and the parameters differs 1787 * according to the context, if the old theme exists or not. 1788 * If the old theme is missing, the parameter will be the slug 1789 * of the old theme. 1790 * 1791 * @since 3.3.0 1792 * 1793 * @param string $old_name Old theme name. 1794 * @param string $old_theme Old theme name. 1795 */ 1796 do_action( 'after_switch_theme', $old_name, $old_theme ); 1797 } else { 1798 /** This action is documented in wp-includes/theme.php */ 1644 1799 do_action( 'after_switch_theme', $stylesheet ); 1800 } 1645 1801 1646 1802 update_option( 'theme_switched', false ); 1647 1803 }