Make WordPress Core

Ticket #39334: 39334.2.patch

File 39334.2.patch, 3.1 KB (added by Mista-Flo, 8 years ago)

Patch 2 : Just handle this in one action

  • wp-admin/themes.php

    diff --git wp-admin/themes.php wp-admin/themes.php
    index c02c17a..0291cfb 100644
    if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { 
    2222                check_admin_referer('switch-theme_' . $_GET['stylesheet']);
    2323                $theme = wp_get_theme( $_GET['stylesheet'] );
    2424
    25                 if ( ! $theme->exists() || ! $theme->is_allowed() ) {
     25                if ( ! $theme->exists() ) {
    2626                        wp_die(
    2727                                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
    2828                                '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
    if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { 
    3030                        );
    3131                }
    3232
     33                if ( ! $theme->is_allowed() && current_user_can( 'manage_network_themes' ) ) {
     34                        WP_Theme::network_enable_theme( $theme->get_stylesheet() );
     35                }
     36
    3337                switch_theme( $theme->get_stylesheet() );
    3438                wp_redirect( admin_url('themes.php?activated=true') );
    3539                exit;
    get_current_screen()->set_help_sidebar( 
    119123        '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    120124);
    121125
    122 if ( current_user_can( 'switch_themes' ) ) {
     126if ( current_user_can( 'manage_network_themes' ) ) {
     127        // Display all themes to allow network administrator who can manage themes to network activate it
     128        $themes = wp_prepare_themes_for_js( wp_get_themes() );
     129} else if ( current_user_can( 'switch_themes' ) ) {
     130        // Display only allowed themes
    123131        $themes = wp_prepare_themes_for_js();
    124132} else {
    125133        $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );