Created
December 12, 2014 17:27
-
-
Save zanematthew/1fecf2ff89740becce4b to your computer and use it in GitHub Desktop.
Note this is a snippet from a class, you can replace the $this-> with your params or hardcode them. Its all ran during admin_init.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sends user to the start page on first activation, as well as each time the | |
* plugin is upgraded to a new version | |
* | |
* @access public | |
* @since 1.1 | |
* @return void | |
*/ | |
public function welcome_init(){ | |
// Bail if no activation redirect | |
if ( ! get_transient( '_' . $this->plugin_slug . '_activation_redirect' ) ) | |
return; | |
// Delete the redirect transient | |
delete_transient( '_' . $this->plugin_slug . '_activation_redirect' ); | |
// Bail if activating from network, or bulk | |
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) | |
return; | |
if( ! $this->upgraded_from ){ // First time install | |
wp_safe_redirect( admin_url( 'index.php?page=' . $this->start_slug ) ); exit; | |
} else { // Update | |
wp_safe_redirect( admin_url( 'index.php?page=' . $this->update_slug ) ); exit; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note version numbers can be handled to your liking, this is how I do it: https://gist.github.com/zanematthew/f8440442df8524a9dff0