From 23915768092af5acc9a9b404d33651774d3e7d69 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:27:55 -0500 Subject: [PATCH 01/17] Update Generic.Arrays.DisallowShortArraySyntax to the new name Universal.Arrays.DisallowShortArraySyntax --- phpcs.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a6c50822d..24957fb30 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -16,7 +16,7 @@ - + From 52a98054f8604e8cda35aa2fdb1a127b1296e3d8 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:41:11 -0500 Subject: [PATCH 02/17] Fixes for linter errors about PSR2.Classes.ClassDeclaration.CloseBraceAfterBody fixed with phpcbf. --- includes/API/Catalog/Product_Group/Products/Read/Request.php | 2 -- includes/API/Catalog/Product_Group/Products/Read/Response.php | 2 -- includes/API/Catalog/Product_Item/Find/Request.php | 2 -- includes/API/Catalog/Send_Item_Updates/Request.php | 2 -- includes/API/FBE/Configuration/Update/Request.php | 2 -- includes/API/Pixel/Events/Request.php | 2 -- includes/API/Traits/Idempotent_Request.php | 2 -- includes/API/Traits/Rate_Limited_Response.php | 2 -- includes/ExternalVersionUpdate/Update.php | 1 - includes/Framework/Api/Response.php | 1 - includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php | 1 - includes/Jobs/DeleteProductsFromFBCatalog.php | 1 - includes/Jobs/ResetAllProductsFBSettings.php | 1 - includes/ProductSync/ProductValidator.php | 1 - includes/Utilities/DebugTools.php | 1 - includes/fbwpml.php | 2 -- 16 files changed, 25 deletions(-) diff --git a/includes/API/Catalog/Product_Group/Products/Read/Request.php b/includes/API/Catalog/Product_Group/Products/Read/Request.php index 891208f1d..1e481f37b 100644 --- a/includes/API/Catalog/Product_Group/Products/Read/Request.php +++ b/includes/API/Catalog/Product_Group/Products/Read/Request.php @@ -54,6 +54,4 @@ public static function get_rate_limit_id() { return 'ads_management'; } - - } diff --git a/includes/API/Catalog/Product_Group/Products/Read/Response.php b/includes/API/Catalog/Product_Group/Products/Read/Response.php index f0ce1ef81..f179fc167 100644 --- a/includes/API/Catalog/Product_Group/Products/Read/Response.php +++ b/includes/API/Catalog/Product_Group/Products/Read/Response.php @@ -42,6 +42,4 @@ public function get_ids() { return $product_item_ids; } - - } diff --git a/includes/API/Catalog/Product_Item/Find/Request.php b/includes/API/Catalog/Product_Item/Find/Request.php index 20554aac6..7f772ad87 100644 --- a/includes/API/Catalog/Product_Item/Find/Request.php +++ b/includes/API/Catalog/Product_Item/Find/Request.php @@ -60,6 +60,4 @@ public function get_params() { return array( 'fields' => 'id,product_group{id}' ); } - - } diff --git a/includes/API/Catalog/Send_Item_Updates/Request.php b/includes/API/Catalog/Send_Item_Updates/Request.php index 7c1a63b3d..f45a45442 100644 --- a/includes/API/Catalog/Send_Item_Updates/Request.php +++ b/includes/API/Catalog/Send_Item_Updates/Request.php @@ -123,6 +123,4 @@ public function get_data() { 'item_type' => 'PRODUCT_ITEM', ); } - - } diff --git a/includes/API/FBE/Configuration/Update/Request.php b/includes/API/FBE/Configuration/Update/Request.php index a3c76af72..36cea944a 100644 --- a/includes/API/FBE/Configuration/Update/Request.php +++ b/includes/API/FBE/Configuration/Update/Request.php @@ -52,6 +52,4 @@ public function set_plugin_version( string $plugin_version ) { ), ); } - - } diff --git a/includes/API/Pixel/Events/Request.php b/includes/API/Pixel/Events/Request.php index d118227c6..1f14e983f 100644 --- a/includes/API/Pixel/Events/Request.php +++ b/includes/API/Pixel/Events/Request.php @@ -90,6 +90,4 @@ public function get_data() { */ return apply_filters( 'wc_facebook_api_pixel_event_request_data', $data, $this ); } - - } diff --git a/includes/API/Traits/Idempotent_Request.php b/includes/API/Traits/Idempotent_Request.php index b2ba013bc..55c342286 100644 --- a/includes/API/Traits/Idempotent_Request.php +++ b/includes/API/Traits/Idempotent_Request.php @@ -40,6 +40,4 @@ public function get_idempotency_key() { return $this->idempotency_key; } - - } diff --git a/includes/API/Traits/Rate_Limited_Response.php b/includes/API/Traits/Rate_Limited_Response.php index 7db269403..d1abaf2c9 100644 --- a/includes/API/Traits/Rate_Limited_Response.php +++ b/includes/API/Traits/Rate_Limited_Response.php @@ -118,6 +118,4 @@ public function get_rate_limit_estimated_time_to_regain_access( $headers ) { return ! empty( $usage_data['estimated_time_to_regain_access'] ) ? (int) $usage_data['estimated_time_to_regain_access'] : null; } - - } diff --git a/includes/ExternalVersionUpdate/Update.php b/includes/ExternalVersionUpdate/Update.php index 5202c0b8b..8d60d2362 100644 --- a/includes/ExternalVersionUpdate/Update.php +++ b/includes/ExternalVersionUpdate/Update.php @@ -101,5 +101,4 @@ public function send_new_version_to_facebook_server() { return false; } } - } diff --git a/includes/Framework/Api/Response.php b/includes/Framework/Api/Response.php index 046968b20..2841c14a0 100644 --- a/includes/Framework/Api/Response.php +++ b/includes/Framework/Api/Response.php @@ -30,5 +30,4 @@ public function to_string(); * @return string the request, safe for logging/displaying */ public function to_string_safe(); - } diff --git a/includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php b/includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php index 11d4632c2..cb9f7477e 100644 --- a/includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php +++ b/includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php @@ -57,5 +57,4 @@ public function clean_up_old_completed_options() { LIMIT 500" ); } - } diff --git a/includes/Jobs/DeleteProductsFromFBCatalog.php b/includes/Jobs/DeleteProductsFromFBCatalog.php index a6ab6c5f7..4341c3595 100644 --- a/includes/Jobs/DeleteProductsFromFBCatalog.php +++ b/includes/Jobs/DeleteProductsFromFBCatalog.php @@ -125,5 +125,4 @@ public function get_plugin_name(): string { public function get_batch_size(): int { return 25; } - } diff --git a/includes/Jobs/ResetAllProductsFBSettings.php b/includes/Jobs/ResetAllProductsFBSettings.php index dc9cffbff..93b6d51b7 100644 --- a/includes/Jobs/ResetAllProductsFBSettings.php +++ b/includes/Jobs/ResetAllProductsFBSettings.php @@ -116,5 +116,4 @@ public function get_plugin_name(): string { public function get_batch_size(): int { return 25; } - } diff --git a/includes/ProductSync/ProductValidator.php b/includes/ProductSync/ProductValidator.php index 15a37c297..c62ec6da7 100644 --- a/includes/ProductSync/ProductValidator.php +++ b/includes/ProductSync/ProductValidator.php @@ -443,5 +443,4 @@ protected function validate_variation_structure() { throw new ProductInvalidException( __( 'Too many attributes selected for product. Use 4 or less.', 'facebook-for-woocommerce' ) ); } } - } diff --git a/includes/Utilities/DebugTools.php b/includes/Utilities/DebugTools.php index 3e950e285..c156070c2 100644 --- a/includes/Utilities/DebugTools.php +++ b/includes/Utilities/DebugTools.php @@ -120,5 +120,4 @@ public function delete_all_products() { facebook_for_woocommerce()->job_manager->delete_all_products->queue_start(); return esc_html__( 'Delete products from Facebook catalog job started!', 'facebook-for-woocommerce' ); } - } diff --git a/includes/fbwpml.php b/includes/fbwpml.php index 0d6129f7c..25e17f569 100644 --- a/includes/fbwpml.php +++ b/includes/fbwpml.php @@ -189,6 +189,4 @@ class="button button-primary" Date: Thu, 25 Jul 2024 11:44:05 -0500 Subject: [PATCH 03/17] Fixes for linter errors about PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose fixed with phpcbf. --- includes/Admin/Enhanced_Catalog_Attribute_Fields.php | 1 - includes/Jobs/DeleteProductsFromFBCatalog.php | 1 - includes/Jobs/ResetAllProductsFBSettings.php | 1 - includes/Utilities/DebugTools.php | 3 --- 4 files changed, 6 deletions(-) diff --git a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php index 89deb9c14..a2c14e0d7 100644 --- a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php +++ b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php @@ -266,7 +266,6 @@ private function render_field( $attr_id, $attribute ) { // string $this->render_text_field( $attr_id, $attribute, $placeholder ); } - } private function render_select_field( $attr_id, $attribute ) { diff --git a/includes/Jobs/DeleteProductsFromFBCatalog.php b/includes/Jobs/DeleteProductsFromFBCatalog.php index 4341c3595..9bb314a71 100644 --- a/includes/Jobs/DeleteProductsFromFBCatalog.php +++ b/includes/Jobs/DeleteProductsFromFBCatalog.php @@ -57,7 +57,6 @@ protected function get_items_for_batch( int $batch_number, array $args ): array ); return array_map( 'intval', $products ); - } /** diff --git a/includes/Jobs/ResetAllProductsFBSettings.php b/includes/Jobs/ResetAllProductsFBSettings.php index 93b6d51b7..fda928bf3 100644 --- a/includes/Jobs/ResetAllProductsFBSettings.php +++ b/includes/Jobs/ResetAllProductsFBSettings.php @@ -57,7 +57,6 @@ protected function get_items_for_batch( int $batch_number, array $args ): array ); return array_map( 'intval', $products ); - } /** diff --git a/includes/Utilities/DebugTools.php b/includes/Utilities/DebugTools.php index c156070c2..19e80cdcd 100644 --- a/includes/Utilities/DebugTools.php +++ b/includes/Utilities/DebugTools.php @@ -78,7 +78,6 @@ public function clean_up_old_background_sync_options() { $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%wc_facebook_background_product_sync%'" ); return __( 'Background sync jobs have been deleted.', 'facebook-for-woocommerce' ); - } /** @@ -93,7 +92,6 @@ public function clear_facebook_settings() { facebook_for_woocommerce()->get_connection_handler()->disconnect(); return esc_html__( 'Cleared all Facebook settings!', 'facebook-for-woocommerce' ); - } /** @@ -106,7 +104,6 @@ public function clear_facebook_settings() { public function reset_all_product_fb_settings() { facebook_for_woocommerce()->job_manager->reset_all_product_fb_settings->queue_start(); return esc_html__( 'Reset products Facebook settings job started!', 'facebook-for-woocommerce' ); - } /** From 4487539c1b5af40d410d0045cb97a43410749a50 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:47:18 -0500 Subject: [PATCH 04/17] Fixes for linter errors about PSR12.Traits.UseDeclaration.MultipleImport fixed with phpcbf. --- includes/Jobs/DeleteProductsFromFBCatalog.php | 3 ++- includes/Jobs/ResetAllProductsFBSettings.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/Jobs/DeleteProductsFromFBCatalog.php b/includes/Jobs/DeleteProductsFromFBCatalog.php index 9bb314a71..f27f474a2 100644 --- a/includes/Jobs/DeleteProductsFromFBCatalog.php +++ b/includes/Jobs/DeleteProductsFromFBCatalog.php @@ -16,7 +16,8 @@ */ class DeleteProductsFromFBCatalog extends AbstractChainedJob { - use BatchQueryOffset, LoggingTrait; + use BatchQueryOffset; + use LoggingTrait; /** * Called before starting the job. diff --git a/includes/Jobs/ResetAllProductsFBSettings.php b/includes/Jobs/ResetAllProductsFBSettings.php index fda928bf3..9ddb4806f 100644 --- a/includes/Jobs/ResetAllProductsFBSettings.php +++ b/includes/Jobs/ResetAllProductsFBSettings.php @@ -16,7 +16,8 @@ */ class ResetAllProductsFBSettings extends AbstractChainedJob { - use BatchQueryOffset, LoggingTrait; + use BatchQueryOffset; + use LoggingTrait; /** * Called before starting the job. From 9170a07f01461711ac5d1c821417799148db5ea4 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:44:05 -0500 Subject: [PATCH 05/17] Add exclusion for WordPress.Security.EscapeOutput.ExceptionNotEscaped --- phpcs.xml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 24957fb30..238868d21 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -25,6 +25,9 @@ + + + From abe4be675d80915bc9d3ab134dd864757eaf33b1 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:47:51 -0500 Subject: [PATCH 06/17] Fix for linter error about Universal.ControlStructures.DisallowLonelyIf.Found fixed with phpcbf. --- includes/ProductSync/ProductValidator.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/ProductSync/ProductValidator.php b/includes/ProductSync/ProductValidator.php index c62ec6da7..e839ef6ca 100644 --- a/includes/ProductSync/ProductValidator.php +++ b/includes/ProductSync/ProductValidator.php @@ -347,10 +347,8 @@ protected function validate_product_sync_field() { // Variable product has no variations with sync enabled so it shouldn't be synced. throw $invalid_exception; - } else { - if ( 'no' === $this->product->get_meta( self::SYNC_ENABLED_META_KEY ) ) { + } elseif ( 'no' === $this->product->get_meta( self::SYNC_ENABLED_META_KEY ) ) { throw $invalid_exception; - } } } From c66936ebc10c402eabace8a5b687bfcd7a1dc841 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:52:17 -0500 Subject: [PATCH 07/17] Fixes for linter errors about Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound fixed with phpcbf. --- includes/API/Request.php | 2 +- includes/Admin/Settings.php | 2 +- includes/Framework/Utilities/BackgroundJobHandler.php | 4 ++-- includes/Products/Sync/Background.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/API/Request.php b/includes/API/Request.php index 398b8c780..d695f5b7e 100644 --- a/includes/API/Request.php +++ b/includes/API/Request.php @@ -81,7 +81,7 @@ public function get_retry_count() { * @since 2.1.0 */ public function mark_retry() { - $this->retry_count++; + ++$this->retry_count; } diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index 9e34b4aa9..932ef6bc8 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -362,7 +362,7 @@ private function register_woo_nav_menu_items() { 'order' => $order, ) ); - $order++; + ++$order; } } } diff --git a/includes/Framework/Utilities/BackgroundJobHandler.php b/includes/Framework/Utilities/BackgroundJobHandler.php index f1458e1ac..4e87d13f6 100644 --- a/includes/Framework/Utilities/BackgroundJobHandler.php +++ b/includes/Framework/Utilities/BackgroundJobHandler.php @@ -656,8 +656,8 @@ public function process_job( $job, $items_per_batch = null ) { // process the item $this->process_item( $item, $job ); - $processed++; - $job->progress++; + ++$processed; + ++$job->progress; // update job progress $job = $this->update_job( $job ); diff --git a/includes/Products/Sync/Background.php b/includes/Products/Sync/Background.php index ba8464e98..5b22317e4 100644 --- a/includes/Products/Sync/Background.php +++ b/includes/Products/Sync/Background.php @@ -118,8 +118,8 @@ public function process_items( $job, $data, $items_per_batch = null ) { facebook_for_woocommerce()->log( "Background sync error: {$e->getMessage()}" ); } - $processed++; - $job->progress++; + ++$processed; + ++$job->progress; // update job progress $job = $this->update_job( $job ); // job limits reached From 0d8ec272e9d939622f6e62e6b2ceb4350479c459 Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:54:10 -0500 Subject: [PATCH 08/17] Fixes for linter errors about Universal.CodeAnalysis.NoDoubleNegative.FoundDouble fixed with phpcbf. --- includes/API/FBE/Configuration/Read/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/API/FBE/Configuration/Read/Response.php b/includes/API/FBE/Configuration/Read/Response.php index 5e4884e45..76b7a617d 100644 --- a/includes/API/FBE/Configuration/Read/Response.php +++ b/includes/API/FBE/Configuration/Read/Response.php @@ -18,7 +18,7 @@ class Response extends API\Response { * @return boolean */ public function is_ig_shopping_enabled(): bool { - return ! ! $this->response_data['ig_shopping']['enabled'] ?? false; + return (bool) $this->response_data['ig_shopping']['enabled'] ?? false; } /** @@ -27,6 +27,6 @@ public function is_ig_shopping_enabled(): bool { * @return boolean */ public function is_ig_cta_enabled(): bool { - return ! ! $this->response_data['ig_cta']['enabled']; + return (bool) $this->response_data['ig_cta']['enabled']; } } From 690da103bff7529d6f43f35e6a0af29cf453fdce Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:57:34 -0500 Subject: [PATCH 09/17] Fixes for linter errors about Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction fixed with phpcbf. --- includes/Admin/Enhanced_Catalog_Attribute_Fields.php | 8 ++++---- includes/Admin/Product_Sets.php | 2 +- includes/Admin/Products.php | 2 +- includes/Admin/Settings.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php index a2c14e0d7..d50445214 100644 --- a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php +++ b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php @@ -89,20 +89,20 @@ private function extract_attribute( &$attributes, $key ) { public function render( $category_id ) { $all_attributes = $this->category_handler->get_attributes_with_fallback_to_parent_category( $category_id ); $all_attributes_with_values = array_map( - function( $attribute ) use ( $category_id ) { + function ( $attribute ) use ( $category_id ) { return array_merge( $attribute, array( 'value' => $this->get_value( $attribute['key'], $category_id ) ) ); }, $all_attributes ); $recommended_attributes = array_filter( $all_attributes_with_values, - function( $attr ) { + function ( $attr ) { return $attr['recommended']; } ); $optional_attributes = array_filter( $all_attributes_with_values, - function( $attr ) { + function ( $attr ) { return ! $attr['recommended']; } ); @@ -117,7 +117,7 @@ function( $attr ) { $this->extract_attribute( $optional_attributes, 'size' ), $this->extract_attribute( $optional_attributes, 'gender' ), ), - function( $attr ) { + function ( $attr ) { return ! is_null( $attr ); } ); diff --git a/includes/Admin/Product_Sets.php b/includes/Admin/Product_Sets.php index a01e88dd3..cca1b4ed3 100644 --- a/includes/Admin/Product_Sets.php +++ b/includes/Admin/Product_Sets.php @@ -118,7 +118,7 @@ public function save_custom_field( $term_id, $tt_id ) { $wc_product_cats = empty( $_POST[ $this->categories_field ] ) ? '' : wc_clean( wp_unslash( $_POST[ $this->categories_field ] ) ); //phpcs:ignore if ( ! empty( $wc_product_cats ) ) { $wc_product_cats = array_map( - function( $item ) { + function ( $item ) { return absint( $item ); }, $wc_product_cats diff --git a/includes/Admin/Products.php b/includes/Admin/Products.php index cb6fb662b..84dd92538 100644 --- a/includes/Admin/Products.php +++ b/includes/Admin/Products.php @@ -170,7 +170,7 @@ private static function filter_available_product_attribute_names( \WC_Product $p */ public static function get_available_product_attribute_names( \WC_Product $product ) { return array_map( - function( $attribute ) use ( $product ) { + function ( $attribute ) use ( $product ) { return wc_attribute_label( $attribute->get_name(), $product ); }, Products_Handler::get_available_product_attributes( $product ) diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index 932ef6bc8..1fa1294dc 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -302,7 +302,7 @@ public function get_screens() { // ensure no bogus values are added via filter $screens = array_filter( $screens, - function( $value ) { + function ( $value ) { return $value instanceof Abstract_Settings_Screen; } ); From e3b490b8b50a7fca2c62210037d084ed61009d1f Mon Sep 17 00:00:00 2001 From: Brezo Cordero <8002881+brezocordero@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:07:45 -0500 Subject: [PATCH 10/17] Fix for WordPress.WP.DeprecatedParameters.Get_termsParam2Found The parameter at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. --- includes/Admin/Product_Sets.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/Admin/Product_Sets.php b/includes/Admin/Product_Sets.php index cca1b4ed3..008d31329 100644 --- a/includes/Admin/Product_Sets.php +++ b/includes/Admin/Product_Sets.php @@ -149,7 +149,12 @@ protected function get_field_label() { */ protected function get_field( $term_id = '' ) { $saved_items = get_term_meta( $term_id, $this->categories_field, true ); - $product_cats = get_terms( 'product_cat', array( 'hide_empty' => 0 ) ); + $product_cats = get_terms( + array( + 'taxonomy' => 'product_cat', + 'hide_empty' => false, + ) + ); ?>