| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly |
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 |
|
| 6 |
class Vimeography_Admin_Welcome { |
| 7 |
|
| 8 |
public function __construct() { |
| 9 |
|
| 10 |
register_activation_hook( VIMEOGRAPHY_BASENAME, array($this, 'set_welcome_screen_flag') ); |
| 11 |
|
| 12 |
add_action( 'admin_init', array($this, 'welcome_screen_do_activation_redirect') ); |
| 13 |
|
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
/** |
| 18 |
* Set a transient that expires in 30 seconds. |
| 19 |
* |
| 20 |
* @return [type] [description] |
| 21 |
*/ |
| 22 |
public function set_welcome_screen_flag() { |
| 23 |
set_transient( '_vimeography_welcome_screen_activation_redirect', true, 30 ); |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Check to see if we should perform the redirect |
| 29 |
* |
| 30 |
* @return [type] [description] |
| 31 |
*/ |
| 32 |
public function welcome_screen_do_activation_redirect() { |
| 33 |
|
| 34 |
// Bail if no activation redirect |
| 35 |
if ( ! get_transient( '_vimeography_welcome_screen_activation_redirect' ) ) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
// Delete the redirect transient |
| 40 |
delete_transient( '_vimeography_welcome_screen_activation_redirect' ); |
| 41 |
|
| 42 |
// Bail if activating from network, or bulk |
| 43 |
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
| 44 |
return; |
| 45 |
} |
| 46 |
|
| 47 |
// Redirect |
| 48 |
wp_safe_redirect( add_query_arg( array( 'page' => 'vimeography-welcome', 'step' => '1' ), admin_url( 'options.php' ) ) ); |
| 49 |
} |
| 50 |
|
| 51 |
} |