Skip to content

Commit

Permalink
fix(Setup-Wizard): redirection conflict with cli during plugin activa…
Browse files Browse the repository at this point in the history
…tion fixed #235
  • Loading branch information
sabbir1991 committed Apr 24, 2018
1 parent be3f5c7 commit fddb3ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
20 changes: 0 additions & 20 deletions classes/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function do_install() {
if ( ! $was_installed_before ) {
set_transient( '_dokan_setup_page_redirect', true, 30 );
}

}

/**
Expand Down Expand Up @@ -79,25 +78,6 @@ function woocommerce_settings() {
update_option( 'woocommerce_enable_myaccount_registration', 'yes' );
}

/**
* Redirect to Setup page if transient is valid
*
* @since 2.5
*
* @return void
*/
public static function setup_page_redirect( $plugin ) {

if ( !get_transient( '_dokan_setup_page_redirect' ) ) {
return;
}
// Delete the redirect transient
delete_transient( '_dokan_setup_page_redirect' );

wp_safe_redirect( add_query_arg( array( 'page' => 'dokan-setup' ), admin_url( 'index.php' ) ) );
exit;
}

/**
* Update product new style options
*
Expand Down
2 changes: 0 additions & 2 deletions dokan.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,3 @@ function dokan() {

// Lets Go....
dokan();

add_action( 'activated_plugin', array( 'Dokan_Installer', 'setup_page_redirect' ) );
20 changes: 20 additions & 0 deletions includes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct() {
add_filter( 'body_class', array( $this, 'add_dashboard_template_class' ), 99 );
add_filter( 'wp_title', array( $this, 'wp_title' ), 20, 2 );
add_action( 'template_redirect', array( $this, 'redirect_if_not_logged_seller' ), 11 );
add_action( 'admin_init', array( $this, 'redirect_after_activate' ), 999 );
}

/**
Expand Down Expand Up @@ -162,5 +163,24 @@ function redirect_if_not_logged_seller() {
}
}

/**
* Redirect after activation
*
* @since 2.8.0
*
* @return void
*/
public function redirect_after_activate() {
if ( ! get_transient( '_dokan_setup_page_redirect' ) ) {
return;
}

// Delete the redirect transient
delete_transient( '_dokan_setup_page_redirect' );

wp_safe_redirect( add_query_arg( array( 'page' => 'dokan-setup' ), admin_url( 'index.php' ) ) );
exit;
}

}

0 comments on commit fddb3ac

Please sign in to comment.