Coding Standards: Rename the $object variable to $attachment in several files.

This brings some consistency with a similar fragment in `Custom_Image_Heade::step_2_manage_upload()`, `WP_Site_Icon::insert_attachment()`, `media_handle_upload()`, and clarifies the type of the data.

Follow-up to [52946], [53137].

See #55327, #54728.
Built from https://develop.svn.wordpress.org/trunk@53183


git-svn-id: http://core.svn.wordpress.org/trunk@52772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-14 15:15:12 +00:00
parent c57fd8ae09
commit 9a9617ea72
6 changed files with 22 additions and 22 deletions

View File

@ -3950,13 +3950,13 @@ function wp_ajax_crop_image() {
}
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
$object = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
unset( $object['ID'] );
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
$attachment = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
unset( $attachment['ID'] );
// Update the attachment.
add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
$attachment_id = $wp_site_icon->insert_attachment( $object, $cropped );
$attachment_id = $wp_site_icon->insert_attachment( $attachment, $cropped );
remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
// Additional sizes in wp_prepare_attachment_for_js().
@ -3988,9 +3988,9 @@ function wp_ajax_crop_image() {
$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
// Get the original image's post to pre-populate the cropped image.
$original_attachment = get_post( $attachment_id );
$sanitized_post_title = sanitize_file_name( $original_attachment->post_title );
$use_original_title = (
$original_attachment = get_post( $attachment_id );
$sanitized_post_title = sanitize_file_name( $original_attachment->post_title );
$use_original_title = (
( '' !== trim( $original_attachment->post_title ) ) &&
/*
* Check if the original image has a title other than the "filename" default,
@ -4001,7 +4001,7 @@ function wp_ajax_crop_image() {
);
$use_original_description = ( '' !== trim( $original_attachment->post_content ) );
$object = array(
$attachment = array(
'post_title' => $use_original_title ? $original_attachment->post_title : wp_basename( $cropped ),
'post_content' => $use_original_description ? $original_attachment->post_content : $url,
'post_mime_type' => $image_type,
@ -4011,17 +4011,17 @@ function wp_ajax_crop_image() {
// Copy the image caption attribute (post_excerpt field) from the original image.
if ( '' !== trim( $original_attachment->post_excerpt ) ) {
$object['post_excerpt'] = $original_attachment->post_excerpt;
$attachment['post_excerpt'] = $original_attachment->post_excerpt;
}
// Copy the image alt text attribute from the original image.
if ( '' !== trim( $original_attachment->_wp_attachment_image_alt ) ) {
$object['meta_input'] = array(
$attachment['meta_input'] = array(
'_wp_attachment_image_alt' => wp_slash( $original_attachment->_wp_attachment_image_alt ),
);
}
$attachment_id = wp_insert_attachment( $object, $cropped );
$attachment_id = wp_insert_attachment( $attachment, $cropped );
$metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
/**

View File

@ -510,8 +510,8 @@ class Custom_Background {
$file = $file['file'];
$filename = wp_basename( $file );
// Construct the object array.
$object = array(
// Construct the attachment array.
$attachment = array(
'post_title' => $filename,
'post_content' => $url,
'post_mime_type' => $type,
@ -520,7 +520,7 @@ class Custom_Background {
);
// Save the data.
$id = wp_insert_attachment( $object, $file );
$id = wp_insert_attachment( $attachment, $file );
// Add the metadata.
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );

View File

@ -973,7 +973,7 @@ endif;
$file = $file['file'];
$filename = wp_basename( $file );
// Construct the array with attachment object data.
// Construct the attachment array.
$attachment = array(
'post_title' => $filename,
'post_content' => $url,

View File

@ -71,8 +71,8 @@ class File_Upload_Upgrader {
$this->filename = $_FILES[ $form ]['name'];
$this->package = $file['file'];
// Construct the object array.
$object = array(
// Construct the attachment array.
$attachment = array(
'post_title' => $this->filename,
'post_content' => $file['url'],
'post_mime_type' => $file['type'],
@ -82,7 +82,7 @@ class File_Upload_Upgrader {
);
// Save the data.
$this->id = wp_insert_attachment( $object, $file['file'] );
$this->id = wp_insert_attachment( $attachment, $file['file'] );
// Schedule a cleanup for 2 hours from now in case of failed installation.
wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );

View File

@ -103,8 +103,8 @@ function wp_import_handle_upload() {
return $upload;
}
// Construct the object array.
$object = array(
// Construct the attachment array.
$attachment = array(
'post_title' => wp_basename( $upload['file'] ),
'post_content' => $upload['url'],
'post_mime_type' => $upload['type'],
@ -114,7 +114,7 @@ function wp_import_handle_upload() {
);
// Save the data.
$id = wp_insert_attachment( $object, $upload['file'] );
$id = wp_insert_attachment( $attachment, $upload['file'] );
/*
* Schedule a cleanup for one day from now in case of failed

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-beta1-53182';
$wp_version = '6.0-beta1-53183';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.