Skip to content

Commit 1aab8fa

Browse files
Address review feedback
1 parent 85fa07b commit 1aab8fa

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

admin/load.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ function perflab_get_modules( $modules_root = null ) {
254254
$modules = array();
255255
$module_files = array();
256256
// PHPCS ignore reason: A modules directory is always present.
257-
$modules_dir = @opendir( $modules_root ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
257+
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
258+
$modules_dir = @opendir( $modules_root );
258259

259260
// Modules are organized as {focus}/{module-slug} in the modules folder.
260261
if ( $modules_dir ) {
@@ -270,7 +271,8 @@ function perflab_get_modules( $modules_root = null ) {
270271
}
271272

272273
// PHPCS ignore reason: Only the focus area directory is allowed.
273-
$focus_dir = @opendir( $modules_root . '/' . $focus ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
274+
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
275+
$focus_dir = @opendir( $modules_root . '/' . $focus );
274276
if ( $focus_dir ) {
275277
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
276278
while ( ( $file = readdir( $focus_dir ) ) !== false ) {
@@ -280,7 +282,8 @@ function perflab_get_modules( $modules_root = null ) {
280282
}
281283

282284
// PHPCS ignore reason: Only the module directory is allowed.
283-
$module_dir = @opendir( $modules_root . '/' . $focus . '/' . $file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
285+
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
286+
$module_dir = @opendir( $modules_root . '/' . $focus . '/' . $file );
284287
if ( $module_dir ) {
285288
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
286289
while ( ( $subfile = readdir( $module_dir ) ) !== false ) {

modules/images/dominant-color/hooks.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ function dominant_color_filter_content_tags( $content, $context = null ) {
236236
*/
237237
function dominant_color_add_inline_style() {
238238
$handle = 'dominant-color-styles';
239-
// PHPCS ignore reason: Dominant color add single line inline style that does not change frequently,
240-
// so the version number is not used.
241-
wp_register_style( $handle, false ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
239+
// PHPCS ignore reason: Version not used since this handle is only registered for adding an inline style.
240+
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
241+
wp_register_style( $handle, false );
242242
wp_enqueue_style( $handle );
243243
$custom_css = 'img[data-dominant-color]:not(.has-transparency) { background-color: var(--dominant-color); }';
244244
wp_add_inline_style( $handle, $custom_css );

modules/images/webp-uploads/hooks.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ function webp_uploads_wp_get_missing_image_subsizes( $missing_sizes, $image_meta
242242
* @see wp_update_image_subsizes()
243243
* @see wp_get_missing_image_subsizes()
244244
*/
245-
$trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 10 ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
245+
// PHPCS ignore reason: Only the way to generate missing image subsize if all core sub-sizes have been generated.
246+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
247+
$trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 10 );
246248

247249
foreach ( $trace as $element ) {
248250
if ( isset( $element['function'] ) && 'wp_update_image_subsizes' === $element['function'] ) {

modules/images/webp-uploads/image-edit.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ function ( $metadata, $post_meta_id ) use ( $post_id, $file_path, $mime_type, $e
120120

121121
$old_metadata = wp_get_attachment_metadata( $post_id );
122122
$resize_sizes = array();
123-
// PHPCS ignore reason: A nonce check is not necessary here as this logic directly ties in with WordPress core logic which already has one.
124-
$target = isset( $_REQUEST['target'] ) ? sanitize_key( $_REQUEST['target'] ) : 'all'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
123+
// PHPCS ignore reason: A nonce check is not necessary here as this logic directly ties in with WordPress core
124+
// function `wp_ajax_image_editor()` which already has one.
125+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
126+
$target = isset( $_REQUEST['target'] ) ? sanitize_key( $_REQUEST['target'] ) : 'all';
125127

126128
foreach ( $old_metadata['sizes'] as $size_name => $size_details ) {
127129
// If the target is 'nothumb', skip generating the 'thumbnail' size.
@@ -238,7 +240,9 @@ function ( $metadata, $post_meta_id ) use ( $post_id, $file_path, $mime_type, $e
238240
* @return array The updated metadata for the attachment to be stored in the meta table.
239241
*/
240242
function webp_uploads_update_attachment_metadata( $data, $attachment_id ) {
241-
$trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 10 ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
243+
// PHPCS ignore reason: Update the attachment's metadata by either restoring or editing it.
244+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
245+
$trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 10 );
242246

243247
foreach ( $trace as $element ) {
244248
if ( ! isset( $element['function'] ) ) {
@@ -273,7 +277,10 @@ function webp_uploads_update_attachment_metadata( $data, $attachment_id ) {
273277
* @return array The updated metadata for the attachment.
274278
*/
275279
function webp_uploads_backup_sources( $attachment_id, $data ) {
276-
$target = isset( $_REQUEST['target'] ) ? sanitize_key( $_REQUEST['target'] ) : 'all'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
280+
// PHPCS ignore reason: A nonce check is not necessary here as this logic directly ties in with WordPress core
281+
// function `wp_ajax_image_editor()` which already has one.
282+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
283+
$target = isset( $_REQUEST['target'] ) ? sanitize_key( $_REQUEST['target'] ) : 'all';
277284

278285
// When an edit to an image is only applied to a thumbnail there's nothing we need to back up.
279286
if ( 'thumbnail' === $target ) {

0 commit comments

Comments
 (0)