Edit File by line
/home/barbar84/public_h.../wp-admin
File: media.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Media management action handler.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/** Load WordPress Administration Bootstrap */
[8] Fix | Delete
require_once __DIR__ . '/admin.php';
[9] Fix | Delete
[10] Fix | Delete
$parent_file = 'upload.php';
[11] Fix | Delete
$submenu_file = 'upload.php';
[12] Fix | Delete
[13] Fix | Delete
wp_reset_vars( array( 'action' ) );
[14] Fix | Delete
[15] Fix | Delete
switch ( $action ) {
[16] Fix | Delete
case 'editattachment':
[17] Fix | Delete
$attachment_id = (int) $_POST['attachment_id'];
[18] Fix | Delete
check_admin_referer( 'media-form' );
[19] Fix | Delete
[20] Fix | Delete
if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
[21] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this attachment.' ) );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
$errors = media_upload_form_handler();
[25] Fix | Delete
[26] Fix | Delete
if ( empty( $errors ) ) {
[27] Fix | Delete
$location = 'media.php';
[28] Fix | Delete
$referer = wp_get_original_referer();
[29] Fix | Delete
if ( $referer ) {
[30] Fix | Delete
if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) === $attachment_id ) ) {
[31] Fix | Delete
$location = $referer;
[32] Fix | Delete
}
[33] Fix | Delete
}
[34] Fix | Delete
if ( false !== strpos( $location, 'upload.php' ) ) {
[35] Fix | Delete
$location = remove_query_arg( 'message', $location );
[36] Fix | Delete
$location = add_query_arg( 'posted', $attachment_id, $location );
[37] Fix | Delete
} elseif ( false !== strpos( $location, 'media.php' ) ) {
[38] Fix | Delete
$location = add_query_arg( 'message', 'updated', $location );
[39] Fix | Delete
}
[40] Fix | Delete
wp_redirect( $location );
[41] Fix | Delete
exit;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
// No break.
[45] Fix | Delete
case 'edit':
[46] Fix | Delete
$title = __( 'Edit Media' );
[47] Fix | Delete
[48] Fix | Delete
if ( empty( $errors ) ) {
[49] Fix | Delete
$errors = null;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
if ( empty( $_GET['attachment_id'] ) ) {
[53] Fix | Delete
wp_redirect( admin_url( 'upload.php' ) );
[54] Fix | Delete
exit;
[55] Fix | Delete
}
[56] Fix | Delete
$att_id = (int) $_GET['attachment_id'];
[57] Fix | Delete
[58] Fix | Delete
if ( ! current_user_can( 'edit_post', $att_id ) ) {
[59] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this attachment.' ) );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$att = get_post( $att_id );
[63] Fix | Delete
[64] Fix | Delete
if ( empty( $att->ID ) ) {
[65] Fix | Delete
wp_die( __( 'You attempted to edit an attachment that doesn&#8217;t exist. Perhaps it was deleted?' ) );
[66] Fix | Delete
}
[67] Fix | Delete
if ( 'attachment' !== $att->post_type ) {
[68] Fix | Delete
wp_die( __( 'You attempted to edit an item that isn&#8217;t an attachment. Please go back and try again.' ) );
[69] Fix | Delete
}
[70] Fix | Delete
if ( 'trash' === $att->post_status ) {
[71] Fix | Delete
wp_die( __( 'You can&#8217;t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.' ) );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
[75] Fix | Delete
[76] Fix | Delete
wp_enqueue_script( 'wp-ajax-response' );
[77] Fix | Delete
wp_enqueue_script( 'image-edit' );
[78] Fix | Delete
wp_enqueue_style( 'imgareaselect' );
[79] Fix | Delete
[80] Fix | Delete
get_current_screen()->add_help_tab(
[81] Fix | Delete
array(
[82] Fix | Delete
'id' => 'overview',
[83] Fix | Delete
'title' => __( 'Overview' ),
[84] Fix | Delete
'content' =>
[85] Fix | Delete
'<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
[86] Fix | Delete
'<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>' .
[87] Fix | Delete
'<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>' .
[88] Fix | Delete
'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
[89] Fix | Delete
)
[90] Fix | Delete
);
[91] Fix | Delete
[92] Fix | Delete
get_current_screen()->set_help_sidebar(
[93] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[94] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
[95] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
[96] Fix | Delete
);
[97] Fix | Delete
[98] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[99] Fix | Delete
[100] Fix | Delete
$parent_file = 'upload.php';
[101] Fix | Delete
$message = '';
[102] Fix | Delete
$class = '';
[103] Fix | Delete
if ( isset( $_GET['message'] ) ) {
[104] Fix | Delete
switch ( $_GET['message'] ) {
[105] Fix | Delete
case 'updated':
[106] Fix | Delete
$message = __( 'Media file updated.' );
[107] Fix | Delete
$class = 'updated';
[108] Fix | Delete
break;
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
if ( $message ) {
[112] Fix | Delete
echo "<div id='message' class='$class'><p>$message</p></div>\n";
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
?>
[116] Fix | Delete
[117] Fix | Delete
<div class="wrap">
[118] Fix | Delete
<h1 class="wp-heading-inline">
[119] Fix | Delete
<?php
[120] Fix | Delete
echo esc_html( $title );
[121] Fix | Delete
?>
[122] Fix | Delete
</h1>
[123] Fix | Delete
[124] Fix | Delete
<?php
[125] Fix | Delete
if ( current_user_can( 'upload_files' ) ) {
[126] Fix | Delete
?>
[127] Fix | Delete
<a href="media-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a>
[128] Fix | Delete
<?php } ?>
[129] Fix | Delete
[130] Fix | Delete
<hr class="wp-header-end">
[131] Fix | Delete
[132] Fix | Delete
<form method="post" class="media-upload-form" id="media-single-form">
[133] Fix | Delete
<p class="submit" style="padding-bottom: 0;">
[134] Fix | Delete
<?php submit_button( __( 'Update Media' ), 'primary', 'save', false ); ?>
[135] Fix | Delete
</p>
[136] Fix | Delete
[137] Fix | Delete
<div class="media-single">
[138] Fix | Delete
<div id="media-item-<?php echo $att_id; ?>" class="media-item">
[139] Fix | Delete
<?php
[140] Fix | Delete
echo get_media_item(
[141] Fix | Delete
$att_id,
[142] Fix | Delete
array(
[143] Fix | Delete
'toggle' => false,
[144] Fix | Delete
'send' => false,
[145] Fix | Delete
'delete' => false,
[146] Fix | Delete
'show_title' => false,
[147] Fix | Delete
'errors' => ! empty( $errors[ $att_id ] ) ? $errors[ $att_id ] : null,
[148] Fix | Delete
)
[149] Fix | Delete
);
[150] Fix | Delete
?>
[151] Fix | Delete
</div>
[152] Fix | Delete
</div>
[153] Fix | Delete
[154] Fix | Delete
<?php submit_button( __( 'Update Media' ), 'primary', 'save' ); ?>
[155] Fix | Delete
<input type="hidden" name="post_id" id="post_id" value="<?php echo isset( $post_id ) ? esc_attr( $post_id ) : ''; ?>" />
[156] Fix | Delete
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $att_id ); ?>" />
[157] Fix | Delete
<input type="hidden" name="action" value="editattachment" />
[158] Fix | Delete
<?php wp_original_referer_field( true, 'previous' ); ?>
[159] Fix | Delete
<?php wp_nonce_field( 'media-form' ); ?>
[160] Fix | Delete
[161] Fix | Delete
</form>
[162] Fix | Delete
[163] Fix | Delete
</div>
[164] Fix | Delete
[165] Fix | Delete
<?php
[166] Fix | Delete
[167] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[168] Fix | Delete
[169] Fix | Delete
exit;
[170] Fix | Delete
[171] Fix | Delete
default:
[172] Fix | Delete
wp_redirect( admin_url( 'upload.php' ) );
[173] Fix | Delete
exit;
[174] Fix | Delete
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function