Make WordPress Core

Ticket #39318: 39318.2.patch

File 39318.2.patch, 2.1 KB (added by Mista-Flo, 7 years ago)

Better patch

  • wp-admin/network/site-new.php

    diff --git wp-admin/network/site-new.php wp-admin/network/site-new.php
    index 318da58..b943fe9 100644
    if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { 
    6363
    6464        $title = $blog['title'];
    6565
     66        // Get specified theme or fallback to network theme or WP_DEFAULT_THEME constant
     67        $theme = wp_get_theme( $blog['theme'] );
     68        if ( ! $theme->exists() ) {
     69                $theme = wp_get_theme( WP_Theme::network_get_default_theme() );
     70        }
     71
     72        $stylesheet = $theme->get_stylesheet();
     73        $template   = $theme->get_template();
     74
     75        // Check if the theme is not network enabled
     76        if ( ! in_array( $stylesheet, WP_Theme::get_allowed_on_network(), true) ) {
     77                WP_Theme::network_enable_theme( $stylesheet );
     78        }
     79
    6680        $meta = array(
    67                 'public' => 1,
     81                'public'     => 1,
     82                'stylesheet' => $stylesheet,
     83                'template'   => $template,
    6884        );
    6985
    7086        // Handle translation installation for the new site.
    if ( ! empty( $messages ) ) { 
    273289                <tr class="form-field">
    274290                        <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ); ?><br /><?php _e( 'The username and a link to set the password will be mailed to this email address.' ); ?></td>
    275291                </tr>
    276         </table>
    277292
    278         <?php
     293                <?php
     294                $themes = wp_get_themes( array( 'errors' => false ) );
     295                if ( ! empty( $themes ) && is_array( $themes ) ) : ?>
     296                        <tr class="form-field">
     297                                <th scope="row"><label for="site-theme"><?php _e( 'Site Theme' ); ?></label></th>
     298                                <td>
     299                                        <?php
     300                                        // Network default.
     301                                        echo "<select name='blog[theme]' id='site-theme'>\n";
     302                                        $default_theme = WP_Theme::network_get_default_theme();
     303                                        foreach ( $themes as $theme ) {
     304                                                printf( "\t<option value='%s' %s>%s</option>\n",
     305                                                        $theme->stylesheet,
     306                                                        selected( $theme->stylesheet, $default_theme, false ),
     307                                                        $theme
     308                                                );
     309                                        }
     310                                        echo "</select>\n";
     311                                        ?>
     312                                </td>
     313                        </tr>
     314                <?php endif; // Theme. ?>
     315    </table>
     316
     317    <?php
    279318        /**
    280319         * Fires at the end of the new site form in network admin.
    281320         *