Skip to content
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

[Fix] Deprecated Noticed on Admin Setup Wizard #2414

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions includes/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,14 @@ public function setup_wizard_header() {
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php esc_html_e( 'Dokan &rsaquo; Setup Wizard', 'dokan-lite' ); ?></title>
<?php wp_print_scripts(); ?>
<?php do_action( 'admin_print_styles' ); ?>
<?php do_action( 'admin_head' ); ?>
<?php do_action( 'dokan_setup_wizard_styles' ); ?>
<?php
wp_print_scripts();
wp_enqueue_emoji_styles();
do_action( 'admin_print_styles' );
wp_enqueue_admin_bar_header_styles();
do_action( 'admin_head' );
do_action( 'dokan_setup_wizard_styles' );
?>
</head>
<body class="wc-setup dokan-admin-setup-wizard wp-core-ui<?php echo get_transient( 'dokan_setup_wizard_no_wc' ) ? ' dokan-setup-wizard-activated-wc' : ''; ?>">
<?php
Expand Down
40 changes: 23 additions & 17 deletions includes/Vendor/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function __construct() {
}

// define the woocommerce_registration_redirect callback
public function filter_woocommerce_registration_redirect( $var ) {
$url = $var;
public function filter_woocommerce_registration_redirect( $url ) {

$user = wp_get_current_user();

if ( in_array( 'seller', $user->roles, true ) ) {
Expand Down Expand Up @@ -123,6 +123,7 @@ public function setup_wizard() {
*/
public function frontend_enqueue_scripts() {
wp_enqueue_style( 'jquery-ui' );
wp_enqueue_emoji_styles();
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-tiptip' );
wp_enqueue_script( 'jquery-blockui' );
Expand Down Expand Up @@ -178,8 +179,9 @@ public function setup_wizard_footer() {
* Introduction step.
*/
public function dokan_setup_introduction() {
$dashboard_url = dokan_get_navigation_url();
$default_message = wp_kses_post( __( '<p>Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than two minutes.</strong></p>', 'dokan-lite' ) );
$dashboard_url = dokan_get_navigation_url();
// translators: %1$s and %2$s are HTML tags for bold text
$default_message = wp_kses_post( sprintf( __( 'Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. %1$sIt’s completely optional and shouldn’t take longer than two minutes.%2$s', 'dokan-lite' ), '<strong>', '</strong>' ) );
$setup_wizard_message = dokan_get_option( 'setup_wizard_message', 'dokan_general', $default_message );
?>
<h1><?php esc_attr_e( 'Welcome to the Marketplace!', 'dokan-lite' ); ?></h1>
Expand Down Expand Up @@ -214,6 +216,9 @@ public function dokan_setup_store() {
$country_obj = new WC_Countries();
$countries = $country_obj->get_allowed_countries();
$states = $country_obj->states;

$request_data = wc_clean( wp_unslash( $_POST ) ); // phpcs:ignore

?>
<h1><?php esc_attr_e( 'Store Setup', 'dokan-lite' ); ?></h1>
<form method="post" class="dokan-seller-setup-form">
Expand All @@ -230,7 +235,7 @@ public function dokan_setup_store() {
<input type="text" id="address[street_1]" name="address[street_1]" value="<?php echo esc_attr( $address_street1 ); ?>"/>
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[street_1]'] ) ) {
if ( ! empty( $request_data['error_address[street_1]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand All @@ -247,7 +252,7 @@ public function dokan_setup_store() {
<input type="text" id="address[street_2]" name="address[street_2]" value="<?php echo esc_attr( $address_street2 ); ?>"/>
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[street_2]'] ) ) {
if ( ! empty( $request_data['error_address[street_2]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand All @@ -265,7 +270,7 @@ public function dokan_setup_store() {
<input type="text" id="address[city]" name="address[city]" value="<?php echo esc_attr( $address_city ); ?>"/>
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[city]'] ) ) {
if ( ! empty( $request_data['error_address[city]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand All @@ -282,7 +287,7 @@ public function dokan_setup_store() {
<input type="text" id="address[zip]" name="address[zip]" value="<?php echo esc_attr( $address_zip ); ?>"/>
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[zip]'] ) ) {
if ( ! empty( $request_data['error_address[zip]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand All @@ -301,7 +306,7 @@ public function dokan_setup_store() {
</select>
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[country]'] ) ) {
if ( ! empty( $request_data['error_address[country]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand All @@ -319,7 +324,7 @@ public function dokan_setup_store() {
<input type="text" id="calc_shipping_state" name="address[state]" value="<?php echo esc_attr( $address_state ); ?>" / placeholder="<?php esc_attr_e( 'State Name', 'dokan-lite' ); ?>">
<span class="error-container">
<?php
if ( ! empty( $_POST['error_address[state]'] ) ) {
if ( ! empty( $request_data['error_address[state]'] ) ) {
echo '<span class="required">' . __( 'This is required', 'dokan-lite' ) . '</span>';
}
?>
Expand Down Expand Up @@ -520,12 +525,9 @@ public function dokan_setup_store_save() {
if ( empty( $dokan_settings['address']['country'] ) ) {
$is_valid_form = false;
$_POST['error_address[country]'] = 'error';
}
else {
if ( ( isset( $states[ $dokan_settings['address']['country'] ] ) && count( $states[ $dokan_settings['address']['country'] ] ) && empty( $dokan_settings['address']['state'] ) || ( ! isset( $states[ $dokan_settings['address']['country'] ] ) && empty( $dokan_settings['address']['state'] ) ) ) ) {
$is_valid_form = false;
} elseif ( ( ( isset( $states[ $dokan_settings['address']['country'] ] ) && count( $states[ $dokan_settings['address']['country'] ] ) && empty( $dokan_settings['address']['state'] ) ) || ( ! isset( $states[ $dokan_settings['address']['country'] ] ) && empty( $dokan_settings['address']['state'] ) ) ) ) {
$is_valid_form = false;
$_POST['error_address[state]'] = 'error';
}
}

if ( ! $is_valid_form ) {
Expand Down Expand Up @@ -607,12 +609,16 @@ public function dokan_setup_payment_save() {
'swift' => $bank['swift'],
];

$user_bank_data = array_filter( $dokan_settings['payment']['bank'], function( $item ) { return ! empty( $item ); } );
$user_bank_data = array_filter(
$dokan_settings['payment']['bank'], function ( $item ) {
return ! empty( $item );
}
);
$require_fields = array_keys( dokan_bank_payment_required_fields() );

$has_bank_information = true;
foreach ( $require_fields as $require_field ) {
if( empty( $user_bank_data[ $require_field ] ) ) {
if ( empty( $user_bank_data[ $require_field ] ) ) {
$_POST[ 'error_' . $require_field ] = 'error';
$has_bank_information = false;
}
Expand Down
Loading