Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/media.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$return` parameter to `$return_type` in `media_sideload_image()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53192


git-svn-id: http://core.svn.wordpress.org/trunk@52781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-17 10:51:10 +00:00
parent 9998c01dca
commit 88cce3c705
2 changed files with 11 additions and 11 deletions

View File

@ -974,21 +974,21 @@ function wp_media_upload_handler() {
* Downloads an image from the specified URL, saves it as an attachment, and optionally attaches it to a post.
*
* @since 2.6.0
* @since 4.2.0 Introduced the `$return` parameter.
* @since 4.8.0 Introduced the 'id' option for the `$return` parameter.
* @since 4.2.0 Introduced the `$return_type` parameter.
* @since 4.8.0 Introduced the 'id' option for the `$return_type` parameter.
* @since 5.3.0 The `$post_id` parameter was made optional.
* @since 5.4.0 The original URL of the attachment is stored in the `_source_url`
* post meta value.
*
* @param string $file The URL of the image to download.
* @param int $post_id Optional. The post ID the media is to be associated with.
* @param string $desc Optional. Description of the image.
* @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL),
* or 'id' (attachment ID). Default 'html'.
* @param string $file The URL of the image to download.
* @param int $post_id Optional. The post ID the media is to be associated with.
* @param string $desc Optional. Description of the image.
* @param string $return_type Optional. Accepts 'html' (image tag html) or 'src' (URL),
* or 'id' (attachment ID). Default 'html'.
* @return string|int|WP_Error Populated HTML img tag, attachment ID, or attachment source
* on success, WP_Error object otherwise.
*/
function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) {
function media_sideload_image( $file, $post_id = 0, $desc = null, $return_type = 'html' ) {
if ( ! empty( $file ) ) {
$allowed_extensions = array( 'jpg', 'jpeg', 'jpe', 'png', 'gif', 'webp' );
@ -1043,7 +1043,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm
add_post_meta( $id, '_source_url', $file );
// If attachment ID was requested, return it.
if ( 'id' === $return ) {
if ( 'id' === $return_type ) {
return $id;
}
@ -1052,7 +1052,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm
// Finally, check to make sure the file has been saved, then return the HTML.
if ( ! empty( $src ) ) {
if ( 'src' === $return ) {
if ( 'src' === $return_type ) {
return $src;
}

View File

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