Ticket #34306: 34306.3.diff
File 34306.3.diff, 7.8 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/schema.php
368 368 $uploads_use_yearmonth_folders = 1; 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 } 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 } 383 377 384 $timezone_string = ''; 378 385 $gmt_offset = 0; 379 386 /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) … … 433 440 'default_email_category' => 1, 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' => '', 439 446 'comment_registration' => 0, … … 914 921 $template = get_option( 'template' ); 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 } 921 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 ] = true; 937 } 938 } 939 922 940 if ( 1 == $network_id ) { 923 941 $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) ); 924 942 $network_id = $wpdb->insert_id; -
src/wp-admin/includes/update-core.php
715 715 * Directories should be noted by suffixing it with a trailing slash (/) 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 720 723 * @name $_new_bundled_files … … 732 735 'themes/twentysixteen/' => '4.4', 733 736 ); 734 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 } 742 735 743 /** 736 744 * Upgrade the core of WordPress. 737 745 * -
src/wp-includes/class-wp-theme.php
56 56 'twentythirteen' => 'Twenty Thirteen', 57 57 'twentyfourteen' => 'Twenty Fourteen', 58 58 'twentyfifteen' => 'Twenty Fifteen', 59 'twentysixteen' => 'Twenty Sixteen', 59 60 ); 60 61 61 62 /** … … 1151 1152 } 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 * 1156 1174 * @since 3.4.0 -
src/wp-includes/default-constants.php
348 348 /** 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') ) 355 define( 'WP_DEFAULT_THEME', 'twenty fifteen' );357 define( 'WP_DEFAULT_THEME', 'twentysixteen' ); 356 358 357 359 } -
src/wp-includes/theme.php
753 753 /** 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. 760 762 * … … 774 776 if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) 775 777 return true; 776 778 777 if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) { 778 switch_theme( WP_DEFAULT_THEME ); 779 return false; 779 if ( get_template() != WP_DEFAULT_THEME && ! file_exists( get_template_directory() . '/index.php' ) ) { 780 // Invalid. 781 } elseif ( get_stylesheet() != WP_DEFAULT_THEME && ! 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; 780 788 } 781 789 782 if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) { 790 $default = wp_get_theme( WP_DEFAULT_THEME ); 791 if ( $default->exists() ) { 783 792 switch_theme( WP_DEFAULT_THEME ); 784 793 return false; 785 794 } 786 795 787 if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) { 788 switch_theme( WP_DEFAULT_THEME ); 789 return false; 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; 790 808 } 791 809 792 return true; 810 switch_theme( $default->get_stylesheet() ); 811 return false; 793 812 } 794 813 795 814 /** -
tests/phpunit/tests/theme.php
176 176 * @ticket 29925 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 ); 181 182 }