Welcome.php
78 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backend\Activation; |
| 4 | |
| 5 | // No Direct Access |
| 6 | if (!defined("WPINC")) { |
| 7 | die; |
| 8 | } |
| 9 | |
| 10 | use WPStaging\Framework\Traits\NoticesTrait; |
| 11 | use WPStaging\Framework\Facades\Escape; |
| 12 | |
| 13 | class Welcome |
| 14 | { |
| 15 | use NoticesTrait; |
| 16 | |
| 17 | public function __construct() |
| 18 | { |
| 19 | add_action('admin_init', [$this, 'welcome']); |
| 20 | |
| 21 | if (wpstgGetProVersionNumberIfInstalled() && $this->isWPStagingAdminPage()) { |
| 22 | add_action('wpstg.admin_notices', [$this, 'wpstgproActivationNotice']); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @return void |
| 28 | * @todo make this message permanently hideable when dismissed. |
| 29 | */ |
| 30 | public function wpstgproActivationNotice() |
| 31 | { |
| 32 | ?> |
| 33 | <div class="notice notice-warning is-dismissible"> |
| 34 | <p> |
| 35 | <?php |
| 36 | printf( |
| 37 | Escape::escapeHtml(__('WP Staging Pro is installed but not activated. Some features may not work until you activate the Pro version. Go to <a href=%s>Installed Plugins</a> and activate WP Staging Pro there.', 'wp-staging')), |
| 38 | esc_url(admin_url('plugins.php')) |
| 39 | ); |
| 40 | ?> |
| 41 | </p> |
| 42 | </div> |
| 43 | <?php |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Sends user to the welcome page on first activation of WPSTG as well as each |
| 48 | * time WPSTG is upgraded to a new version |
| 49 | * |
| 50 | * @access public |
| 51 | * @return void |
| 52 | * @since 1.0.1 |
| 53 | */ |
| 54 | public function welcome() |
| 55 | { |
| 56 | // Bail if pro is installed |
| 57 | if (wpstgGetProVersionNumberIfInstalled()) { |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | // Bail if no activation redirect |
| 62 | if (get_transient('wpstg_activation_redirect') === false) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | // Delete the redirect transient |
| 67 | delete_transient('wpstg_activation_redirect'); |
| 68 | |
| 69 | // Bail if activating from network, or bulk |
| 70 | if (is_network_admin() || isset($_GET['activate-multi'])) { |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | wp_safe_redirect(admin_url('admin.php?page=wpstg-welcome')); |
| 75 | exit; |
| 76 | } |
| 77 | } |
| 78 |