-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added commission settings sub-categories reset toggle. #2543
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,7 +111,7 @@ public function enqueue_scripts() { | |||||
wp_enqueue_script( | ||||||
'dokan-setup-wizard-commission', | ||||||
DOKAN_PLUGIN_ASSEST . '/js/dokan-setup-wizard-commission.js', | ||||||
array( 'jquery', 'dokan-vue-bootstrap', 'dokan-accounting' ), | ||||||
array( 'jquery', 'dokan-vue-bootstrap', 'dokan-accounting', 'dokan-sweetalert2' ), | ||||||
DOKAN_PLUGIN_VERSION, | ||||||
[ 'in_footer' => true ] | ||||||
); | ||||||
|
@@ -517,6 +517,8 @@ public function dokan_setup_commission() { | |||||
$additional_fee = isset( $options['additional_fee'] ) ? $options['additional_fee'] : 0; | ||||||
$commission_category_based_values = isset( $options['commission_category_based_values'] ) ? $options['commission_category_based_values'] : new stdClass(); | ||||||
$commission_type = ! empty( $options['commission_type'] ) ? $options['commission_type'] : 'fixed'; | ||||||
$reset_sub_category_when_edit_all_category = ! empty( $options['reset_sub_category_when_edit_all_category'] ) ? $options['reset_sub_category_when_edit_all_category'] : 'on'; | ||||||
$reset_sub_category = ! ( $reset_sub_category_when_edit_all_category === 'off' ); | ||||||
|
||||||
$args = apply_filters( | ||||||
'dokan_admin_setup_wizard_step_setup_selling_template_args', [ | ||||||
|
@@ -525,6 +527,7 @@ public function dokan_setup_commission() { | |||||
'additional_fee' => $additional_fee, | ||||||
'commission_category_based_values' => $commission_category_based_values, | ||||||
'dokanCommission' => dokan_commission_types(), | ||||||
'reset_sub_category' => $reset_sub_category, | ||||||
'setup_wizard' => $this, | ||||||
] | ||||||
); | ||||||
|
@@ -565,11 +568,12 @@ public function dokan_setup_commission_save() { | |||||
$dokan_commission_percentage = 0; | ||||||
} | ||||||
|
||||||
$options = get_option( 'dokan_selling', [] ); | ||||||
$options['commission_type'] = isset( $_POST['dokan_commission_type'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_commission_type'] ) ) : 'fixed'; | ||||||
$options['admin_percentage'] = $dokan_commission_percentage; | ||||||
$options['additional_fee'] = isset( $_POST['dokan_commission_flat'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_commission_flat'] ) ) : 0; | ||||||
$options['commission_category_based_values'] = isset( $_POST['dokan_commission_category_based'] ) ? wc_clean( json_decode( sanitize_text_field( wp_unslash( $_POST['dokan_commission_category_based'] ) ), true ) ) : []; | ||||||
$options = get_option( 'dokan_selling', [] ); | ||||||
$options['commission_type'] = isset( $_POST['dokan_commission_type'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_commission_type'] ) ) : 'fixed'; | ||||||
$options['admin_percentage'] = $dokan_commission_percentage; | ||||||
$options['additional_fee'] = isset( $_POST['dokan_commission_flat'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_commission_flat'] ) ) : 0; | ||||||
$options['commission_category_based_values'] = isset( $_POST['dokan_commission_category_based'] ) ? wc_clean( json_decode( sanitize_text_field( wp_unslash( $_POST['dokan_commission_category_based'] ) ), true ) ) : []; | ||||||
$options['reset_sub_category_when_edit_all_category'] = isset( $_POST['reset_sub_category'] ) && false === dokan_string_to_bool( $_POST['reset_sub_category'] ) ? 'off' : 'on'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanitize POST data before use. The - $options['reset_sub_category_when_edit_all_category'] = isset( $_POST['reset_sub_category'] ) && false === dokan_string_to_bool( $_POST['reset_sub_category'] ) ? 'off' : 'on';
+ $options['reset_sub_category_when_edit_all_category'] = isset( $_POST['reset_sub_category'] ) && false === dokan_string_to_bool( sanitize_text_field( wp_unslash( $_POST['reset_sub_category'] ) ) ) ? 'off' : 'on'; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Inspections[error] 576-576: Security issue: $_POST['reset_sub_category'] not unslashed and not sanitized before use |
||||||
|
||||||
update_option( 'dokan_selling', $options ); | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
vendorInfo
is undefined and needs proper declarationAfter thorough verification,
vendorInfo
is not defined in the component's:This confirms the original review comment. The use of an undefined
vendorInfo
in a callback could lead to runtime errors.Recommendations:
vendorInfo
in the component's data() if it's local state🔗 Analysis chain
Verify vendorInfo reference.
The
vendorInfo
object is referenced but not defined in the component's data or props. This could lead to runtime errors.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 190
Script:
Length of output: 1485
Script:
Length of output: 481