Ticket #34306: 34306.5.diff
File 34306.5.diff, 14.9 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/update-core.php
$_old_files = array( 703 703 ); 704 704 705 705 /** 706 706 * Stores new files in wp-content to copy 707 707 * 708 708 * The contents of this array indicate any new bundled plugins/themes which 709 709 * should be installed with the WordPress Upgrade. These items will not be 710 710 * re-installed in future upgrades, this behaviour is controlled by the 711 711 * introduced version present here being older than the current installed version. 712 712 * 713 713 * The content of this array should follow the following format: 714 714 * Filename (relative to wp-content) => Introduced version 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 721 724 */ 722 725 global $_new_bundled_files; 723 726 724 727 $_new_bundled_files = array( 725 728 'plugins/akismet/' => '2.0', 726 729 'themes/twentyten/' => '3.0', 727 730 'themes/twentyeleven/' => '3.2', 728 731 'themes/twentytwelve/' => '3.5', 729 732 'themes/twentythirteen/' => '3.6', 730 733 'themes/twentyfourteen/' => '3.8', 731 734 'themes/twentyfifteen/' => '4.1', 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 * 738 746 * This will create a .maintenance file at the base of the WordPress directory 739 747 * to ensure that people can not access the web site, when the files are being 740 748 * copied to their locations. 741 749 * 742 750 * The files in the {@link $_old_files} list will be removed and the new files 743 751 * copied from the zip file after the database is upgraded. 744 752 * 745 753 * The files in the {@link $_new_bundled_files} list will be added to the installation 746 754 * if the version is greater than or equal to the old version being upgraded. 747 755 * 748 756 * The steps for the upgrader for after the new release is downloaded and 749 757 * unzipped is: -
src/wp-admin/includes/schema.php
function populate_options() { 356 356 $guessurl = wp_guess_url(); 357 357 /** 358 358 * Fires before creating WordPress options and populating their default values. 359 359 * 360 360 * @since 2.6.0 361 361 */ 362 362 do_action( 'populate_options' ); 363 363 364 364 if ( ini_get('safe_mode') ) { 365 365 // Safe mode can break mkdir() so use a flat structure by default. 366 366 $uploads_use_yearmonth_folders = 0; 367 367 } else { 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 } 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 = ''; 378 385 $gmt_offset = 0; 379 386 /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) 380 387 or a valid timezone string (America/New_York). See http://us3.php.net/manual/en/timezones.php 381 388 for all timezone strings supported by PHP. 382 389 */ 383 390 $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); 384 391 if ( is_numeric( $offset_or_tz ) ) 385 392 $gmt_offset = $offset_or_tz; 386 393 elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) 387 394 $timezone_string = $offset_or_tz; 388 395 389 396 $options = array( 390 397 'siteurl' => $guessurl, … … function populate_options() { 421 428 'moderation_notify' => 1, 422 429 'permalink_structure' => '', 423 430 'hack_file' => 0, 424 431 'blog_charset' => 'UTF-8', 425 432 'moderation_keys' => '', 426 433 'active_plugins' => array(), 427 434 'category_base' => '', 428 435 'ping_sites' => 'http://rpc.pingomatic.com/', 429 436 'comment_max_links' => 2, 430 437 'gmt_offset' => $gmt_offset, 431 438 432 439 // 1.5 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, 440 447 'html_type' => 'text/html', 441 448 442 449 // 1.5.1 443 450 'use_trackback' => 0, 444 451 445 452 // 2.0 446 453 'default_role' => 'subscriber', 447 454 'db_version' => $wp_db_version, 448 455 449 456 // 2.0.1 450 457 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 451 458 'upload_path' => '', … … function populate_network( $network_id = 902 909 $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); 903 910 904 911 if ( $errors->get_error_code() ) 905 912 return $errors; 906 913 907 914 // If a user with the provided email does not exist, default to the current user as the new network admin. 908 915 $site_user = get_user_by( 'email', $email ); 909 916 if ( false === $site_user ) { 910 917 $site_user = wp_get_current_user(); 911 918 } 912 919 913 920 // Set up site tables. 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 } 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 ) { 923 941 $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) ); 924 942 $network_id = $wpdb->insert_id; 925 943 } else { 926 944 $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) ); 927 945 } 928 946 929 947 wp_cache_delete( 'networks_have_paths', 'site-options' ); 930 948 931 949 if ( !is_multisite() ) { 932 950 $site_admins = array( $site_user->user_login ); 933 951 $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) ); 934 952 if ( $users ) { 935 953 foreach ( $users as $user ) { -
src/wp-includes/class-wp-theme.php
final class WP_Theme implements ArrayAcc 44 44 * Default themes. 45 45 * 46 46 * @static 47 47 * @access private 48 48 * @var array 49 49 */ 50 50 private static $default_themes = array( 51 51 'classic' => 'WordPress Classic', 52 52 'default' => 'WordPress Default', 53 53 'twentyten' => 'Twenty Ten', 54 54 'twentyeleven' => 'Twenty Eleven', 55 55 'twentytwelve' => 'Twenty Twelve', 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 /** 62 63 * Renamed theme tags. 63 64 * 64 65 * @static 65 66 * @access private 66 67 * @var array 67 68 */ 68 69 private static $tag_map = array( 69 70 'fixed-width' => 'fixed-layout', 70 71 'flexible-width' => 'fluid-layout', 71 72 ); 72 73 73 74 /** … … final class WP_Theme implements ArrayAcc 1139 1140 $allowed = self::get_allowed_on_network(); 1140 1141 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) 1141 1142 return true; 1142 1143 } 1143 1144 1144 1145 if ( 'both' == $check || 'site' == $check ) { 1145 1146 $allowed = self::get_allowed_on_site( $blog_id ); 1146 1147 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) 1147 1148 return true; 1148 1149 } 1149 1150 1150 1151 return false; 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 1157 1175 * 1158 1176 * @static 1159 1177 * @access public 1160 1178 * 1161 1179 * @param int $blog_id Optional. Defaults to current blog. 1162 1180 * @return array Array of stylesheet names. 1163 1181 */ 1164 1182 public static function get_allowed( $blog_id = null ) { 1165 1183 /** 1166 1184 * Filter the array of themes allowed on the site or network. 1167 1185 * 1168 1186 * @since MU -
src/wp-includes/default-constants.php
function wp_templating_constants() { 336 336 /** 337 337 * Filesystem path to the current active template directory 338 338 * @since 1.5.0 339 339 */ 340 340 define('TEMPLATEPATH', get_template_directory()); 341 341 342 342 /** 343 343 * Filesystem path to the current active template stylesheet directory 344 344 * @since 2.1.0 345 345 */ 346 346 define('STYLESHEETPATH', get_stylesheet_directory()); 347 347 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
function switch_theme( $stylesheet ) { 741 741 update_option( 'theme_switched', $old_theme->get_stylesheet() ); 742 742 /** 743 743 * Fires after the theme is switched. 744 744 * 745 745 * @since 1.5.0 746 746 * 747 747 * @param string $new_name Name of the new theme. 748 748 * @param WP_Theme $new_theme WP_Theme instance of the new theme. 749 749 */ 750 750 do_action( 'switch_theme', $new_name, $new_theme ); 751 751 } 752 752 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 * 761 763 * @since 1.5.0 762 764 * @see WP_DEFAULT_THEME 763 765 * 764 766 * @return bool 765 767 */ 766 768 function validate_current_theme() { 767 769 /** 768 770 * Filter whether to validate the current theme. 769 771 * 770 772 * @since 2.7.0 771 773 * 772 774 * @param bool true Validation flag to check the current theme. 773 775 */ 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 ( ! 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; 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 /** 796 815 * Retrieve all theme modifications. 797 816 * 798 817 * @since 3.1.0 799 818 * 800 819 * @return array|void Theme modifications. 801 820 */ 802 821 function get_theme_mods() { 803 822 $theme_slug = get_option( 'stylesheet' ); 804 823 $mods = get_option( "theme_mods_$theme_slug" ); 805 824 if ( false === $mods ) { 806 825 $theme_name = get_option( 'current_theme' ); 807 826 if ( false === $theme_name ) -
tests/phpunit/tests/theme.php
class Tests_Theme extends WP_UnitTestCas 164 164 165 165 $this->assertEquals('publish', $theme->get( 'Status' ) ); 166 166 167 167 $this->assertEquals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_stylesheet_directory(), 'get_stylesheet_directory' ); 168 168 $this->assertEquals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_template_directory(), 'get_template_directory' ); 169 169 $this->assertEquals( content_url( 'themes/' . $this->theme_slug ), $theme->get_stylesheet_directory_uri(), 'get_stylesheet_directory_uri' ); 170 170 $this->assertEquals( content_url( 'themes/' . $this->theme_slug ), $theme->get_template_directory_uri(), 'get_template_directory_uri' ); 171 171 } 172 172 173 173 /** 174 174 * Make sure we update the default theme list to include the latest default theme. 175 175 * 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 } 182 183 } 183 184 184 185 function test_default_themes_have_textdomain() { 185 186 foreach ( $this->default_themes as $theme ) { 186 187 $this->assertEquals( $theme, wp_get_theme( $theme )->get( 'TextDomain' ) ); 187 188 } 188 189 } 189 190 190 191 /** 191 192 * @ticket 20897 192 193 * @expectedDeprecated get_theme_data 193 194 */