From d4d709856b6ffb78ecaed3b24ee08898c35eaaa2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 5 Jun 2020 08:28:42 +0000 Subject: [PATCH] Docs: Update the DocBlock for the `wp_media_attach_action` hook per the documentation standards. Rename the `$att_id` variable to `$attachment_id` for clarity. Follow-up to [47909]. See #49614. git-svn-id: https://develop.svn.wordpress.org/trunk@47913 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 26 +++++++++---------- .../tests/rest-api/rest-controller.php | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 35080275ed..8d0e4089dc 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -3683,7 +3683,7 @@ function wp_get_media_creation_timestamp( $metadata ) { } /** - * Encapsulate logic for Attach/Detach actions + * Encapsulates the logic for Attach/Detach actions. * * @since 4.2.0 * @@ -3706,14 +3706,14 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) { $ids = array(); - foreach ( (array) $_REQUEST['media'] as $att_id ) { - $att_id = (int) $att_id; + foreach ( (array) $_REQUEST['media'] as $attachment_id ) { + $attachment_id = (int) $attachment_id; - if ( ! current_user_can( 'edit_post', $att_id ) ) { + if ( ! current_user_can( 'edit_post', $attachment_id ) ) { continue; } - $ids[] = $att_id; + $ids[] = $attachment_id; } if ( ! empty( $ids ) ) { @@ -3727,19 +3727,19 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) { } if ( isset( $result ) ) { - foreach ( $ids as $att_id ) { + foreach ( $ids as $attachment_id ) { /** - * Fires when media is attached/detached from a post. + * Fires when media is attached or detached from a post. * - * @since 5.5 + * @since 5.5.0 * - * @param string $action Attach/detach action. - * @param int $att_id The attachment ID. - * @param int $parent_id Attachment parent ID. + * @param string $action Attach/detach action. Accepts 'attach' or 'detach'. + * @param int $attachment_id The attachment ID. + * @param int $parent_id Attachment parent ID. */ - do_action( 'wp_media_attach_action', $action, $att_id, $parent_id ); + do_action( 'wp_media_attach_action', $action, $attachment_id, $parent_id ); - clean_attachment_cache( $att_id ); + clean_attachment_cache( $attachment_id ); } $location = 'upload.php'; diff --git a/tests/phpunit/tests/rest-api/rest-controller.php b/tests/phpunit/tests/rest-api/rest-controller.php index cb29822d97..887cb8f76e 100644 --- a/tests/phpunit/tests/rest-api/rest-controller.php +++ b/tests/phpunit/tests/rest-api/rest-controller.php @@ -269,13 +269,13 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $this->assertArrayHasKey( $property, $args['someobject'] ); } - // ignored properties + // Ignored properties. $this->assertArrayNotHasKey( 'ignored_prop', $args['someobject'] ); } /** - * @dataProvider data_get_fields_for_response, + * @dataProvider data_get_fields_for_response */ public function test_get_fields_for_response( $param, $expected ) { $controller = new WP_REST_Test_Controller();