-
Notifications
You must be signed in to change notification settings - Fork 200
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
enhance: Implement vendor default banner, profile image & controls. #2275
base: develop
Are you sure you want to change the base?
Changes from all commits
744885e
16c4882
0e437d3
4bd3e1a
1aa7952
9c9f2d0
a0a86ed
6b7c0ca
b0fbae6
fb453f2
0d10f36
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 |
---|---|---|
|
@@ -131,7 +131,7 @@ | |
} | ||
|
||
// check if user have permission to view settings page | ||
if ( ! current_user_can( 'dokan_view_store_settings_menu' ) ) { | ||
Check warning on line 134 in includes/Dashboard/Templates/Settings.php GitHub Actions / Run PHPCS inspection
|
||
dokan_get_template_part( | ||
'global/dokan-error', '', [ | ||
'deleted' => false, | ||
|
@@ -161,12 +161,12 @@ | |
* @return void | ||
*/ | ||
public function load_store_content() { | ||
$currentuser = dokan_get_current_user_id(); | ||
$profile_info = dokan_get_store_info( dokan_get_current_user_id() ); | ||
$current_user = dokan_get_current_user_id(); | ||
$profile_info = dokan_get_store_info( $current_user ); | ||
|
||
dokan_get_template_part( | ||
'settings/store-form', '', [ | ||
'current_user' => $currentuser, | ||
'current_user' => $current_user, | ||
Comment on lines
+164
to
+169
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. Ensure proper sanitization and escaping of user data. The method |
||
'profile_info' => $profile_info, | ||
] | ||
); | ||
|
@@ -317,7 +317,7 @@ | |
|
||
switch ( sanitize_text_field( wp_unslash( $_POST['form_id'] ) ) ) { // phpcs:ignore | ||
case 'profile-form': | ||
if ( ! current_user_can( 'dokan_view_store_social_menu' ) ) { | ||
Check warning on line 320 in includes/Dashboard/Templates/Settings.php GitHub Actions / Run PHPCS inspection
|
||
wp_send_json_error( __( 'Pemission denied social', 'dokan-lite' ) ); | ||
} | ||
|
||
|
@@ -329,7 +329,7 @@ | |
break; | ||
|
||
case 'store-form': | ||
if ( ! current_user_can( 'dokan_view_store_settings_menu' ) ) { | ||
Check warning on line 332 in includes/Dashboard/Templates/Settings.php GitHub Actions / Run PHPCS inspection
|
||
wp_send_json_error( __( 'Pemission denied', 'dokan-lite' ) ); | ||
} | ||
|
||
|
@@ -341,7 +341,7 @@ | |
break; | ||
|
||
case 'payment-form': | ||
if ( ! current_user_can( 'dokan_view_store_payment_menu' ) ) { | ||
Check warning on line 344 in includes/Dashboard/Templates/Settings.php GitHub Actions / Run PHPCS inspection
|
||
wp_send_json_error( __( 'Pemission denied', 'dokan-lite' ) ); | ||
} | ||
|
||
|
@@ -563,8 +563,8 @@ | |
|
||
// Get & set 7 days opening & closing time for update dokan store time. | ||
foreach ( $dokan_days as $day_key => $day ) { | ||
$opening_time = isset( $_POST['opening_time'][ $day_key ] ) ? wc_clean( wp_unslash( $_POST['opening_time'][ $day_key ] ) ) : ''; | ||
$closing_time = isset( $_POST['closing_time'][ $day_key ] ) ? wc_clean( wp_unslash( $_POST['closing_time'][ $day_key ] ) ) : ''; | ||
$store_status = ! empty( $_POST[ $day_key ]['working_status'] ) ? sanitize_text_field( wp_unslash( $_POST[ $day_key ]['working_status'] ) ) : 'close'; | ||
|
||
// If open or closing time is array then return from here. | ||
|
@@ -609,11 +609,11 @@ | |
// Update store settings info. | ||
$dokan_settings = [ | ||
'store_name' => isset( $_POST['dokan_store_name'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_store_name'] ) ) : '', | ||
'address' => isset( $_POST['dokan_address'] ) ? wc_clean( wp_unslash( $_POST['dokan_address'] ) ) : $prev_dokan_settings['address'], | ||
'location' => $location, | ||
'find_address' => $find_address, | ||
'banner' => isset( $_POST['dokan_banner'] ) ? absint( $_POST['dokan_banner'] ) : 0, | ||
'phone' => isset( $_POST['setting_phone'] ) ? dokan_sanitize_phone_number( wp_unslash( $_POST['setting_phone'] ) ) : 'no', | ||
'show_email' => isset( $_POST['setting_show_email'] ) ? sanitize_text_field( wp_unslash( $_POST['setting_show_email'] ) ) : 'no', | ||
'gravatar' => isset( $_POST['dokan_gravatar'] ) ? absint( $_POST['dokan_gravatar'] ) : 0, | ||
'enable_tnc' => isset( $_POST['dokan_store_tnc_enable'] ) && 'on' === sanitize_text_field( wp_unslash( $_POST['dokan_store_tnc_enable'] ) ) ? 'on' : 'off', | ||
|
@@ -633,7 +633,7 @@ | |
]; | ||
|
||
if ( isset( $_POST['settings']['bank'] ) ) { | ||
$bank = wc_clean( wp_unslash( $_POST['settings']['bank'] ) ); | ||
|
||
$dokan_settings['payment']['bank'] = [ | ||
'ac_name' => $bank['ac_name'], | ||
|
@@ -821,7 +821,7 @@ | |
* | ||
* @return string | ||
*/ | ||
public function get_method_frontend_title( $title, $method ) { | ||
if ( 0 === stripos( $title, 'Dokan ' ) ) { | ||
return substr( $title, 6 ); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,6 +272,27 @@ | |
</div> | ||
</template> | ||
|
||
<template v-if="'croppable_image' === fieldData.type"> | ||
<div class="field_contents" v-bind:class="[fieldData.content_class ? fieldData.content_class : '']"> | ||
<fieldset> | ||
<FieldHeading :fieldData="fieldData"></FieldHeading> | ||
<div class="field add_files"> | ||
<label :style="{ maxWidth: fieldData.render_width + 'px' }" :for="sectionId + '[' + fieldData.name + ']'"> | ||
<UploadImage | ||
:croppingWidth="parseInt( croppingWidth )" | ||
:croppingHeight="parseInt( croppingHeight )" | ||
:src="fieldValue[fieldData.name]" | ||
@uploadedImage="uploadedImage" | ||
:showButton="false" /> | ||
</label> | ||
</div> | ||
</fieldset> | ||
<p v-if="hasError( fieldData.name )" class="dokan-error"> | ||
{{ getError( fieldData.label ) }} | ||
</p> | ||
</div> | ||
</template> | ||
Comment on lines
+275
to
+294
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. Add handling for missing or invalid image data in the The current implementation does not handle cases where the image data might be missing or invalid. It's important to ensure robustness by adding error handling for these scenarios. + if (!fieldValue[fieldData.name]) {
+ console.error('Invalid or missing image data');
+ return;
+ }
|
||
|
||
<template v-if="'color' === fieldData.type"> | ||
<div class="field_contents" v-bind:class="[fieldData.content_class ? fieldData.content_class : '']"> | ||
<fieldset> | ||
|
@@ -511,6 +532,7 @@ | |
import SecretInput from './SecretInput.vue'; | ||
import WithdrawCharges from './Fields/WithdrawCharges.vue' | ||
import DokanRadioGroup from "admin/components/DokanRadioGroup.vue"; | ||
import UploadImage from "admin/components/UploadImage.vue"; | ||
|
||
let Mapbox = dokan_get_lib('Mapbox'); | ||
let TextEditor = dokan_get_lib('TextEditor'); | ||
|
@@ -521,7 +543,8 @@ | |
name: 'Fields', | ||
|
||
components: { | ||
DokanRadioGroup, | ||
UploadImage, | ||
DokanRadioGroup, | ||
Mapbox, | ||
Switches, | ||
TextEditor, | ||
|
@@ -542,12 +565,15 @@ | |
checked : this.isChecked(), | ||
socialChecked : this.isSocialChecked(), | ||
expandSocials : false, | ||
croppingWidth : this.fieldData.cropping_width, | ||
croppingHeight : this.fieldData.cropping_height, | ||
repeatableItem : {}, | ||
repeatableTime : [], | ||
singleColorPicker : { default: this.fieldData.default, label: '', show_pallete: false }, | ||
yourStringTimeValue : '', | ||
customFieldComponents : dokan.hooks.applyFilters( 'getDokanCustomFieldComponents', [] ), | ||
multiCheckValues : {}, | ||
dokanProExists : dokan.hasPro, | ||
} | ||
}, | ||
|
||
|
@@ -565,11 +591,21 @@ | |
this.checked = value; | ||
} | ||
}); | ||
|
||
this.$root.$on( 'dokanRestoreDefault', ( fieldData ) => { | ||
if ( this.fieldValue[ fieldData.name ] !== fieldData.default ) { | ||
this.fieldValue[ fieldData.name ] = fieldData.default | ||
} | ||
}); | ||
}, | ||
|
||
watch: { | ||
fieldValue: { | ||
handler() { | ||
handler( newValue ) { | ||
if ( this.id === 'default_store_banner' ) { | ||
this.croppingWidth = newValue.store_banner_width; | ||
this.croppingHeight = newValue.store_banner_height; | ||
} | ||
}, | ||
deep: true, | ||
} | ||
|
@@ -723,6 +759,11 @@ | |
fieldData.is_lite ?? false | ||
); | ||
}, | ||
|
||
uploadedImage( image ) { | ||
this.fieldValue[ this.id ] = this.validateInputData( this.id, image.src, this.fieldValue[ this.id ], this.fieldData ); | ||
}, | ||
|
||
inputValueHandler( name, newValue, oldValue ) { | ||
this.fieldValue[ name ] = this.validateInputData( name, newValue, oldValue, this.fieldData ); | ||
}, | ||
|
@@ -1095,6 +1136,10 @@ | |
} | ||
} | ||
} | ||
|
||
.field_default { | ||
margin: 0; | ||
} | ||
} | ||
|
||
.social-switch-wraper { | ||
|
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.
Refactor variable names for consistency.
This change aligns the variable name with WordPress coding standards, which recommend using underscores in variable names for better readability.