Remove cruft from media-new.php. No need to keep extra parameters around (including post ID, which is always 0 here). see #22083.

git-svn-id: https://develop.svn.wordpress.org/trunk@22752 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-11-21 12:27:12 +00:00
parent 7572347b8c
commit d2c8701c37
1 changed files with 11 additions and 24 deletions

View File

@ -21,20 +21,11 @@ wp_enqueue_script('set-post-thumbnail' );
wp_enqueue_style('imgareaselect'); wp_enqueue_style('imgareaselect');
wp_enqueue_script( 'media-gallery' ); wp_enqueue_script( 'media-gallery' );
$errors = array();
// IDs should be integers unset( $_REQUEST['post_id'] );
$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?' ) );
$errors = array();
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
wp_die( __( 'Cheatin’ uh?' ) );
if ( $_POST ) {
if ( isset($_POST['html-upload']) && !empty($_FILES) ) { if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
check_admin_referer('media-form'); check_admin_referer('media-form');
// Upload File button was clicked // Upload File button was clicked
@ -46,19 +37,15 @@ if ( isset($action) && $action == 'edit' && !$ID )
} }
} }
if ( isset($_GET['upload-page-form']) ) { $errors = array_merge($errors, (array) media_upload_form_handler());
$errors = array_merge($errors, (array) media_upload_form_handler());
$location = 'upload.php'; $location = 'upload.php';
if ( $errors ) if ( $errors )
$location .= '?message=3'; $location .= '?message=3';
wp_redirect( admin_url($location) ); wp_redirect( admin_url($location) );
exit; exit;
} }
if ( isset( $_REQUEST['post_id'] ) )
wp_die( __( 'Cheatin’ uh?' ) );
$title = __('Upload New Media'); $title = __('Upload New Media');
$parent_file = 'upload.php'; $parent_file = 'upload.php';
@ -91,7 +78,7 @@ if ( isset($action) && $action == 'edit' && !$ID )
<?php screen_icon(); ?> <?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2> <h2><?php echo esc_html( $title ); ?></h2>
<form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php?inline=&amp;upload-page-form='); ?>" class="<?php echo $form_class; ?>" id="file-form"> <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo $form_class; ?>" id="file-form">
<?php media_upload_form(); ?> <?php media_upload_form(); ?>