Skip to content
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
110 changes: 110 additions & 0 deletions includes/Admin/Notices/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private function init_hooks() {
add_filter( 'dokan_admin_notices', [ $this, 'show_admin_logo_update_notice' ] );
add_action( 'wp_ajax_dismiss_dokan_admin_logo_update_notice', [ $this, 'dismiss_dokan_admin_logo_update_notice' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_admin_plugin_update_notice' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_vendor_onboarding_page_notice' ] );
}

/**
Expand Down Expand Up @@ -225,4 +226,113 @@ public function show_admin_plugin_update_notice( $notices ) {

return $notices;
}

/**
* Show admin notice if vendor onboarding page is not configured.
*
* @since 3.7.11
*
* @param array $notices
*
* @return array
*/
public function show_vendor_onboarding_page_notice( $notices ) {
// Check if vendor onboarding page is configured
if ( $this->is_vendor_onboarding_page_configured() ) {
return $notices;
}

$settings_url = add_query_arg(
[ 'page' => 'dokan#/tools' ],
admin_url( 'admin.php' )
);

$dokan_pages = get_option( 'dokan_pages', [] );
$page_id = isset( $dokan_pages['vendor_onboarding'] ) ? $dokan_pages['vendor_onboarding'] : 0;

// Check if page was configured but is now deleted or unpublished
if ( $page_id && (int) $page_id > 0 ) {
$page = get_post( $page_id );

if ( ! $page ) {
// Page doesn't exist
$notice_title = esc_html__( 'Vendor Onboarding page not found!', 'dokan-lite' );
$notice_description = sprintf(
/* translators: %s: Settings link */
esc_html__( 'The configured Vendor Onboarding page has been deleted. Please set a new page in %s', 'dokan-lite' ),
sprintf(
'<a href="%s">%s</a>',
esc_url( $settings_url ),
esc_html__( 'Dokan → Tools → Page Installation', 'dokan-lite' )
)
);
} else {
// Page exists but is not published
$notice_title = esc_html__( 'Vendor Onboarding page is not published!', 'dokan-lite' );
$notice_description = sprintf(
/* translators: %s: Settings link */
esc_html__( 'The configured Vendor Onboarding page is not published. Please publish it or configure a new page in %s', 'dokan-lite' ),
sprintf(
'<a href="%s">%s</a>',
esc_url( $settings_url ),
esc_html__( 'Dokan → Tools → Page Installation', 'dokan-lite' )
)
);
}
} else {
// Page not configured at all
$notice_title = esc_html__( 'Vendor Onboarding feature is almost ready!', 'dokan-lite' );
$notice_description = sprintf(
/* translators: %s: Settings link */
esc_html__( 'Dokan Vendor Onboarding requires a dedicated page to be configured. Please set it in %s', 'dokan-lite' ),
sprintf(
'<a href="%s">%s</a>',
esc_url( $settings_url ),
esc_html__( 'Dokan → Tools → Page Installation', 'dokan-lite' )
)
);
}

$notices[] = [
'type' => 'warning',
'title' => $notice_title,
'description' => $notice_description,
'priority' => 5,
'scope' => 'global',
];

return $notices;
}

/**
* Check if vendor onboarding page is configured.
*
* @since 3.7.11
*
* @return bool
*/
private function is_vendor_onboarding_page_configured() {
$dokan_pages = get_option( 'dokan_pages', [] );

// Check if vendor_onboarding key exists and has a valid page ID
if ( ! isset( $dokan_pages['vendor_onboarding'] ) || empty( $dokan_pages['vendor_onboarding'] ) ) {
return false;
}

$page_id = $dokan_pages['vendor_onboarding'];

// Verify the page ID is not zero or empty
if ( ! $page_id || 0 === (int) $page_id ) {
return false;
}

// Verify the page actually exists and is published
$page = get_post( $page_id );

if ( ! $page || 'publish' !== $page->post_status ) {
return false;
}

return true;
}
}
8 changes: 8 additions & 0 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,14 @@ public function get_settings_fields() {
'tooltip' => __( 'Select a page to display the Terms and Conditions of your store for Vendors.', 'dokan-lite' ),
'placeholder' => __( 'Select page', 'dokan-lite' ),
],
'vendor_onboarding' => [
'name' => 'vendor_onboarding',
'label' => __( 'Vendor Onboarding', 'dokan-lite' ),
'desc' => __( 'Select a page for vendor onboarding and login', 'dokan-lite' ),
'type' => 'select',
'placeholder' => __( 'Select page', 'dokan-lite' ),
'options' => $pages_array,
],
],
'dokan_appearance' => [
'vendor_layout_options' => [
Expand Down
6 changes: 6 additions & 0 deletions includes/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@
'page_id' => 'my_orders',
'content' => '[dokan-my-orders]',
],
[
'post_title' => __( 'Vendor Onboarding', 'dokan-lite' ),
'slug' => 'vendor-onboarding',
'page_id' => 'vendor_onboarding',
'content' => '[dokan-vendor-onboarding-registration]',
],
];

$dokan_page_settings = [];
Expand Down Expand Up @@ -504,7 +510,7 @@
*
* @return string
*/
private static function parse_update_notice( $content, $new_version ) {

Check warning on line 513 in includes/Install/Installer.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $new_version is never used
// Output Upgrade Notice.
$matches = null;
$regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( DOKAN_PLUGIN_VERSION, '/' ) . '\s*=|$)~Uis';
Expand Down
2 changes: 2 additions & 0 deletions includes/Shortcodes/Shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use WeDevs\Dokan\Shortcodes\Stores;
use WeDevs\Dokan\Shortcodes\TopRatedProduct;
use WeDevs\Dokan\Shortcodes\VendorRegistration;
use WeDevs\Dokan\Shortcodes\VendorOnboardingRegistration;

class Shortcodes {

Expand All @@ -31,6 +32,7 @@ public function __construct() {
'dokan-stores' => new Stores(),
'dokan-vendor-registration' => new VendorRegistration(),
'dokan-customer-migration' => new CustomerMigration(),
'dokan-vendor-onboarding-registration' => new VendorOnboardingRegistration(),
]
);
}
Expand Down
35 changes: 35 additions & 0 deletions includes/Shortcodes/VendorOnboardingRegistration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace WeDevs\Dokan\Shortcodes;

use WeDevs\Dokan\Abstracts\DokanShortcode;

class VendorOnboardingRegistration extends DokanShortcode {

protected $shortcode = 'dokan-vendor-onboarding-registration';

/**
* Vendor onboarding form shortcode callback
*
* @return string
*/
public function render_shortcode( $atts ) {
if ( is_user_logged_in() ) {
return esc_html__( 'You are already logged in', 'dokan-lite' );
}

dokan()->scripts->load_form_validate_script();

wp_enqueue_script( 'dokan-form-validate' );
wp_enqueue_script( 'dokan-vendor-registration' );
wp_enqueue_script( 'dokan-vendor-address' );

$data = dokan_get_seller_registration_form_data();

ob_start();
dokan_get_template_part( 'account/vendor-onboarding', false, [ 'data' => $data ] );
$content = ob_get_clean();

return apply_filters( 'dokan_vendor_reg_form', $content );
}
}
1 change: 1 addition & 0 deletions includes/Upgrade/Upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Upgrades {
'3.7.19' => Upgrades\V_3_7_19::class,
'3.13.0' => Upgrades\V_3_13_0::class,
'3.14.0' => Upgrades\V_3_14_0::class,
'4.2.2' => Upgrades\V_4_2_2::class,
];

/**
Expand Down
55 changes: 55 additions & 0 deletions includes/Upgrade/Upgrades/V_4_2_2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace WeDevs\Dokan\Upgrade\Upgrades;

defined( 'ABSPATH' ) || exit;

use WeDevs\Dokan\Abstracts\DokanUpgrader;

/**
* Upgrader Class.
*
* @since 4.2.2
*/
class V_4_2_2 extends DokanUpgrader {

/**
* Create Vendor Onboarding page if it doesn't exist.
*
* @since 4.2.2
*
* @return void
*/
public static function create_vendor_onboarding_page() {
$dokan_pages = get_option( 'dokan_pages', [] );

// Check if vendor_onboarding page already exists
if ( isset( $dokan_pages['vendor_onboarding'] ) ) {
$page_id = $dokan_pages['vendor_onboarding'];
$page = get_post( $page_id );

// If page exists and is published, skip creation
if ( $page && 'publish' === $page->post_status ) {
return;
}
}

// Create vendor onboarding page
$page_id = wp_insert_post(
[
'post_title' => __( 'Vendor Onboarding', 'dokan-lite' ),
'post_name' => 'vendor-onboarding',
'post_content' => '[dokan-vendor-onboarding-registration]',
'post_status' => 'publish',
'post_type' => 'page',
'comment_status' => 'closed',
]
);

// Update dokan_pages option
if ( $page_id && ! is_wp_error( $page_id ) ) {
$dokan_pages['vendor_onboarding'] = $page_id;
update_option( 'dokan_pages', $dokan_pages );
}
}
}
Loading
Loading