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.
Built from https://develop.svn.wordpress.org/trunk@33866


git-svn-id: http://core.svn.wordpress.org/trunk@33834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-09-02 18:45:21 +00:00
parent 3e0929740e
commit bc0a1e1c4b
2 changed files with 34 additions and 7 deletions

View File

@ -9,23 +9,50 @@
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
wp_die( __( 'Cheatin’ uh?' ), 403 );
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'You are not allowed to edit theme options on this site.' ) . '</p>',
403
);
}
if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
if ( 'activate' == $_GET['action'] ) {
check_admin_referer('switch-theme_' . $_GET['stylesheet']);
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( ! $theme->exists() || ! $theme->is_allowed() )
wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
if ( ! $theme->exists() || ! $theme->is_allowed() ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'The requested theme does not exist.' ) . '</p>',
403
);
}
switch_theme( $theme->get_stylesheet() );
wp_redirect( admin_url('themes.php?activated=true') );
exit;
} elseif ( 'delete' == $_GET['action'] ) {
check_admin_referer('delete-theme_' . $_GET['stylesheet']);
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( !current_user_can('delete_themes') || ! $theme->exists() )
wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
if ( ! current_user_can( 'delete_themes' ) ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'You are not allowed to delete this item.' ) . '</p>',
403
);
}
if ( ! $theme->exists() ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'The requested theme does not exist.' ) . '</p>',
403
);
}
$active = wp_get_theme();
if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) {
wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-33865';
$wp_version = '4.4-alpha-33866';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.