Skip to content
Open
33 changes: 32 additions & 1 deletion includes/Dashboard/Templates/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,23 @@
}
}

$enable_tnc = isset( $_POST['dokan_store_tnc_enable'] ) && 'on' === sanitize_text_field( wp_unslash( $_POST['dokan_store_tnc_enable'] ) );

if ( $enable_tnc ) {
$store_tnc = isset( $_POST['dokan_store_tnc'] ) ? wp_kses_post( wp_unslash( $_POST['dokan_store_tnc'] ) ) : '';

$store_tnc_clean = wp_strip_all_tags( $store_tnc );
$store_tnc_clean = html_entity_decode( $store_tnc_clean, ENT_QUOTES | ENT_HTML5, 'UTF-8' );
$store_tnc_clean = preg_replace( '/[\s\x{00A0}\x{200B}\x{FEFF}]+/u', '', $store_tnc_clean );

if ( empty( $store_tnc_clean ) ) {
$error->add(
'dokan_tnc_content',
__( 'Please add Terms & Conditions content before enabling this option.', 'dokan-lite' )
);
}
}

if ( $error->get_error_codes() ) {
return $error;
}
Expand Down Expand Up @@ -639,6 +656,20 @@
];
}

$store_tnc_raw = isset( $_POST['dokan_store_tnc'] ) ? wp_kses_post( wp_unslash( $_POST['dokan_store_tnc'] ) ) : '';

$store_tnc_processed = '';

if ( ! empty( $store_tnc_raw ) ) {
$store_tnc_clean = wp_strip_all_tags( $store_tnc_raw );
$store_tnc_clean = html_entity_decode( $store_tnc_clean, ENT_QUOTES | ENT_HTML5, 'UTF-8' );
$store_tnc_clean = preg_replace( '/[\s\x{00A0}\x{200B}\x{FEFF}]+/u', '', $store_tnc_clean );

if ( ! empty( $store_tnc_clean ) ) {
$store_tnc_processed = $store_tnc_raw;
}
}

// Update store settings info.
$dokan_settings = [
'store_name' => isset( $_POST['dokan_store_name'] ) ? sanitize_text_field( wp_unslash( $_POST['dokan_store_name'] ) ) : '',
Expand All @@ -650,7 +681,7 @@
'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',
'store_tnc' => isset( $_POST['dokan_store_tnc'] ) ? wp_kses_post( wp_unslash( $_POST['dokan_store_tnc'] ) ) : '',
'store_tnc' => $store_tnc_processed,
'dokan_store_time' => apply_filters( 'dokan_store_time', $dokan_store_time ),
'dokan_store_time_enabled' => isset( $_POST['dokan_store_time_enabled'] ) && 'yes' === sanitize_text_field( wp_unslash( $_POST['dokan_store_time_enabled'] ) ) ? 'yes' : 'no',
'dokan_store_open_notice' => isset( $_POST['dokan_store_open_notice'] ) ? sanitize_textarea_field( wp_unslash( $_POST['dokan_store_open_notice'] ) ) : '',
Expand Down Expand Up @@ -864,7 +895,7 @@
*
* @return string
*/
public function get_method_frontend_title( $title, $method ) {

Check warning on line 898 in includes/Dashboard/Templates/Settings.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $method is never used
if ( 0 === stripos( $title, 'Dokan ' ) ) {
return substr( $title, 6 );
}
Expand Down
2 changes: 1 addition & 1 deletion templates/settings/store-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</div>
</div>
<div class="dokan-form-group" id="dokan_tnc_text">
<label class="dokan-w3 dokan-control-label" for="dokan_store_tnc"><?php esc_html_e( 'TOC Details', 'dokan-lite' ); ?></label>
<label class="dokan-w3 dokan-control-label" for="dokan_store_tnc"><?php esc_html_e( 'TOC Details', 'dokan-lite' ); ?> <span style="color: red;">*</span></label>
<div class="dokan-w8 dokan-text-left">
<?php
$settings = [
Expand Down
Loading