wp/wp-admin/media.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 19 3d72ae0968f4
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** Load WordPress Administration Bootstrap */
     9 /** Load WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once __DIR__ . '/admin.php';
    11 
    11 
    12 $parent_file  = 'upload.php';
    12 $parent_file  = 'upload.php';
    13 $submenu_file = 'upload.php';
    13 $submenu_file = 'upload.php';
    14 
    14 
    15 wp_reset_vars( array( 'action' ) );
    15 wp_reset_vars( array( 'action' ) );
    25 
    25 
    26 		$errors = media_upload_form_handler();
    26 		$errors = media_upload_form_handler();
    27 
    27 
    28 		if ( empty( $errors ) ) {
    28 		if ( empty( $errors ) ) {
    29 			$location = 'media.php';
    29 			$location = 'media.php';
    30 			if ( $referer = wp_get_original_referer() ) {
    30 			$referer  = wp_get_original_referer();
    31 				if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) == $attachment_id ) ) {
    31 			if ( $referer ) {
       
    32 				if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) === $attachment_id ) ) {
    32 					$location = $referer;
    33 					$location = $referer;
    33 				}
    34 				}
    34 			}
    35 			}
    35 			if ( false !== strpos( $location, 'upload.php' ) ) {
    36 			if ( false !== strpos( $location, 'upload.php' ) ) {
    36 				$location = remove_query_arg( 'message', $location );
    37 				$location = remove_query_arg( 'message', $location );
    50 			$errors = null;
    51 			$errors = null;
    51 		}
    52 		}
    52 
    53 
    53 		if ( empty( $_GET['attachment_id'] ) ) {
    54 		if ( empty( $_GET['attachment_id'] ) ) {
    54 			wp_redirect( admin_url( 'upload.php' ) );
    55 			wp_redirect( admin_url( 'upload.php' ) );
    55 			exit();
    56 			exit;
    56 		}
    57 		}
    57 		$att_id = (int) $_GET['attachment_id'];
    58 		$att_id = (int) $_GET['attachment_id'];
    58 
    59 
    59 		if ( ! current_user_can( 'edit_post', $att_id ) ) {
    60 		if ( ! current_user_can( 'edit_post', $att_id ) ) {
    60 			wp_die( __( 'Sorry, you are not allowed to edit this attachment.' ) );
    61 			wp_die( __( 'Sorry, you are not allowed to edit this attachment.' ) );
    66 			wp_die( __( 'You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?' ) );
    67 			wp_die( __( 'You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?' ) );
    67 		}
    68 		}
    68 		if ( 'attachment' !== $att->post_type ) {
    69 		if ( 'attachment' !== $att->post_type ) {
    69 			wp_die( __( 'You attempted to edit an item that isn’t an attachment. Please go back and try again.' ) );
    70 			wp_die( __( 'You attempted to edit an item that isn’t an attachment. Please go back and try again.' ) );
    70 		}
    71 		}
    71 		if ( $att->post_status == 'trash' ) {
    72 		if ( 'trash' === $att->post_status ) {
    72 			wp_die( __( 'You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.' ) );
    73 			wp_die( __( 'You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.' ) );
    73 		}
    74 		}
    74 
    75 
    75 		add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
    76 		add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
    76 
    77 
    81 		get_current_screen()->add_help_tab(
    82 		get_current_screen()->add_help_tab(
    82 			array(
    83 			array(
    83 				'id'      => 'overview',
    84 				'id'      => 'overview',
    84 				'title'   => __( 'Overview' ),
    85 				'title'   => __( 'Overview' ),
    85 				'content' =>
    86 				'content' =>
    86 					  '<p>' . __( 'This screen allows you to edit five fields for metadata in a file within the media library.' ) . '</p>' .
    87 					'<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
    87 					  '<p>' . __( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
    88 					'<p>' . __( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
    88 					  '<p>' . __( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
    89 					'<p>' . __( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
    89 					  '<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
    90 					'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
    90 			)
    91 			)
    91 		);
    92 		);
    92 
    93 
    93 		get_current_screen()->set_help_sidebar(
    94 		get_current_screen()->set_help_sidebar(
    94 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    95 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    95 			'<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>' ) . '</p>' .
    96 			'<p>' . __( '<a href="https://wordpress.org/support/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
    96 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    97 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    97 		);
    98 		);
    98 
    99 
    99 		require( ABSPATH . 'wp-admin/admin-header.php' );
   100 		require_once ABSPATH . 'wp-admin/admin-header.php';
   100 
   101 
   101 		$parent_file = 'upload.php';
   102 		$parent_file = 'upload.php';
   102 		$message     = '';
   103 		$message     = '';
   103 		$class       = '';
   104 		$class       = '';
   104 		if ( isset( $_GET['message'] ) ) {
   105 		if ( isset( $_GET['message'] ) ) {
   163 
   164 
   164 	</div>
   165 	</div>
   165 
   166 
   166 		<?php
   167 		<?php
   167 
   168 
   168 		require( ABSPATH . 'wp-admin/admin-footer.php' );
   169 		require_once ABSPATH . 'wp-admin/admin-footer.php';
   169 
   170 
   170 		exit;
   171 		exit;
   171 
   172 
   172 	default:
   173 	default:
   173 		wp_redirect( admin_url( 'upload.php' ) );
   174 		wp_redirect( admin_url( 'upload.php' ) );