Make WordPress Core

Changeset 33866


Ignore:
Timestamp:
09/02/2015 06:44:07 PM (9 years ago)
Author:
SergeyBiryukov
Message:

Provide more helpful feedback than just "Cheatin' uh?" for permission errors in wp-admin/themes.php.

props ericlewis, kraftbj, lukecarbis, mrmist.
fixes #33677. see #14530.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r33820 r33866  
    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 edit theme options on this site.' ) . '</p>',
     16        403
     17    );
     18}
    1419
    1520if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
     
    1722        check_admin_referer('switch-theme_' . $_GET['stylesheet']);
    1823        $theme = wp_get_theme( $_GET['stylesheet'] );
    19         if ( ! $theme->exists() || ! $theme->is_allowed() )
    20             wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
     24
     25        if ( ! $theme->exists() || ! $theme->is_allowed() ) {
     26            wp_die(
     27                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     28                '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
     29                403
     30            );
     31        }
     32
    2133        switch_theme( $theme->get_stylesheet() );
    2234        wp_redirect( admin_url('themes.php?activated=true') );
     
    2537        check_admin_referer('delete-theme_' . $_GET['stylesheet']);
    2638        $theme = wp_get_theme( $_GET['stylesheet'] );
    27         if ( !current_user_can('delete_themes') || ! $theme->exists() )
    28             wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
     39
     40        if ( ! current_user_can( 'delete_themes' ) ) {
     41            wp_die(
     42                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     43                '<p>' . __( 'You are not allowed to delete this item.' ) . '</p>',
     44                403
     45            );
     46        }
     47
     48        if ( ! $theme->exists() ) {
     49            wp_die(
     50                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     51                '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
     52                403
     53            );
     54        }
     55
    2956        $active = wp_get_theme();
    3057        if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) {
Note: See TracChangeset for help on using the changeset viewer.