| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The welcome class after install |
| 5 |
* |
| 6 |
* @since 1.1.0 |
| 7 |
*/ |
| 8 |
class WeForms_Admin_Welcome { |
| 9 |
|
| 10 |
function __construct() { |
| 11 |
add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
| 12 |
add_action( 'admin_head', array( $this, 'hide_menu' ) ); |
| 13 |
add_action( 'admin_init', array( $this, 'redirect_to_page' ), 9999 ); |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Register the admin menu to setup the welcome message |
| 18 |
* |
| 19 |
* @return void |
| 20 |
*/ |
| 21 |
public function register_menu() { |
| 22 |
add_dashboard_page( __( 'Welcome to weForms', 'weforms' ), __( 'Welcome to weForms', 'weforms' ), 'manage_options', 'weforms-welcome', array( $this, 'welcome_page' ) ); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Hide the menu as we don't want to show the welcome page in admin menu |
| 27 |
* |
| 28 |
* @return void |
| 29 |
*/ |
| 30 |
public function hide_menu() { |
| 31 |
remove_submenu_page( 'index.php', 'weforms-welcome' ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Redirect to the welcome page once the plugin is installed |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function redirect_to_page() { |
| 40 |
if ( ! get_transient( 'weforms_activation_redirect' ) ) { |
| 41 |
return; |
| 42 |
} |
| 43 |
|
| 44 |
delete_transient( 'weforms_activation_redirect' ); |
| 45 |
|
| 46 |
// Only do this for single site installs. |
| 47 |
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
| 48 |
return; |
| 49 |
} |
| 50 |
|
| 51 |
wp_safe_redirect( admin_url( 'index.php?page=weforms-welcome' ) ); |
| 52 |
exit; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Render the welcome page |
| 57 |
* |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
public function welcome_page() { |
| 61 |
echo "Hello There!"; |
| 62 |
} |
| 63 |
} |
| 64 |
|