Make WordPress Core

Ticket #13743: 13743.3.patch

File 13743.3.patch, 6.0 KB (added by Mista-Flo, 8 years ago)

Code refactoring

  • wp-admin/includes/schema.php

    diff --git wp-admin/includes/schema.php wp-admin/includes/schema.php
    index 8ddc139..46a4d8f 100644
    function populate_options() { 
    367367
    368368        // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
    369369        $stylesheet = $template = WP_DEFAULT_THEME;
    370         $theme = wp_get_theme( WP_DEFAULT_THEME );
    371         if ( ! $theme->exists() ) {
    372                 $theme = WP_Theme::get_core_default_theme();
     370
     371        // If it's multisite and WP_DEFAULT_THEME is not redifined in WP Config, get the network default theme
     372        if ( is_multisite() && WP_DEFAULT_THEME === WP_Theme::get_core_default_theme()->get_template() ) {
     373                $default_theme = get_site_option( 'default_theme' );
     374                if ( ! empty( $default_theme ) && WP_DEFAULT_THEME !== $default_theme ) {
     375                        $theme = wp_get_theme( $default_theme );
     376                        if ( $theme->exists() ) {
     377                                $stylesheet = $theme->get_stylesheet();
     378                                $template   = $theme->get_template();
     379                        }
     380                }
    373381        }
    374382
    375383        // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.
    376         if ( $theme ) {
     384        if ( ! isset( $theme ) ) {
     385                $theme = wp_get_theme( WP_DEFAULT_THEME );
     386                if ( ! $theme->exists() ) {
     387                        $theme = WP_Theme::get_core_default_theme();
     388                }
    377389                $stylesheet = $theme->get_stylesheet();
    378390                $template   = $theme->get_template();
    379         }
     391        }
    380392
    381393        $timezone_string = '';
    382394        $gmt_offset = 0;
  • wp-admin/network/settings.php

    diff --git wp-admin/network/settings.php wp-admin/network/settings.php
    index 07f2a26..49c8d7f 100644
    if ( $_POST ) { 
    5959                'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author',
    6060                'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled',
    6161                'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'admin_email',
    62                 'first_comment_email',
     62                'first_comment_email', 'default_theme'
    6363        );
    6464
    6565        // Handle translation install.
    if ( isset( $_GET['updated'] ) ) { 
    204204                <table class="form-table">
    205205
    206206                        <tr>
     207                                <th scope="row"><label for="default_theme"><?php _e( 'Default Theme' ) ?></label></th>
     208                                <td>
     209                                        <?php
     210                                        $themes = wp_get_themes( array( 'errors' => false, 'allowed' => 'network' ) );
     211                                        if ( ! empty( $themes ) && is_array( $themes ) ) {
     212                                                echo "<select name='default_theme' id='default_theme'>\n";
     213                                                $default_theme = get_site_option( 'default_theme' );
     214                                                foreach ( $themes as $theme ) {
     215                                                        printf( "\t<option value='%s' %s>%s</option>\n",
     216                                                                $theme->stylesheet,
     217                                                                selected( $theme->stylesheet, $default_theme, false ),
     218                                                                $theme
     219                                                        );
     220                                                }
     221                                                echo "</select>\n";
     222                                        }
     223                                        ?>
     224                                </td>
     225                        </tr>
     226                        <tr>
    207227                                <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th>
    208228                                <td>
    209229                                        <textarea name="welcome_email" id="welcome_email" aria-describedby="welcome-email-desc" rows="5" cols="45" class="large-text">