diff --git a/.distignore b/.distignore index b964b40c7..95b52fb02 100644 --- a/.distignore +++ b/.distignore @@ -6,6 +6,8 @@ .travis.yml behat.yml circle.yml +phpcs.xml.dist +phpunit.xml.dist bin/ features/ utils/ diff --git a/.gitignore b/.gitignore index ff4941991..bcf211b32 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ vendor/ *.tar.gz composer.lock *.log +phpunit.xml +phpcs.xml +.phpcs.xml diff --git a/composer.json b/composer.json index a9bdba1cb..317ed17d9 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^2.0.7" + "wp-cli/wp-cli-tests": "^2.1" }, "config": { "process-timeout": 7200, diff --git a/media-command.php b/media-command.php index f17d8aae5..f5c4e74da 100644 --- a/media-command.php +++ b/media-command.php @@ -4,16 +4,27 @@ return; } -$autoload = dirname( __FILE__ ) . '/vendor/autoload.php'; -if ( file_exists( $autoload ) ) { - require_once $autoload; +$wpcli_media_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +if ( file_exists( $wpcli_media_autoloader ) ) { + require_once $wpcli_media_autoloader; } -WP_CLI::add_command( 'media', 'Media_Command', array( - 'before_invoke' => function () { - if ( !wp_image_editor_supports() ) { - WP_CLI::error( 'No support for generating images found. ' . - 'Please install the Imagick or GD PHP extensions.' ); - } +/** + * Check for Imagick and GD extensions availability. + * + * @throws \WP_CLI\ExitException + */ +$wpcli_media_assert_image_editor_support = function () { + if ( ! wp_image_editor_supports() ) { + WP_CLI::error( + 'No support for generating images found. ' + . 'Please install the Imagick or GD PHP extensions.' + ); } -) ); +}; + +WP_CLI::add_command( + 'media', + 'Media_Command', + [ 'before_invoke' => $wpcli_media_assert_image_editor_support ] +); diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 000000000..75f665799 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,59 @@ + + + Custom ruleset for WP-CLI media-command + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */src/Media_Command\.php$ + + + diff --git a/src/Media_Command.php b/src/Media_Command.php index aca43c28a..f48f59575 100644 --- a/src/Media_Command.php +++ b/src/Media_Command.php @@ -99,10 +99,11 @@ class Media_Command extends WP_CLI_Command { * 3/3 Regenerated "large" thumbnail for "Sunburst Over River" (ID 756). * Success: Regenerated 3 of 3 images. */ - function regenerate( $args, $assoc_args = array() ) { - $assoc_args = wp_parse_args( $assoc_args, array( - 'image_size' => '', - ) ); + public function regenerate( $args, $assoc_args = array() ) { + $assoc_args = wp_parse_args( + $assoc_args, + [ 'image_size' => '' ] + ); $image_size = $assoc_args['image_size']; if ( $image_size && ! in_array( $image_size, get_intermediate_image_sizes(), true ) ) { @@ -117,8 +118,8 @@ function regenerate( $args, $assoc_args = array() ) { } } - $skip_delete = \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-delete' ); - $only_missing = \WP_CLI\Utils\get_flag_value( $assoc_args, 'only-missing' ); + $skip_delete = Utils\get_flag_value( $assoc_args, 'skip-delete' ); + $only_missing = Utils\get_flag_value( $assoc_args, 'only-missing' ); if ( $only_missing ) { $skip_delete = true; } @@ -128,31 +129,39 @@ function regenerate( $args, $assoc_args = array() ) { $mime_types[] = 'application/pdf'; } $query_args = array( - 'post_type' => 'attachment', - 'post__in' => $args, + 'post_type' => 'attachment', + 'post__in' => $args, 'post_mime_type' => $mime_types, - 'post_status' => 'any', - 'posts_per_page' => -1, - 'fields' => 'ids' + 'post_status' => 'any', + 'posts_per_page' => - 1, + 'fields' => 'ids', ); $images = new WP_Query( $query_args ); $count = $images->post_count; - if ( !$count ) { + if ( ! $count ) { WP_CLI::warning( 'No images found.' ); return; } - WP_CLI::log( sprintf( 'Found %1$d %2$s to regenerate.', $count, - _n( 'image', 'images', $count ) ) ); + WP_CLI::log( + sprintf( + 'Found %1$d %2$s to regenerate.', + $count, + _n( 'image', 'images', $count ) + ) + ); if ( $image_size ) { $image_size_filters = $this->add_image_size_filters( $image_size ); } - $number = $successes = $errors = $skips = 0; + $number = 0; + $successes = 0; + $errors = 0; + $skips = 0; foreach ( $images->posts as $id ) { $number++; if ( 0 === $number % self::WP_CLEAR_OBJECT_CACHE_INTERVAL ) { @@ -236,13 +245,16 @@ function regenerate( $args, $assoc_args = array() ) { * $ wp media import http://s.wordpress.org/style/images/wp-header-logo.png --porcelain | xargs -I {} wp post list --post__in={} --field=url --post_type=attachment * http://wordpress-develop.dev/wp-header-logo/ */ - function import( $args, $assoc_args = array() ) { - $assoc_args = wp_parse_args( $assoc_args, array( - 'title' => '', - 'caption' => '', - 'alt' => '', - 'desc' => '', - ) ); + public function import( $args, $assoc_args = array() ) { + $assoc_args = wp_parse_args( + $assoc_args, + array( + 'title' => '', + 'caption' => '', + 'alt' => '', + 'desc' => '', + ) + ); // Assume the most generic term $noun = 'item'; @@ -256,47 +268,54 @@ function import( $args, $assoc_args = array() ) { } if ( isset( $assoc_args['post_id'] ) ) { - if ( !get_post( $assoc_args['post_id'] ) ) { - WP_CLI::warning( "Invalid --post_id" ); + if ( ! get_post( $assoc_args['post_id'] ) ) { + WP_CLI::warning( 'Invalid --post_id' ); $assoc_args['post_id'] = false; } } else { $assoc_args['post_id'] = false; } - $number = $successes = $errors = 0; + $number = 0; + $successes = 0; + $errors = 0; foreach ( $args as $file ) { $number++; if ( 0 === $number % self::WP_CLEAR_OBJECT_CACHE_INTERVAL ) { Utils\wp_clear_object_cache(); } - $is_file_remote = parse_url( $file, PHP_URL_HOST ); - $orig_filename = $file; - $file_time = ''; + + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- parse_url will only be used in absence of wp_parse_url. + $is_file_remote = function_exists( 'wp_parse_url' ) ? wp_parse_url( $file, PHP_URL_HOST ) : parse_url( $file, PHP_URL_HOST ); + $orig_filename = $file; + $file_time = ''; if ( empty( $is_file_remote ) ) { - if ( !file_exists( $file ) ) { + if ( ! file_exists( $file ) ) { WP_CLI::warning( "Unable to import file '$file'. Reason: File doesn't exist." ); $errors++; continue; } - if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-copy' ) ) { + if ( Utils\get_flag_value( $assoc_args, 'skip-copy' ) ) { $tempfile = $file; } else { $tempfile = $this->make_copy( $file ); } $name = Utils\basename( $file ); - if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'preserve-filetime' ) ) { + if ( Utils\get_flag_value( $assoc_args, 'preserve-filetime' ) ) { $file_time = @filemtime( $file ); } } else { $tempfile = download_url( $file ); if ( is_wp_error( $tempfile ) ) { - WP_CLI::warning( sprintf( - "Unable to import file '%s'. Reason: %s", - $file, implode( ', ', $tempfile->get_error_messages() ) - ) ); + WP_CLI::warning( + sprintf( + "Unable to import file '%s'. Reason: %s", + $file, + implode( ', ', $tempfile->get_error_messages() ) + ) + ); $errors++; continue; } @@ -305,19 +324,19 @@ function import( $args, $assoc_args = array() ) { $file_array = array( 'tmp_name' => $tempfile, - 'name' => $name, + 'name' => $name, ); $post_array = array( - 'post_title' => $assoc_args['title'], + 'post_title' => $assoc_args['title'], 'post_excerpt' => $assoc_args['caption'], 'post_content' => $assoc_args['desc'], ); if ( ! empty( $file_time ) ) { - $post_array['post_date'] = gmdate( 'Y-m-d H:i:s', $file_time + ( $gmt_offset * HOUR_IN_SECONDS ) ); - $post_array['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $file_time ); - $post_array['post_modified'] = gmdate( 'Y-m-d H:i:s', $file_time + ( $gmt_offset * HOUR_IN_SECONDS ) ); + $post_array['post_date'] = gmdate( 'Y-m-d H:i:s', $file_time + ( $gmt_offset * HOUR_IN_SECONDS ) ); + $post_array['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $file_time ); + $post_array['post_modified'] = gmdate( 'Y-m-d H:i:s', $file_time + ( $gmt_offset * HOUR_IN_SECONDS ) ); $post_array['post_modified_gmt'] = gmdate( 'Y-m-d H:i:s', $file_time ); } @@ -343,17 +362,20 @@ function import( $args, $assoc_args = array() ) { $post_array['post_title'] = preg_replace( '/\.[^.]+$/', '', Utils\basename( $file ) ); } - if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-copy' ) ) { - $wp_filetype = wp_check_filetype( $file, null ); + if ( Utils\get_flag_value( $assoc_args, 'skip-copy' ) ) { + $wp_filetype = wp_check_filetype( $file, null ); $post_array['post_mime_type'] = $wp_filetype['type']; - $post_array['post_status'] = 'inherit'; + $post_array['post_status'] = 'inherit'; $success = wp_insert_attachment( $post_array, $file, $assoc_args['post_id'] ); if ( is_wp_error( $success ) ) { - WP_CLI::warning( sprintf( - "Unable to insert file '%s'. Reason: %s", - $orig_filename, implode( ', ', $success->get_error_messages() ) - ) ); + WP_CLI::warning( + sprintf( + "Unable to insert file '%s'. Reason: %s", + $orig_filename, + implode( ', ', $success->get_error_messages() ) + ) + ); $errors++; continue; } @@ -362,10 +384,13 @@ function import( $args, $assoc_args = array() ) { // Deletes the temporary file. $success = media_handle_sideload( $file_array, $assoc_args['post_id'], $assoc_args['title'], $post_array ); if ( is_wp_error( $success ) ) { - WP_CLI::warning( sprintf( - "Unable to import file '%s'. Reason: %s", - $orig_filename, implode( ', ', $success->get_error_messages() ) - ) ); + WP_CLI::warning( + sprintf( + "Unable to import file '%s'. Reason: %s", + $orig_filename, + implode( ', ', $success->get_error_messages() ) + ) + ); $errors++; continue; } @@ -377,24 +402,29 @@ function import( $args, $assoc_args = array() ) { } // Set as featured image, if --post_id and --featured_image are set - if ( $assoc_args['post_id'] && \WP_CLI\Utils\get_flag_value( $assoc_args, 'featured_image' ) ) { + if ( $assoc_args['post_id'] && Utils\get_flag_value( $assoc_args, 'featured_image' ) ) { update_post_meta( $assoc_args['post_id'], '_thumbnail_id', $success ); } $attachment_success_text = ''; if ( $assoc_args['post_id'] ) { $attachment_success_text = " and attached to post {$assoc_args['post_id']}"; - if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'featured_image' ) ) + if ( Utils\get_flag_value( $assoc_args, 'featured_image' ) ) { $attachment_success_text .= ' as featured image'; + } } - if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { + if ( Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { WP_CLI::line( $success ); } else { - WP_CLI::log( sprintf( - "Imported file '%s' as attachment ID %d%s.", - $orig_filename, $success, $attachment_success_text - ) ); + WP_CLI::log( + sprintf( + "Imported file '%s' as attachment ID %d%s.", + $orig_filename, + $success, + $attachment_success_text + ) + ); } $successes++; } @@ -458,74 +488,83 @@ public function image_size( $args, $assoc_args ) { $soft_ratio_text = 'N/A'; - $assoc_args = array_merge( array( - 'fields' => 'name,width,height,crop,ratio' - ), $assoc_args ); + $assoc_args = array_merge( + array( + 'fields' => 'name,width,height,crop,ratio', + ), + $assoc_args + ); $sizes = array( array( - 'name' => 'large', - 'width' => intval( get_option( 'large_size_w' ) ), - 'height' => intval( get_option( 'large_size_h' ) ), - 'crop' => false !== get_option( 'large_crop' ) ? 'hard' : 'soft', - 'ratio' => false !== get_option( 'large_crop' ) ? $this->get_ratio( intval( get_option( 'large_size_w' ) ), intval( get_option( 'large_size_h' ) ) ) : $soft_ratio_text, + 'name' => 'large', + 'width' => intval( get_option( 'large_size_w' ) ), + 'height' => intval( get_option( 'large_size_h' ) ), + 'crop' => false !== get_option( 'large_crop' ) ? 'hard' : 'soft', + 'ratio' => false !== get_option( 'large_crop' ) ? $this->get_ratio( intval( get_option( 'large_size_w' ) ), intval( get_option( 'large_size_h' ) ) ) : $soft_ratio_text, ), array( - 'name' => 'medium_large', - 'width' => intval( get_option( 'medium_large_size_w' ) ), - 'height' => intval( get_option( 'medium_large_size_h' ) ), - 'crop' => false !== get_option( 'medium_large_crop' ) ? 'hard' : 'soft', - 'ratio' => false !== get_option( 'medium_large_crop' ) ? $this->get_ratio( intval( get_option( 'medium_large_size_w' ) ), intval( get_option( 'medium_large_size_h' ) ) ) : $soft_ratio_text, + 'name' => 'medium_large', + 'width' => intval( get_option( 'medium_large_size_w' ) ), + 'height' => intval( get_option( 'medium_large_size_h' ) ), + 'crop' => false !== get_option( 'medium_large_crop' ) ? 'hard' : 'soft', + 'ratio' => false !== get_option( 'medium_large_crop' ) ? $this->get_ratio( intval( get_option( 'medium_large_size_w' ) ), intval( get_option( 'medium_large_size_h' ) ) ) : $soft_ratio_text, ), array( - 'name' => 'medium', - 'width' => intval( get_option( 'medium_size_w' ) ), - 'height' => intval( get_option( 'medium_size_h' ) ), - 'crop' => false !== get_option( 'medium_crop' ) ? 'hard' : 'soft', - 'ratio' => false !== get_option( 'medium_crop' ) ? $this->get_ratio( intval( get_option( 'medium_size_w' ) ), intval( get_option( 'medium_size_h' ) ) ) : $soft_ratio_text, + 'name' => 'medium', + 'width' => intval( get_option( 'medium_size_w' ) ), + 'height' => intval( get_option( 'medium_size_h' ) ), + 'crop' => false !== get_option( 'medium_crop' ) ? 'hard' : 'soft', + 'ratio' => false !== get_option( 'medium_crop' ) ? $this->get_ratio( intval( get_option( 'medium_size_w' ) ), intval( get_option( 'medium_size_h' ) ) ) : $soft_ratio_text, ), array( - 'name' => 'thumbnail', - 'width' => intval( get_option( 'thumbnail_size_w' ) ), - 'height' => intval( get_option( 'thumbnail_size_h' ) ), - 'crop' => false !== get_option( 'thumbnail_crop' ) ? 'hard' : 'soft', - 'ratio' => false !== get_option( 'thumbnail_crop' ) ? $this->get_ratio( intval( get_option( 'thumbnail_size_w' ) ), intval( get_option( 'thumbnail_size_h' ) ) ) : $soft_ratio_text, + 'name' => 'thumbnail', + 'width' => intval( get_option( 'thumbnail_size_w' ) ), + 'height' => intval( get_option( 'thumbnail_size_h' ) ), + 'crop' => false !== get_option( 'thumbnail_crop' ) ? 'hard' : 'soft', + 'ratio' => false !== get_option( 'thumbnail_crop' ) ? $this->get_ratio( intval( get_option( 'thumbnail_size_w' ) ), intval( get_option( 'thumbnail_size_h' ) ) ) : $soft_ratio_text, ), ); if ( is_array( $_wp_additional_image_sizes ) ) { - foreach( $_wp_additional_image_sizes as $size => $size_args ) { - $crop = filter_var( $size_args['crop'], FILTER_VALIDATE_BOOLEAN ); + foreach ( $_wp_additional_image_sizes as $size => $size_args ) { + $crop = filter_var( $size_args['crop'], FILTER_VALIDATE_BOOLEAN ); $sizes[] = array( - 'name' => $size, - 'width' => $size_args['width'], - 'height' => $size_args['height'], - 'crop' => empty( $crop ) || is_array( $size_args['crop'] ) ? 'soft' : 'hard', - 'ratio' => empty( $crop ) || is_array( $size_args['crop'] ) ? $soft_ratio_text : $this->get_ratio( $size_args['width'], $size_args['height'] ), + 'name' => $size, + 'width' => $size_args['width'], + 'height' => $size_args['height'], + 'crop' => empty( $crop ) || is_array( $size_args['crop'] ) ? 'soft' : 'hard', + 'ratio' => empty( $crop ) || is_array( $size_args['crop'] ) ? $soft_ratio_text : $this->get_ratio( $size_args['width'], $size_args['height'] ), ); } } - usort( $sizes, function( $a, $b ){ - if ( $a['width'] == $b['width'] ) { - return 0; + usort( + $sizes, + function( $a, $b ) { + if ( $a['width'] === $b['width'] ) { + return 0; + } + return ( $a['width'] < $b['width'] ) ? 1 : -1; } - return ( $a['width'] < $b['width'] ) ? 1 : -1; - }); - array_unshift( $sizes, array( - 'name' => 'full', - 'width' => '', - 'height' => '', - 'crop' => 'N/A', - 'ratio' => $soft_ratio_text, - ) ); + ); + array_unshift( + $sizes, + array( + 'name' => 'full', + 'width' => '', + 'height' => '', + 'crop' => 'N/A', + 'ratio' => $soft_ratio_text, + ) + ); WP_CLI\Utils\format_items( $assoc_args['format'], $sizes, explode( ',', $assoc_args['fields'] ) ); } private function get_ratio( $width, $height ) { - if ( $height == 0 ) { + if ( 0 === $height ) { return "0:{$width}"; } - if ( $width == 0 ) { + if ( 0 === $width ) { return "{$height}:0"; } @@ -536,8 +575,8 @@ private function get_ratio( $width, $height ) { return "{$width_ratio}:{$height_ratio}"; } - private function gcd($num1,$num2) { - while (0 !== $num2) { + private function gcd( $num1, $num2 ) { + while ( 0 !== $num2 ) { $t = $num1 % $num2; $num1 = $num2; $num2 = $t; @@ -547,14 +586,16 @@ private function gcd($num1,$num2) { // wp_tempnam() inexplicably forces a .tmp extension, which spoils MIME type detection private function make_copy( $path ) { - $dir = get_temp_dir(); + $dir = get_temp_dir(); $filename = Utils\basename( $path ); - if ( empty( $filename ) ) + if ( empty( $filename ) ) { $filename = time(); + } $filename = $dir . wp_unique_filename( $dir, $filename ); - if ( !copy( $path, $filename ) ) + if ( ! copy( $path, $filename ) ) { WP_CLI::error( "Could not create temporary file for $path." ); + } return $filename; } @@ -577,7 +618,7 @@ private function process_regeneration( $id, $skip_delete, $only_missing, $image_ $fullsizepath = get_attached_file( $id ); - if ( false === $fullsizepath || !file_exists( $fullsizepath ) ) { + if ( false === $fullsizepath || ! file_exists( $fullsizepath ) ) { WP_CLI::warning( "Can't find $att_desc." ); $errors++; return; @@ -647,11 +688,13 @@ private function remove_old_images( $metadata, $fullsizepath, $image_size ) { foreach ( $metadata['sizes'] as $size_info ) { $intermediate_path = $dir_path . $size_info['file']; - if ( $intermediate_path === $fullsizepath ) + if ( $intermediate_path === $fullsizepath ) { continue; + } - if ( file_exists( $intermediate_path ) ) + if ( file_exists( $intermediate_path ) ) { unlink( $intermediate_path ); + } } } @@ -661,7 +704,7 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz $skip_it = false; // Note: zero-length string returned if no metadata, for instance if PDF or non-standard image (eg an SVG). - $metadata = wp_get_attachment_metadata($att_id); + $metadata = wp_get_attachment_metadata( $att_id ); $image_sizes = $this->get_intermediate_image_sizes_for_attachment( $fullsizepath, $is_pdf, $metadata ); @@ -715,11 +758,12 @@ private function needs_regeneration( $att_id, $fullsizepath, $is_pdf, $image_siz $dir_path = dirname( $fullsizepath ) . '/'; // Check that the thumbnail files exist. - foreach( $metadata['sizes'] as $size_info ) { + foreach ( $metadata['sizes'] as $size_info ) { $intermediate_path = $dir_path . $size_info['file']; - if ( $intermediate_path === $fullsizepath ) + if ( $intermediate_path === $fullsizepath ) { continue; + } if ( ! file_exists( $intermediate_path ) ) { return true; @@ -752,7 +796,8 @@ private function get_intermediate_image_sizes_for_attachment( $fullsizepath, $is if ( is_wp_error( $editor ) ) { return $editor; } - if ( is_wp_error( $result = $editor->load() ) ) { + $result = $editor->load(); + if ( is_wp_error( $result ) ) { unset( $editor ); return $result; } @@ -762,9 +807,13 @@ private function get_intermediate_image_sizes_for_attachment( $fullsizepath, $is $sizes = array(); foreach ( $this->get_intermediate_sizes( $is_pdf, $metadata ) as $name => $size ) { // Need to check destination and original width or height differ before calling image_resize_dimensions(), otherwise it will return non-false. - if ( ( $width !== $size['width'] || $height !== $size['height'] ) && ( $dims = image_resize_dimensions( $width, $height, $size['width'], $size['height'], $size['crop'] ) ) ) { + $dims = image_resize_dimensions( $width, $height, $size['width'], $size['height'], $size['crop'] ); + if ( ( $width !== $size['width'] || $height !== $size['height'] ) && $dims ) { list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; - $sizes[ $name ] = array( 'width' => $dst_w, 'height' => $dst_h ); + $sizes[ $name ] = array( + 'width' => $dst_w, + 'height' => $dst_h, + ); } } return $sizes; @@ -779,6 +828,7 @@ private function get_intermediate_sizes( $is_pdf, $metadata ) { 'medium', 'large', ); + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Calling native WordPress hook. $intermediate_image_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata ); } else { $intermediate_image_sizes = get_intermediate_image_sizes(); @@ -792,11 +842,11 @@ private function get_intermediate_sizes( $is_pdf, $metadata ) { // For WP < 4.7.0. global $_wp_additional_image_sizes; if ( ! $_wp_additional_image_sizes ) { + // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Used as a fallback for WordPress version less than 4.7.0 as function wp_get_additional_image_sizes didn't exist then. $_wp_additional_image_sizes = array(); } } - $sizes = array(); foreach ( $intermediate_image_sizes as $s ) { if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) { @@ -825,6 +875,7 @@ private function get_intermediate_sizes( $is_pdf, $metadata ) { // Check here that not PDF (as filter not applied in core if is) and `$metadata` is array (as may not be and filter only applied in core when is). if ( ! $is_pdf && is_array( $metadata ) ) { + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Calling native WordPress hook. $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes, $metadata ); }