Changeset 35738
- Timestamp:
- 11/25/2015 09:44:02 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r35688 r35738 369 369 } 370 370 371 $template = WP_DEFAULT_THEME; 372 // If default theme is a child theme, we need to get its template 373 $theme = wp_get_theme( $template ); 374 if ( ! $theme->errors() ) 375 $template = $theme->get_template(); 371 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. 372 $stylesheet = $template = WP_DEFAULT_THEME; 373 $theme = wp_get_theme( WP_DEFAULT_THEME ); 374 if ( ! $theme->exists() ) { 375 $theme = WP_Theme::get_core_default_theme(); 376 } 377 378 // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. 379 if ( $theme ) { 380 $stylesheet = $theme->get_stylesheet(); 381 $template = $theme->get_template(); 382 } 376 383 377 384 $timezone_string = ''; … … 434 441 'recently_edited' => '', 435 442 'template' => $template, 436 'stylesheet' => WP_DEFAULT_THEME,443 'stylesheet' => $stylesheet, 437 444 'comment_whitelist' => 1, 438 445 'blacklist_keys' => '', … … 915 922 $stylesheet = get_option( 'stylesheet' ); 916 923 $allowed_themes = array( $stylesheet => true ); 917 if ( $template != $stylesheet ) 924 925 if ( $template != $stylesheet ) { 918 926 $allowed_themes[ $template ] = true; 919 if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) 927 } 928 929 if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { 920 930 $allowed_themes[ WP_DEFAULT_THEME ] = true; 931 } 932 933 // If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme. 934 if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) { 935 if ( $core_default = WP_Theme::get_core_default_theme() ) { 936 $allowed_themes[ $core_default->get_stylesheet() ] = true; 937 } 938 } 921 939 922 940 if ( 1 == $network_id ) { -
trunk/src/wp-admin/includes/update-core.php
r35718 r35738 716 716 * 717 717 * @since 3.2.0 718 * @since 4.4.0 New themes are not automatically installed on upgrade. 719 * This can still be explicitly asked for by defining 720 * CORE_UPGRADE_SKIP_NEW_BUNDLED as false. 718 721 * @global array $_new_bundled_files 719 722 * @var array … … 732 735 'themes/twentysixteen/' => '4.4', 733 736 ); 737 738 // If not explicitly defined as false, don't install new default themes. 739 if ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || CORE_UPGRADE_SKIP_NEW_BUNDLED ) { 740 $_new_bundled_files = array( 'plugins/akismet/' => '2.0' ); 741 } 734 742 735 743 /** -
trunk/src/wp-includes/class-wp-theme.php
r34995 r35738 57 57 'twentyfourteen' => 'Twenty Fourteen', 58 58 'twentyfifteen' => 'Twenty Fifteen', 59 'twentysixteen' => 'Twenty Sixteen', 59 60 ); 60 61 … … 1152 1153 1153 1154 /** 1155 * Determines the latest WordPress default theme that is installed. 1156 * 1157 * This hits the filesystem. 1158 * 1159 * @return WP_Theme|false Object, or false if no theme is installed, which would be bad. 1160 */ 1161 public static function get_core_default_theme() { 1162 foreach ( array_reverse( self::$default_themes ) as $slug => $name ) { 1163 $theme = wp_get_theme( $slug ); 1164 if ( $theme->exists() ) { 1165 return $theme; 1166 } 1167 } 1168 return false; 1169 } 1170 1171 /** 1154 1172 * Returns array of stylesheet names of themes allowed on the site or network. 1155 1173 * -
trunk/src/wp-includes/default-constants.php
r35290 r35738 349 349 * Slug of the default theme for this install. 350 350 * Used as the default theme when installing new sites. 351 * Will be used as the fallback if the current theme doesn't exist. 351 * It will be used as the fallback if the current theme doesn't exist. 352 * 352 353 * @since 3.0.0 354 * @see WP_Theme::get_core_default_theme() 353 355 */ 354 356 if ( !defined('WP_DEFAULT_THEME') ) -
trunk/src/wp-includes/theme.php
r35595 r35738 754 754 * Checks that current theme files 'index.php' and 'style.css' exists. 755 755 * 756 * Does not check the default theme, which is the fallback and should always exist. 756 * Does not initially check the default theme, which is the fallback and should always exist. 757 * But if it doesn't exist, it'll fall back to the latest core default theme that does exist. 757 758 * Will switch theme to the fallback theme if current theme does not validate. 759 * 758 760 * You can use the 'validate_current_theme' filter to return false to 759 761 * disable this functionality. … … 775 777 return true; 776 778 777 if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) { 779 if ( ! file_exists( get_template_directory() . '/index.php' ) ) { 780 // Invalid. 781 } elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) { 782 // Invalid. 783 } elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) { 784 // Invalid. 785 } else { 786 // Valid. 787 return true; 788 } 789 790 $default = wp_get_theme( WP_DEFAULT_THEME ); 791 if ( $default->exists() ) { 778 792 switch_theme( WP_DEFAULT_THEME ); 779 793 return false; 780 794 } 781 795 782 if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) { 783 switch_theme( WP_DEFAULT_THEME ); 784 return false; 785 } 786 787 if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) { 788 switch_theme( WP_DEFAULT_THEME ); 789 return false; 790 } 791 792 return true; 796 /** 797 * If we're in an invalid state but WP_DEFAULT_THEME doesn't exist, 798 * switch to the latest core default theme that's installed. 799 * If it turns out that this latest core default theme is our current 800 * theme, then there's nothing we can do about that, so we have to bail, 801 * rather than going into an infinite loop. (This is why there are 802 * checks against WP_DEFAULT_THEME above, also.) We also can't do anything 803 * if it turns out there is no default theme installed. (That's `false`.) 804 */ 805 $default = WP_Theme::get_core_default_theme(); 806 if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) { 807 return true; 808 } 809 810 switch_theme( $default->get_stylesheet() ); 811 return false; 793 812 } 794 813 -
trunk/tests/phpunit/tests/theme.php
r33815 r35738 177 177 */ 178 178 function test_default_theme_in_default_theme_list() { 179 $this->markTestSkipped( 'Core repository inclusion was stopped after Twenty Fifteen' ); 179 180 if ( 'twenty' === substr( WP_DEFAULT_THEME, 0, 6 ) ) { 180 181 $this->assertContains( WP_DEFAULT_THEME, $this->default_themes );
Note: See TracChangeset
for help on using the changeset viewer.