Provide more helful feedback than just "Cheatin' uh?" for permission errors in `wp-admin/media-upload.php`.

props ericlewis, kraftbj, lukecarbis, mrmist.
fixes #33672. see #14530.
Built from https://develop.svn.wordpress.org/trunk@33853


git-svn-id: http://core.svn.wordpress.org/trunk@33821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-09-02 16:21:21 +00:00
parent c3b663ad8d
commit d95417a5e7
2 changed files with 15 additions and 6 deletions

View File

@ -15,8 +15,9 @@ if ( ! isset( $_GET['inline'] ) )
/** Load WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if (!current_user_can('upload_files'))
wp_die(__('You do not have permission to upload files.'));
if ( ! current_user_can( 'upload_files' ) ) {
wp_die( __( 'You do not have permission to upload files.' ), 403 );
}
wp_enqueue_script('plupload-handlers');
wp_enqueue_script('image-edit');
@ -31,12 +32,20 @@ $ID = isset($ID) ? (int) $ID : 0;
$post_id = isset($post_id)? (int) $post_id : 0;
// Require an ID for the edit screen.
if ( isset($action) && $action == 'edit' && !$ID ) {
wp_die( __( 'Cheatin’ uh?' ), 403 );
if ( isset( $action ) && $action == 'edit' && !$ID ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'Invalid item ID.' ) . '</p>',
403
);
}
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) {
wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'You are not allowed to edit this item.' ) . '</p>',
403
);
}
// Upload type: image, video, file, ..?

View File

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