From 38a514041c017135e0c0bf75c641bdd71763ae2c Mon Sep 17 00:00:00 2001 From: Nurul Umbhiya Date: Mon, 1 Feb 2021 09:11:38 +0600 Subject: [PATCH 1/4] fix: fixes conflict with user frontend menu position --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index f90ec1f67e..1a4c623d74 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -7,7 +7,7 @@ * @return void */ function dokan_admin_menu_position() { - return apply_filters( 'dokan_menu_position', 55.4 ); + return apply_filters( 'dokan_menu_position', '55.4' ); } /** From 067ca44245fbf60aa451813e930b1402f6bfc0f3 Mon Sep 17 00:00:00 2001 From: Nurul Umbhiya Date: Fri, 12 Feb 2021 16:57:27 +0600 Subject: [PATCH 2/4] fix: fixes nonce checking for some functions (#1089) * fix: fixes nonce checking for some functions * fix: fixes dev reviews --- includes/Abstracts/DokanPromotion.php | 2 +- includes/Admin/LimitedTimePromotion.php | 2 +- includes/Admin/Settings.php | 4 +- includes/Admin/UserProfile.php | 21 ++++----- includes/Ajax.php | 18 +++----- includes/Dashboard/Templates/Orders.php | 8 +--- includes/Dashboard/Templates/Products.php | 54 +++++++++++------------ includes/Dashboard/Templates/Settings.php | 28 +++++++----- includes/Dashboard/Templates/Withdraw.php | 6 +-- includes/Product/Hooks.php | 2 +- includes/Registration.php | 32 +++++++------- includes/Vendor/SetupWizard.php | 28 ++++-------- includes/Vendor/UserSwitch.php | 2 +- includes/functions.php | 2 +- includes/wc-functions.php | 4 +- includes/wc-template.php | 2 +- 16 files changed, 100 insertions(+), 115 deletions(-) diff --git a/includes/Abstracts/DokanPromotion.php b/includes/Abstracts/DokanPromotion.php index 68f717e207..4c2f2acb24 100644 --- a/includes/Abstracts/DokanPromotion.php +++ b/includes/Abstracts/DokanPromotion.php @@ -186,7 +186,7 @@ public function dismiss_upgrade_promo() { wp_send_json_error( __( 'You have no permission to do that', 'dokan-lite' ) ); } - if ( ! wp_verify_nonce( $post_data['nonce'], 'dokan_admin' ) ) { + if ( ! isset( $post_data['nonce'] ) || ! wp_verify_nonce( sanitize_key( $post_data['nonce'] ), 'dokan_admin' ) ) { wp_send_json_error( __( 'Invalid nonce', 'dokan-lite' ) ); } diff --git a/includes/Admin/LimitedTimePromotion.php b/includes/Admin/LimitedTimePromotion.php index 1e222658b8..9498f05718 100644 --- a/includes/Admin/LimitedTimePromotion.php +++ b/includes/Admin/LimitedTimePromotion.php @@ -200,7 +200,7 @@ public function dismiss_limited_time_promo() { wp_send_json_error( __( 'You have no permission to do that', 'dokan-lite' ) ); } - if ( ! wp_verify_nonce( $post_data['nonce'], 'dokan_admin' ) ) { + if ( ! isset( $post_data['nonce'] ) || ! wp_verify_nonce( sanitize_key( $post_data['nonce'] ), 'dokan_admin' ) ) { wp_send_json_error( __( 'Invalid nonce', 'dokan-lite' ) ); } diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index d8ed82d68a..e9cb5041f7 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -68,7 +68,7 @@ public function get_settings_value() { $_post_data = wp_unslash( $_POST ); - if ( ! wp_verify_nonce( sanitize_text_field( $_post_data['nonce'] ), 'dokan_admin' ) ) { + if ( ! isset( $_post_data['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_post_data['nonce'] ), 'dokan_admin' ) ) { wp_send_json_error( __( 'Invalid nonce', 'dokan-lite' ) ); } @@ -96,7 +96,7 @@ public function save_settings_value() { $_post_data = wp_unslash( $_POST ); - if ( ! wp_verify_nonce( sanitize_text_field( $_post_data['nonce'] ), 'dokan_admin' ) ) { + if ( ! isset( $_post_data['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_post_data['nonce'] ), 'dokan_admin' ) ) { throw new DokanException( 'dokan_settings_invalid_nonce', __( 'Invalid nonce', 'dokan-lite' ), 403 ); } diff --git a/includes/Admin/UserProfile.php b/includes/Admin/UserProfile.php index 7c3c2fe2ab..4da3fa0775 100755 --- a/includes/Admin/UserProfile.php +++ b/includes/Admin/UserProfile.php @@ -26,8 +26,8 @@ public function __construct() { * * @return void */ - function enqueue_scripts( $page ) { - if ( in_array( $page, array( 'profile.php', 'user-edit.php' ) ) ) { + public function enqueue_scripts( $page ) { + if ( in_array( $page, array( 'profile.php', 'user-edit.php' ), true ) ) { wp_enqueue_media(); $admin_admin_script = array( @@ -52,7 +52,7 @@ function enqueue_scripts( $page ) { * * @return void|false */ - function add_meta_fields( $user ) { + public function add_meta_fields( $user ) { if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } @@ -81,7 +81,7 @@ function add_meta_fields( $user ) { $banner_width = dokan_get_option( 'store_banner_width', 'dokan_appearance', 625 ); $banner_height = dokan_get_option( 'store_banner_height', 'dokan_appearance', 300 ); - $admin_commission = ( 'flat' == $admin_commission_type ) ? wc_format_localized_price( $admin_commission ) : wc_format_localized_decimal( $admin_commission ); + $admin_commission = ( 'flat' === $admin_commission_type ) ? wc_format_localized_price( $admin_commission ) : wc_format_localized_decimal( $admin_commission ); $country_state = array( 'country' => array( @@ -119,6 +119,7 @@ function add_meta_fields( $user ) {

- +