Media: Rename several attachment related parameters from `$post_id` to `$attachment_id` for clarity, and improve related

documentation.

See #41017

Built from https://develop.svn.wordpress.org/trunk@41288


git-svn-id: http://core.svn.wordpress.org/trunk@41128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2017-08-22 11:12:44 +00:00
parent c080c0a2ea
commit 9891448a42
6 changed files with 42 additions and 40 deletions

View File

@ -231,14 +231,13 @@ function wp_image_editor($post_id, $msg = false) {
/**
* Streams image in WP_Image_Editor to browser.
* Provided for backcompat reasons
*
* @param WP_Image_Editor $image
* @param string $mime_type
* @param int $post_id
* @return bool
* @param WP_Image_Editor $image The image editor instance.
* @param string $mime_type The mime type of the image.
* @param int $attachment_id The image's attachment post ID.
* @return bool True on success, false on failure.
*/
function wp_stream_image( $image, $mime_type, $post_id ) {
function wp_stream_image( $image, $mime_type, $attachment_id ) {
if ( $image instanceof WP_Image_Editor ) {
/**
@ -246,10 +245,10 @@ function wp_stream_image( $image, $mime_type, $post_id ) {
*
* @since 3.5.0
*
* @param WP_Image_Editor $image WP_Image_Editor instance.
* @param int $post_id Post ID.
* @param WP_Image_Editor $image The image editor instance.
* @param int $attachment_id The attachment post ID.
*/
$image = apply_filters( 'image_editor_save_pre', $image, $post_id );
$image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );
if ( is_wp_error( $image->stream( $mime_type ) ) )
return false;
@ -265,9 +264,9 @@ function wp_stream_image( $image, $mime_type, $post_id ) {
* @deprecated 3.5.0 Use image_editor_save_pre instead.
*
* @param resource $image Image resource to be streamed.
* @param int $post_id Post ID.
* @param int $attachment_id The attachment post ID.
*/
$image = apply_filters( 'image_save_pre', $image, $post_id );
$image = apply_filters( 'image_save_pre', $image, $attachment_id );
switch ( $mime_type ) {
case 'image/jpeg':

View File

@ -429,8 +429,8 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
*
* @since 3.5.0
*
* @param string $mime_type
* @return bool
* @param string $mime_type The mime type of the image.
* @return bool True on success, false on failure.
*/
public function stream( $mime_type = null ) {
list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );

View File

@ -652,8 +652,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
*
* @since 3.5.0
*
* @param string $mime_type
* @return true|WP_Error
* @param string $mime_type The mime type of the image.
* @return bool|WP_Error True on success, WP_Error object on failure.
*/
public function stream( $mime_type = null ) {
list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );

View File

@ -164,8 +164,8 @@ abstract class WP_Image_Editor {
* @since 3.5.0
* @abstract
*
* @param string $mime_type
* @return bool|WP_Error
* @param string $mime_type The mime type of the image.
* @return bool|WP_Error True on success, WP_Error object or false on failure.
*/
abstract public function stream( $mime_type = null );

View File

@ -4963,14 +4963,15 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
*
* @since 2.1.0
*
* @param int $post_id Attachment ID. Default 0.
* @param int $attachment_id Attachment post ID. Defaults to global $post.
* @param bool $unfiltered Optional. If true, filters are not run. Default false.
* @return mixed Attachment meta field. False on failure.
*/
function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
$post_id = (int) $post_id;
if ( !$post = get_post( $post_id ) )
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
$attachment_id = (int) $attachment_id;
if ( ! $post = get_post( $attachment_id ) ) {
return false;
}
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
@ -4984,7 +4985,7 @@ function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
*
* @param array|bool $data Array of meta data for the given attachment, or false
* if the object does not exist.
* @param int $post_id Attachment ID.
* @param int $attachment_id Attachment post ID.
*/
return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
}
@ -4994,14 +4995,15 @@ function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
*
* @since 2.1.0
*
* @param int $post_id Attachment ID.
* @param array $data Attachment data.
* @param int $attachment_id Attachment post ID.
* @param array $data Attachment meta data.
* @return int|bool False if $post is invalid.
*/
function wp_update_attachment_metadata( $post_id, $data ) {
$post_id = (int) $post_id;
if ( !$post = get_post( $post_id ) )
function wp_update_attachment_metadata( $attachment_id, $data ) {
$attachment_id = (int) $attachment_id;
if ( ! $post = get_post( $attachment_id ) ) {
return false;
}
/**
* Filters the updated attachment meta data.
@ -5009,7 +5011,7 @@ function wp_update_attachment_metadata( $post_id, $data ) {
* @since 2.1.0
*
* @param array $data Array of updated attachment meta data.
* @param int $post_id Attachment ID.
* @param int $attachment_id Attachment post ID.
*/
if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
@ -5024,13 +5026,14 @@ function wp_update_attachment_metadata( $post_id, $data ) {
*
* @global string $pagenow
*
* @param int $post_id Optional. Attachment ID. Default 0.
* @param int $attachment_id Optional. Attachment post ID. Defaults to global $post.
* @return string|false Attachment URL, otherwise false.
*/
function wp_get_attachment_url( $post_id = 0 ) {
$post_id = (int) $post_id;
if ( !$post = get_post( $post_id ) )
function wp_get_attachment_url( $attachment_id = 0 ) {
$attachment_id = (int) $attachment_id;
if ( ! $post = get_post( $attachment_id ) ) {
return false;
}
if ( 'attachment' != $post->post_type )
return false;
@ -5073,7 +5076,7 @@ function wp_get_attachment_url( $post_id = 0 ) {
* @since 2.1.0
*
* @param string $url URL for the given attachment.
* @param int $post_id Attachment ID.
* @param int $attachment_id Attachment post ID.
*/
$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41287';
$wp_version = '4.9-alpha-41288';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.