Make WordPress Core

Changeset 53183


Ignore:
Timestamp:
04/14/2022 03:13:45 PM (3 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.

Location:
trunk/src/wp-admin/includes
Files:
5 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
  • trunk/src/wp-admin/includes/class-custom-background.php

    r52978 r53183  
    511511        $filename = wp_basename( $file );
    512512
    513         // Construct the object array.
    514         $object = array(
     513        // Construct the attachment array.
     514        $attachment = array(
    515515            'post_title'     => $filename,
    516516            'post_content'   => $url,
     
    521521
    522522        // Save the data.
    523         $id = wp_insert_attachment( $object, $file );
     523        $id = wp_insert_attachment( $attachment, $file );
    524524
    525525        // Add the metadata.
  • trunk/src/wp-admin/includes/class-custom-image-header.php

    r52978 r53183  
    974974        $filename = wp_basename( $file );
    975975
    976         // Construct the array with attachment object data.
     976        // Construct the attachment array.
    977977        $attachment = array(
    978978            'post_title'     => $filename,
  • trunk/src/wp-admin/includes/class-file-upload-upgrader.php

    r47122 r53183  
    7272            $this->package  = $file['file'];
    7373
    74             // Construct the object array.
    75             $object = array(
     74            // Construct the attachment array.
     75            $attachment = array(
    7676                'post_title'     => $this->filename,
    7777                'post_content'   => $file['url'],
     
    8383
    8484            // Save the data.
    85             $this->id = wp_insert_attachment( $object, $file['file'] );
     85            $this->id = wp_insert_attachment( $attachment, $file['file'] );
    8686
    8787            // Schedule a cleanup for 2 hours from now in case of failed installation.
  • trunk/src/wp-admin/includes/import.php

    r49936 r53183  
    104104    }
    105105
    106     // Construct the object array.
    107     $object = array(
     106    // Construct the attachment array.
     107    $attachment = array(
    108108        'post_title'     => wp_basename( $upload['file'] ),
    109109        'post_content'   => $upload['url'],
     
    115115
    116116    // Save the data.
    117     $id = wp_insert_attachment( $object, $upload['file'] );
     117    $id = wp_insert_attachment( $attachment, $upload['file'] );
    118118
    119119    /*
Note: See TracChangeset for help on using the changeset viewer.