wp/wp-admin/media.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    18 case 'editattachment' :
    18 case 'editattachment' :
    19 	$attachment_id = (int) $_POST['attachment_id'];
    19 	$attachment_id = (int) $_POST['attachment_id'];
    20 	check_admin_referer('media-form');
    20 	check_admin_referer('media-form');
    21 
    21 
    22 	if ( !current_user_can('edit_post', $attachment_id) )
    22 	if ( !current_user_can('edit_post', $attachment_id) )
    23 		wp_die ( __('You are not allowed to edit this attachment.') );
    23 		wp_die ( __('Sorry, you are not allowed to edit this attachment.') );
    24 
    24 
    25 	$errors = media_upload_form_handler();
    25 	$errors = media_upload_form_handler();
    26 
    26 
    27 	if ( empty($errors) ) {
    27 	if ( empty($errors) ) {
    28 		$location = 'media.php';
    28 		$location = 'media.php';
    52 		exit();
    52 		exit();
    53 	}
    53 	}
    54 	$att_id = (int) $_GET['attachment_id'];
    54 	$att_id = (int) $_GET['attachment_id'];
    55 
    55 
    56 	if ( !current_user_can('edit_post', $att_id) )
    56 	if ( !current_user_can('edit_post', $att_id) )
    57 		wp_die ( __('You are not allowed to edit this attachment.') );
    57 		wp_die ( __('Sorry, you are not allowed to edit this attachment.') );
    58 
    58 
    59 	$att = get_post($att_id);
    59 	$att = get_post($att_id);
    60 
    60 
    61 	if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') );
    61 	if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') );
    62 	if ( 'attachment' !== $att->post_type ) wp_die( __('You attempted to edit an item that isn’t an attachment. Please go back and try again.') );
    62 	if ( 'attachment' !== $att->post_type ) wp_die( __('You attempted to edit an item that isn’t an attachment. Please go back and try again.') );
    78 			'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
    78 			'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
    79 	) );
    79 	) );
    80 
    80 
    81 	get_current_screen()->set_help_sidebar(
    81 	get_current_screen()->set_help_sidebar(
    82 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    82 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    83 	'<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media" target="_blank">Documentation on Edit Media</a>') . '</p>' .
    83 	'<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>') . '</p>' .
    84 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    84 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    85 	);
    85 	);
    86 
    86 
    87 	require( ABSPATH . 'wp-admin/admin-header.php' );
    87 	require( ABSPATH . 'wp-admin/admin-header.php' );
    88 
    88 
    89 	$parent_file = 'upload.php';
    89 	$parent_file = 'upload.php';
    90 	$message = '';
    90 	$message = '';
    91 	$class = '';
    91 	$class = '';
    92 	if ( isset($_GET['message']) ) {
    92 	if ( isset($_GET['message']) ) {
    93 		switch ( $_GET['message'] ) {
    93 		switch ( $_GET['message'] ) {
    94 			case 'updated' :
    94 			case 'updated' :
    95 				$message = __('Media attachment updated.');
    95 				$message = __('Media file updated.');
    96 				$class = 'updated';
    96 				$class = 'updated';
    97 				break;
    97 				break;
    98 		}
    98 		}
    99 	}
    99 	}
   100 	if ( $message )
   100 	if ( $message )
   101 		echo "<div id='message' class='$class'><p>$message</p></div>\n";
   101 		echo "<div id='message' class='$class'><p>$message</p></div>\n";
   102 
   102 
   103 ?>
   103 ?>
   104 
   104 
   105 <div class="wrap">
   105 <div class="wrap">
   106 <h2>
   106 <h1 class="wp-heading-inline"><?php
       
   107 echo esc_html( $title );
       
   108 ?></h1>
       
   109 
   107 <?php
   110 <?php
   108 echo esc_html( $title );
       
   109 if ( current_user_can( 'upload_files' ) ) { ?>
   111 if ( current_user_can( 'upload_files' ) ) { ?>
   110 	<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a>
   112 	<a href="media-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a>
   111 <?php } ?>
   113 <?php } ?>
   112 </h2>
   114 
       
   115 <hr class="wp-header-end">
   113 
   116 
   114 <form method="post" class="media-upload-form" id="media-single-form">
   117 <form method="post" class="media-upload-form" id="media-single-form">
   115 <p class="submit" style="padding-bottom: 0;">
   118 <p class="submit" style="padding-bottom: 0;">
   116 <?php submit_button( __( 'Update Media' ), 'primary', 'save', false ); ?>
   119 <?php submit_button( __( 'Update Media' ), 'primary', 'save', false ); ?>
   117 </p>
   120 </p>