Make WordPress Core


Ignore:
Timestamp:
04/14/2022 03:13:45 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r53123 r53183  
    39513951
    39523952            /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
    3953             $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
    3954             $object = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
    3955             unset( $object['ID'] );
     3953            $cropped    = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
     3954            $attachment = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
     3955            unset( $attachment['ID'] );
    39563956
    39573957            // Update the attachment.
    39583958            add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
    3959             $attachment_id = $wp_site_icon->insert_attachment( $object, $cropped );
     3959            $attachment_id = $wp_site_icon->insert_attachment( $attachment, $cropped );
    39603960            remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
    39613961
     
    39893989
    39903990            // Get the original image's post to pre-populate the cropped image.
    3991             $original_attachment      = get_post( $attachment_id );
    3992             $sanitized_post_title     = sanitize_file_name( $original_attachment->post_title );
    3993             $use_original_title       = (
     3991            $original_attachment  = get_post( $attachment_id );
     3992            $sanitized_post_title = sanitize_file_name( $original_attachment->post_title );
     3993            $use_original_title   = (
    39943994                ( '' !== trim( $original_attachment->post_title ) ) &&
    39953995                /*
     
    40024002            $use_original_description = ( '' !== trim( $original_attachment->post_content ) );
    40034003
    4004             $object = array(
     4004            $attachment = array(
    40054005                'post_title'     => $use_original_title ? $original_attachment->post_title : wp_basename( $cropped ),
    40064006                'post_content'   => $use_original_description ? $original_attachment->post_content : $url,
     
    40124012            // Copy the image caption attribute (post_excerpt field) from the original image.
    40134013            if ( '' !== trim( $original_attachment->post_excerpt ) ) {
    4014                 $object['post_excerpt'] = $original_attachment->post_excerpt;
     4014                $attachment['post_excerpt'] = $original_attachment->post_excerpt;
    40154015            }
    40164016
    40174017            // Copy the image alt text attribute from the original image.
    40184018            if ( '' !== trim( $original_attachment->_wp_attachment_image_alt ) ) {
    4019                 $object['meta_input'] = array(
     4019                $attachment['meta_input'] = array(
    40204020                    '_wp_attachment_image_alt' => wp_slash( $original_attachment->_wp_attachment_image_alt ),
    40214021                );
    40224022            }
    40234023
    4024             $attachment_id = wp_insert_attachment( $object, $cropped );
     4024            $attachment_id = wp_insert_attachment( $attachment, $cropped );
    40254025            $metadata      = wp_generate_attachment_metadata( $attachment_id, $cropped );
    40264026
Note: See TracChangeset for help on using the changeset viewer.