From c9c11a2442cf92efb074317eba7e4f1b772a4ea3 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 12:40:40 +0600 Subject: [PATCH 01/22] fix: PHPCS security issues on Commission class --- includes/Commission.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/Commission.php b/includes/Commission.php index f0040530b4..1cdc9041cc 100644 --- a/includes/Commission.php +++ b/includes/Commission.php @@ -89,6 +89,7 @@ public function calculate_gateway_fee( $order_id ) { $net_amount = $vendor_earning - $gateway_fee; $net_amount = apply_filters( 'dokan_orders_vendor_net_amount', $net_amount, $vendor_earning, $gateway_fee, $tmp_order, $order ); + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update( $wpdb->dokan_orders, [ 'net_amount' => (float) $net_amount ], @@ -107,6 +108,7 @@ public function calculate_gateway_fee( $order_id ) { [ '%f' ], [ '%d', '%s' ] ); + // phpcs:enable $tmp_order->update_meta_data( 'dokan_gateway_fee', $gateway_fee ); $tmp_order->save(); @@ -735,12 +737,14 @@ public function get_earning_from_order_table( $order_id, $context = 'seller' ) { return $earning; } + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $result = $wpdb->get_row( $wpdb->prepare( "SELECT `net_amount`, `order_total` FROM {$wpdb->dokan_orders} WHERE `order_id` = %d", $order_id ) ); + // phpcs:enable if ( ! $result ) { return null; From b5e2c1ecab4b18d98df38b5e13beb8cb110e2c9d Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 12:41:20 +0600 Subject: [PATCH 02/22] fix: PHPCS security issues on Product function file --- includes/Product/functions.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/Product/functions.php b/includes/Product/functions.php index 8b2f44bdba..8c8a39c8af 100644 --- a/includes/Product/functions.php +++ b/includes/Product/functions.php @@ -189,7 +189,7 @@ function dokan_product_output_variations() { } } - $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private', 'pending')", $post->ID ) ) ); + $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private', 'pending')", $post->ID ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ); $variations_total_pages = ceil( $variations_count / $variations_per_page ); ?>
@@ -403,9 +403,8 @@ function dokan_search_seller_products( $term, $user_ids = false, $type = '', $in $query_args[] = $user_ids; } } - // phpcs:ignore WordPress.DB.PreparedSQL + // phpcs:disable WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $product_ids = $wpdb->get_col( - // phpcs:disable $wpdb->prepare( " SELECT DISTINCT posts.ID FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} postmeta ON posts.ID = postmeta.post_id @@ -425,8 +424,8 @@ function dokan_search_seller_products( $term, $user_ids = false, $type = '', $in ", $query_args ) - // phpcs:enable ); + // phpcs:enable if ( is_numeric( $term ) ) { $post_id = absint( $term ); From dff500320019232e4b8ec2ad5dc2c3fd2f44b47c Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 12:42:08 +0600 Subject: [PATCH 03/22] fix: PHPCS security issues on Dummy Data Importer class --- includes/DummyData/Importer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/DummyData/Importer.php b/includes/DummyData/Importer.php index a1260108d1..d897665996 100644 --- a/includes/DummyData/Importer.php +++ b/includes/DummyData/Importer.php @@ -332,6 +332,8 @@ public function delete_dummy_vendor_orders( $args ) { global $wpdb; + + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // Deleting orders from dokan orders table. $wpdb->delete( $wpdb->prefix . 'dokan_orders', @@ -352,5 +354,6 @@ public function delete_dummy_vendor_orders( $args ) { [ 'user_id' => $vendor_id ], [ '%d' ] ); + // phpcs:enable } } From 642a7600a14588423845718a920c7aedea0d7a9f Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 14:33:47 +0600 Subject: [PATCH 04/22] fix: PHPCS security issues on Tracker class --- includes/Tracker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/Tracker.php b/includes/Tracker.php index 6b8a000b0a..f98423f72d 100644 --- a/includes/Tracker.php +++ b/includes/Tracker.php @@ -65,7 +65,8 @@ function () { protected function get_order_count() { global $wpdb; - return (int) $wpdb->get_var( "SELECT count(id) FROM {$wpdb->prefix}dokan_orders WHERE order_status IN ('wc-completed', 'wc-processing', 'wc-on-hold', 'wc-refunded');" ); + return (int) $wpdb->get_var( "SELECT count(id) FROM {$wpdb->prefix}dokan_orders WHERE order_status IN ('wc-completed', 'wc-processing', 'wc-on-hold', 'wc-refunded');" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + } /** From 23644537c3e4c9c28983fe920eeabe2a0ffc8392 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 15:29:49 +0600 Subject: [PATCH 05/22] fix: PHPCS security issues on Withdraw Hooks class --- includes/Withdraw/Hooks.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/Withdraw/Hooks.php b/includes/Withdraw/Hooks.php index 23acb51a9c..6bcd5021dc 100644 --- a/includes/Withdraw/Hooks.php +++ b/includes/Withdraw/Hooks.php @@ -94,6 +94,7 @@ public function update_vendor_balance( $withdraw ) { return; } + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $balance_result = $wpdb->get_row( $wpdb->prepare( "select * from {$wpdb->dokan_vendor_balance} where trn_id = %d and trn_type = %s", @@ -129,6 +130,7 @@ public function update_vendor_balance( $withdraw ) { ] ); } + // phpcs:enable } /** From 467e91df95ae4a9f1d926475072eef67cd4b8d49 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 15:35:45 +0600 Subject: [PATCH 06/22] fix: PHPCS security issues on Withdraws class --- includes/Withdraw/Withdraws.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Withdraw/Withdraws.php b/includes/Withdraw/Withdraws.php index 1b0172d1d8..c452e90228 100644 --- a/includes/Withdraw/Withdraws.php +++ b/includes/Withdraw/Withdraws.php @@ -194,7 +194,7 @@ public function query() { $this->withdraws[] = new Withdraw( $withdraw ); } - $this->total = absint( $wpdb->get_var( 'SELECT FOUND_ROWS()' ) ); + $this->total = absint( $wpdb->get_var( 'SELECT FOUND_ROWS()' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching } return $this; From 21cd074c0260ae31678ef1aaac3e15c16990ca12 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 15:39:36 +0600 Subject: [PATCH 07/22] fix: PHPCS security issues on StoreController class --- includes/REST/StoreController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index d0e491e99f..e9f11fbb88 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -605,6 +605,7 @@ public function get_store_reviews( $request ) { public function get_total_review_count( $id, $post_type, $status ) { global $wpdb; + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $total = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) @@ -616,6 +617,7 @@ public function get_total_review_count( $id, $post_type, $status ) { $wpdb->posts.post_type=%s", $id, $status, $post_type ) ); + // phpcs:enable return intval( $total ); } From e1c9938f9de7325be5c3381f653bc87c3303c4b4 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 15:49:54 +0600 Subject: [PATCH 08/22] fix: PHPCS security issues on OrderControllerV2 class --- includes/REST/OrderControllerV2.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/REST/OrderControllerV2.php b/includes/REST/OrderControllerV2.php index ea8491d82e..1ee8757e67 100644 --- a/includes/REST/OrderControllerV2.php +++ b/includes/REST/OrderControllerV2.php @@ -130,6 +130,7 @@ public function get_order_downloads( $requests ) { $downloads = []; // TODO: Need to move this into a separate function. + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $download_permissions = $wpdb->get_results( $wpdb->prepare( " @@ -138,6 +139,7 @@ public function get_order_downloads( $requests ) { ", $requests->get_param( 'id' ) ) ); + // phpcs:enable foreach ( $download_permissions as $download ) { $product = wc_get_product( absint( $download->product_id ) ); From 711dab97cfb789761b8d54bb86d5cb8df2fa9702 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 15:52:23 +0600 Subject: [PATCH 09/22] fix: PHPCS security issues on Uninstaller class --- uninstall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.php b/uninstall.php index bb58687c96..d590ed88f5 100644 --- a/uninstall.php +++ b/uninstall.php @@ -48,7 +48,7 @@ public function __construct() { } // Delete Dokan related options - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '%dokan%' AND option_name NOT LIKE '{$wpdb->prefix}user_roles'" ); + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '%dokan%' AND option_name NOT LIKE '{$wpdb->prefix}user_roles'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // Clear any cached data that has been removed. wp_cache_flush(); From ee721bc9d230ea109d95ea675fce9b46f71c4048 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 17:38:21 +0600 Subject: [PATCH 10/22] fix: PHPCS security issues on Withdraw class --- includes/Withdraw/Withdraw.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/Withdraw/Withdraw.php b/includes/Withdraw/Withdraw.php index 9c818c6c29..5e6a0c9950 100644 --- a/includes/Withdraw/Withdraw.php +++ b/includes/Withdraw/Withdraw.php @@ -448,6 +448,7 @@ protected function create() { unset( $this->data['id'] ); + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery $inserted = $wpdb->insert( $wpdb->dokan_withdraw, [ @@ -462,6 +463,7 @@ protected function create() { ], [ '%d', '%s', '%s', '%d', '%s', '%s', '%s', '%s' ] ); + // phpcs:enable if ( $inserted !== 1 ) { return new WP_Error( 'dokan_withdraw_create_error', __( 'Could not create new withdraw', 'dokan-lite' ) ); @@ -493,6 +495,7 @@ protected function create() { protected function update() { global $wpdb; + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $updated = $wpdb->update( $wpdb->dokan_withdraw, [ @@ -508,6 +511,7 @@ protected function update() { [ '%d', '%s', '%s', '%d', '%s', '%s', '%s' ], [ '%d' ] ); + // phpcs:enable if ( $wpdb->last_error ) { return new WP_Error( 'dokan_withdraw_update_error', __( 'Could not update withdraw', 'dokan-lite' ) ); @@ -544,11 +548,13 @@ protected function update() { public function delete() { global $wpdb; + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $deleted = $wpdb->delete( $wpdb->dokan_withdraw, [ 'id' => $this->data['id'] ], [ '%d' ] ); + // phpcs:enable if ( ! $deleted ) { return new WP_Error( 'dokan_withdraw_delete_error', __( 'Could not delete withdraw', 'dokan-lite' ) ); From e1637b0cc3ef57417ee62f4863e844fe302d32df Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Fri, 10 May 2024 17:48:28 +0600 Subject: [PATCH 11/22] fix: PHPCS security issues on Withdraw Manager class --- includes/Withdraw/Manager.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/Withdraw/Manager.php b/includes/Withdraw/Manager.php index 0d87f8cc14..08fdc17a4a 100644 --- a/includes/Withdraw/Manager.php +++ b/includes/Withdraw/Manager.php @@ -97,6 +97,7 @@ public function is_valid_approval_request( $args ) { public function is_valid_cancellation_request( $args ) { global $wpdb; + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $result = $wpdb->get_row( $wpdb->prepare( "select * from {$wpdb->dokan_withdraw} where id = %d and status = %d", @@ -104,6 +105,7 @@ public function is_valid_cancellation_request( $args ) { $this->get_status_code( 'pending' ) ) ); + // phpcs:enable if ( ! empty( $result ) ) { // permission: vendor -> only own && shop_manager @@ -135,6 +137,7 @@ public function update_status( $id, $user_id, $status ) { // 1 -> active // 2 -> cancelled + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $updated = $wpdb->update( $wpdb->dokan_withdraw, [ @@ -152,6 +155,7 @@ public function update_status( $id, $user_id, $status ) { '%d', ] ); + // phpcs:enable if ( $updated !== 1 ) { return new WP_Error( 'dokan_withdraw_unable_to_update', __( 'Could not update withdraw status', 'dokan-lite' ) ); @@ -185,7 +189,7 @@ public function insert_withdraw( $args = [] ) { $format = [ '%d', '%f', '%s', '%d', '%s', '%s', '%s', '%s' ]; - $inserted = $wpdb->insert( $wpdb->dokan_withdraw, $data, $format ); + $inserted = $wpdb->insert( $wpdb->dokan_withdraw, $data, $format ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery if ( $inserted !== 1 ) { return new WP_Error( 'dokan_withdraw_unable_to_insert', __( 'Could not add new withdraw approval request.', 'dokan-lite' ) ); @@ -219,6 +223,7 @@ public function has_pending_request( $user_id ) { $wpdb->dokan_withdraw = $wpdb->prefix . 'dokan_withdraw'; + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $status = $wpdb->get_results( $wpdb->prepare( "SELECT id @@ -227,6 +232,7 @@ public function has_pending_request( $user_id ) { $user_id ) ); + // phpcs:enable if ( $status ) { return true; @@ -256,9 +262,11 @@ public function get_withdraw_requests( $user_id = '', $status = 0, $limit = 10, if ( false === $result ) { global $wpdb; if ( empty( $user_id ) ) { + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->dokan_withdraw} WHERE status = %d LIMIT %d, %d", $status, $offset, $limit ) ); } else { $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->dokan_withdraw} WHERE user_id = %d AND status = %d ORDER BY id DESC LIMIT %d, %d", $user_id, $status, $offset, $limit ) ); + //phpcs:enable } $result = array_map( @@ -398,12 +406,14 @@ public function get( $id ) { global $wpdb; if ( ! is_array( $id ) ) { + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $result = $wpdb->get_row( $wpdb->prepare( "select * from {$wpdb->dokan_withdraw} where id = %d", $id ), ARRAY_A ); + // phpcs:enable } else { $attributes = [ 'id' => '%d', @@ -522,6 +532,7 @@ public function get_user_withdraw_summary( $user_id = '' ) { $user_id = dokan_get_current_user_id(); } + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $results = $wpdb->get_row( $wpdb->prepare( "SELECT @@ -535,6 +546,7 @@ public function get_user_withdraw_summary( $user_id = '' ) { ), ARRAY_A ); + // phpcs:enable $summary = [ 'total' => ! empty( $results['total'] ) ? absint( $results['total'] ) : 0, From 34553698356f1f65968422e740c0f5c2df7b2ad0 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 11:45:10 +0600 Subject: [PATCH 12/22] Simplified some conditions in Product global functions file --- includes/Product/functions.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/includes/Product/functions.php b/includes/Product/functions.php index 8c8a39c8af..ce1a0dfdf3 100644 --- a/includes/Product/functions.php +++ b/includes/Product/functions.php @@ -38,10 +38,8 @@ function dokan_save_product( $args ) { if ( absint( $data['product_cat'] ) < 0 ) { return new WP_Error( 'no-category', __( 'Please select a category', 'dokan-lite' ) ); } - } else { - if ( ! isset( $data['product_cat'] ) && empty( $data['product_cat'] ) ) { - return new WP_Error( 'no-category', __( 'Please select at least one category', 'dokan-lite' ) ); - } + } elseif ( ! isset( $data['product_cat'] ) && empty( $data['product_cat'] ) ) { + return new WP_Error( 'no-category', __( 'Please select at least one category', 'dokan-lite' ) ); } } elseif ( empty( $data['chosen_product_cat'] ) ) { return new WP_Error( 'no-category', __( 'Please select a category', 'dokan-lite' ) ); @@ -89,10 +87,8 @@ function dokan_save_product( $args ) { if ( ! isset( $data['chosen_product_cat'] ) ) { if ( Helper::product_category_selection_is_single() ) { $cat_ids[] = $data['product_cat']; - } else { - if ( ! empty( $data['product_cat'] ) ) { - $cat_ids = array_map( 'absint', (array) $data['product_cat'] ); - } + } elseif ( ! empty( $data['product_cat'] ) ) { + $cat_ids = array_map( 'absint', (array) $data['product_cat'] ); } $post_data['categories'] = $cat_ids; } From 7629ff0dd69b857cd8e153bbb6facf42b4bf7c9c Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 12:00:24 +0600 Subject: [PATCH 13/22] fix: Some phpcs errors in Product global functions file --- includes/Product/functions.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/Product/functions.php b/includes/Product/functions.php index ce1a0dfdf3..5c3a0be3cf 100644 --- a/includes/Product/functions.php +++ b/includes/Product/functions.php @@ -401,8 +401,8 @@ function dokan_search_seller_products( $term, $user_ids = false, $type = '', $in } // phpcs:disable WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $product_ids = $wpdb->get_col( - $wpdb->prepare( " - SELECT DISTINCT posts.ID FROM {$wpdb->posts} posts + $wpdb->prepare( + "SELECT DISTINCT posts.ID FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} postmeta ON posts.ID = postmeta.post_id $type_join WHERE ( @@ -416,8 +416,7 @@ function dokan_search_seller_products( $term, $user_ids = false, $type = '', $in AND posts.post_status IN ('" . implode( "','", $post_statuses ) . "') $type_where $users_where - ORDER BY posts.post_parent ASC, posts.post_title ASC - ", + ORDER BY posts.post_parent ASC, posts.post_title ASC", $query_args ) ); From 7b70269633024eb6873ddbe1c8da3baf90037f1e Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 12:05:28 +0600 Subject: [PATCH 14/22] Fixed some phpcs issues on OrderControllerV2 class --- includes/REST/OrderControllerV2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/REST/OrderControllerV2.php b/includes/REST/OrderControllerV2.php index 1ee8757e67..505dc983f4 100644 --- a/includes/REST/OrderControllerV2.php +++ b/includes/REST/OrderControllerV2.php @@ -213,7 +213,7 @@ public function grant_order_downloads( $requests ) { $inserted_id = wc_downloadable_file_permission( $download_id, $product_id, $order ); if ( $inserted_id ) { - $file_counter ++; + $file_counter++; if ( $file->get_name() ) { $file_count = $file->get_name(); } else { From d344058f1cd792856b85792cf11496c8600a8274 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 12:13:28 +0600 Subject: [PATCH 15/22] Fixed some phpcs issues on Tracker class --- includes/Tracker.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/includes/Tracker.php b/includes/Tracker.php index f98423f72d..c6228de276 100644 --- a/includes/Tracker.php +++ b/includes/Tracker.php @@ -19,10 +19,10 @@ class Tracker { /** * Class constructor - * - * @return void + * @since 2.8.7 * + * @return void */ public function __construct() { $this->appsero_init_tracker_dokan(); @@ -30,10 +30,10 @@ public function __construct() { /** * Initialize the plugin tracker - * - * @return void + * @since 2.8.7 * + * @return void */ public function appsero_init_tracker_dokan() { $client = new \Appsero\Client( '559bcc0d-21b4-4b34-8317-3e072badf46d', 'Dokan Multivendor Marketplace', DOKAN_FILE ); @@ -66,18 +66,17 @@ protected function get_order_count() { global $wpdb; return (int) $wpdb->get_var( "SELECT count(id) FROM {$wpdb->prefix}dokan_orders WHERE order_status IN ('wc-completed', 'wc-processing', 'wc-on-hold', 'wc-refunded');" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching - } /** * Gets custom deactivation reasons * + * @since 3.0.15 + * * @param string[] $reasons * @param null|\AppSero\Client $client * * @return \array - * @since 3.0.15 - * */ public function get_custom_deactivation_reasons( $reasons, $client = null ) { // return if old version of appsero client is loaded, where corresponding hooks provides only one argument From 900c7be4ae58cd5e2f8083cf6bd9533279b82e4f Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 12:18:13 +0600 Subject: [PATCH 16/22] Fixed minor phpcs issues on Tracker class --- includes/Tracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Tracker.php b/includes/Tracker.php index c6228de276..17b42bb51d 100644 --- a/includes/Tracker.php +++ b/includes/Tracker.php @@ -72,7 +72,7 @@ protected function get_order_count() { * Gets custom deactivation reasons * * @since 3.0.15 - * + * * @param string[] $reasons * @param null|\AppSero\Client $client * From 105d7dd77c7df861ff35d9d13fb5ff1b70df7539 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Mon, 13 May 2024 12:31:04 +0600 Subject: [PATCH 17/22] Fixed some phpcs issues on uninstaller class --- uninstall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.php b/uninstall.php index d590ed88f5..6fed92df46 100644 --- a/uninstall.php +++ b/uninstall.php @@ -63,7 +63,7 @@ public function __construct() { * @return string[] */ private function get_dokan_capabilities() { - require_once dirname( __FILE__ ) . '/includes/functions.php'; + require_once __DIR__ . '/includes/functions.php'; $capabilities = []; foreach ( dokan_get_all_caps() as $cap ) { From dcd5f2f8b172afa45d6866c2c01e9f82cae1c0df Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 2 Jan 2025 12:24:49 +0600 Subject: [PATCH 18/22] fix: PHPCS issues in StoreController REST class --- includes/REST/StoreController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index 63a40a4cb1..96039c61b1 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -433,15 +433,15 @@ public function permission_check_for_manageable_part() { /** * Prepare links for the request. * - * @param \WC_Data $object Object data. + * @param \WC_Data $store Store object. * @param WP_REST_Request $request Request object. * * @return array Links for the given post. */ - protected function prepare_links( $object, $request ) { + protected function prepare_links( $store, $request ) { $links = [ 'self' => [ - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->base, $object['id'] ) ), + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->base, $store['id'] ) ), ], 'collection' => [ 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->base ) ), From 86d81fbd886408106cfbe367d866be673ce924fc Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 2 Jan 2025 12:56:11 +0600 Subject: [PATCH 19/22] fix: PHPCS issues in OrderControllerV2 REST class --- includes/REST/OrderControllerV2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/REST/OrderControllerV2.php b/includes/REST/OrderControllerV2.php index 505dc983f4..b9fc83856d 100644 --- a/includes/REST/OrderControllerV2.php +++ b/includes/REST/OrderControllerV2.php @@ -213,7 +213,7 @@ public function grant_order_downloads( $requests ) { $inserted_id = wc_downloadable_file_permission( $download_id, $product_id, $order ); if ( $inserted_id ) { - $file_counter++; + ++$file_counter; if ( $file->get_name() ) { $file_count = $file->get_name(); } else { From 2d57f2e0f80461924321851233981adea5b88663 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 2 Jan 2025 13:46:29 +0600 Subject: [PATCH 20/22] fix: PHPCS errors on functions.php file in Product directory --- includes/Product/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Product/functions.php b/includes/Product/functions.php index 5c3a0be3cf..70e50c8e8f 100644 --- a/includes/Product/functions.php +++ b/includes/Product/functions.php @@ -399,7 +399,7 @@ function dokan_search_seller_products( $term, $user_ids = false, $type = '', $in $query_args[] = $user_ids; } } - // phpcs:disable WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + // phpcs:disable WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.DirectDatabaseQuery.NoCaching $product_ids = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT posts.ID FROM {$wpdb->posts} posts From 303eeb5a6ea1ef2840d2390818b88fac0b315a5b Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 2 Jan 2025 14:41:42 +0600 Subject: [PATCH 21/22] fix: PHPCS errors on Importer class under DuppyData directory --- includes/DummyData/Importer.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/DummyData/Importer.php b/includes/DummyData/Importer.php index d897665996..c960321428 100644 --- a/includes/DummyData/Importer.php +++ b/includes/DummyData/Importer.php @@ -2,8 +2,8 @@ namespace WeDevs\Dokan\DummyData; -use \WP_Error; -use \WP_Query; +use WP_Error; +use WP_Query; /** * Include dependencies. @@ -166,7 +166,6 @@ private function formate_string_by_separator( $data = '', $separator = ',' ) { * @return array */ public function import() { - $index = 0; $update_existing = false; $data = array( 'imported' => array(), @@ -242,8 +241,6 @@ public function import() { ) ); } - - $index ++; } return $data; @@ -273,8 +270,8 @@ public function clear_all_dummy_data() { 'posts_per_page' => - 1, 'post_status' => 'any', 'fields' => 'ids', - 'meta_key' => 'dokan_dummy_data', - 'meta_value' => '1' + 'meta_key' => 'dokan_dummy_data', // phpcs:ignore + 'meta_value' => '1', // phpcs:ignore ]; $query = new WP_Query( $args ); @@ -324,7 +321,13 @@ public function delete_dummy_vendor_orders( $args ) { return; } - $orders = dokan()->order->all( [ 'seller_id' => $vendor_id, 'return' => 'objects' ] ); + $orders = dokan()->order->all( + [ + 'seller_id' => $vendor_id, + 'return' => 'objects', + ] + ); + // Deleting vendors orders. foreach ( $orders as $order ) { $order->delete( true ); @@ -332,7 +335,6 @@ public function delete_dummy_vendor_orders( $args ) { global $wpdb; - // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // Deleting orders from dokan orders table. $wpdb->delete( From 54dcc2e88792dc1fcfb82f27d9d3e3998950ba87 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 2 Jan 2025 14:47:06 +0600 Subject: [PATCH 22/22] Fix: Some code indentation --- includes/Tracker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Tracker.php b/includes/Tracker.php index 17b42bb51d..261d07b0c9 100644 --- a/includes/Tracker.php +++ b/includes/Tracker.php @@ -19,7 +19,7 @@ class Tracker { /** * Class constructor - + * * @since 2.8.7 * * @return void @@ -30,7 +30,7 @@ public function __construct() { /** * Initialize the plugin tracker - + * * @since 2.8.7 * * @return void