Make WordPress Core

Ticket #33677: 33677.diff

File 33677.diff, 2.1 KB (added by kraftbj, 10 years ago)

Original props ericlewis. Modified for code cleanup, reuse of strings.

  • src/wp-admin/themes.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    1111
    12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
    13         wp_die( __( 'Cheatin’ uh?' ), 403 );
     12if ( ! current_user_can('switch_themes') && ! current_user_can('edit_theme_options') ) {
     13        wp_die(
     14                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     15                '<p>' . __( 'You are not allowed to manage these items.' ) . '</p>',
     16                403 );
     17}
    1418
    1519if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
    1620        if ( 'activate' == $_GET['action'] ) {
    1721                check_admin_referer('switch-theme_' . $_GET['stylesheet']);
    1822                $theme = wp_get_theme( $_GET['stylesheet'] );
    19                 if ( ! $theme->exists() || ! $theme->is_allowed() )
    20                         wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
     23                if ( ! $theme->exists() || ! $theme->is_allowed() ) {
     24                        wp_die(
     25                                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     26                                '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
     27                                403 );
     28                }
    2129                switch_theme( $theme->get_stylesheet() );
    2230                wp_redirect( admin_url('themes.php?activated=true') );
    2331                exit;
     
    2432        } elseif ( 'delete' == $_GET['action'] ) {
    2533                check_admin_referer('delete-theme_' . $_GET['stylesheet']);
    2634                $theme = wp_get_theme( $_GET['stylesheet'] );
    27                 if ( !current_user_can('delete_themes') || ! $theme->exists() )
    28                         wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
     35                if ( ! current_user_can('delete_themes') ) {
     36                        wp_die(
     37                                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     38                                '<p>' . __( 'You are not allowed to delete this item.' ) . '</p>',
     39                                403 );
     40                }
     41                if ( ! $theme->exists() ) {
     42                        wp_die(
     43                                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     44                                '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
     45                                403 );
     46                }
    2947                $active = wp_get_theme();
    3048                if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) {
    3149                        wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) );