| @@ -1,88 +1,36 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Templately\Core; |
| 4 | 4 | |
| 5 | -use Templately\Admin\Roles; | |
| 6 | - | |
| 7 | 5 | class Maintenance { |
| 8 | 6 | /** |
| 9 | 7 | * Init Maintenance |
| 10 | 8 | * |
| 9 | + * @since 2.0.1 | |
| 11 | 10 | * @return void |
| 12 | - * @since 2.0.1 | |
| 13 | 11 | */ |
| 14 | - public static function init() { | |
| 12 | + public static function init(){ | |
| 15 | 13 | register_activation_hook( TEMPLATELY_PLUGIN_BASENAME, [ __CLASS__, 'activation' ] ); |
| 16 | 14 | register_uninstall_hook( TEMPLATELY_PLUGIN_BASENAME, [ __CLASS__, 'uninstall' ] ); |
| 17 | - register_deactivation_hook( TEMPLATELY_PLUGIN_BASENAME, [ __CLASS__, 'deactivation' ] ); | |
| 18 | - add_action( 'admin_init', [ __CLASS__, 'maybe_redirect_templately' ] ); | |
| 19 | 15 | } |
| 20 | 16 | |
| 21 | 17 | /** |
| 22 | 18 | * Runs on activation |
| 23 | 19 | * |
| 24 | - * @return void | |
| 25 | 20 | * @since 2.0.1 |
| 26 | - */ | |
| 27 | - public static function activation( $network_wide ) { | |
| 28 | - // Initialize Roles | |
| 29 | - ( new Roles() )->setup(); | |
| 30 | - | |
| 31 | - if ( wp_doing_ajax() ) { | |
| 32 | - return; | |
| 33 | - } | |
| 34 | - | |
| 35 | - if ( is_multisite() && $network_wide ) { | |
| 36 | - return; | |
| 37 | - } | |
| 38 | - | |
| 39 | - set_transient( 'templately_activation_redirect', true, MINUTE_IN_SECONDS ); | |
| 40 | - } | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * Runs on activation | |
| 44 | - * | |
| 45 | 21 | * @return void |
| 46 | - * @since 2.0.1 | |
| 47 | 22 | */ |
| 48 | - public static function deactivation($network_wide) { | |
| 49 | - // De-initialize Roles | |
| 50 | - ( new Roles() )->setup( true ); | |
| 51 | - if ( is_multisite() && $network_wide ) { | |
| 52 | - return; | |
| 53 | - } | |
| 23 | + public static function activation(){ | |
| 54 | 24 | |
| 55 | - set_transient( 'templately_activation_redirect', true, MINUTE_IN_SECONDS ); | |
| 56 | 25 | } |
| 57 | 26 | |
| 58 | - | |
| 59 | 27 | /** |
| 60 | 28 | * Runs on uninstallation. |
| 61 | 29 | * |
| 30 | + * @since 2.0.1 | |
| 62 | 31 | * @return void |
| 63 | - * @since 2.0.1 | |
| 64 | 32 | */ |
| 65 | - public static function uninstall() { | |
| 33 | + public static function uninstall(){ | |
| 66 | 34 | |
| 67 | - } | |
| 68 | - | |
| 69 | - /** | |
| 70 | - * Redirect on Active | |
| 71 | - */ | |
| 72 | - public static function maybe_redirect_templately() { | |
| 73 | - if ( ! get_transient( 'templately_activation_redirect' ) ) { | |
| 74 | - return; | |
| 75 | - } | |
| 76 | - if ( wp_doing_ajax() ) { | |
| 77 | - return; | |
| 78 | - } | |
| 79 | - | |
| 80 | - delete_transient( 'templately_activation_redirect' ); | |
| 81 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | |
| 82 | - return; | |
| 83 | - } | |
| 84 | - // Safe Redirect to Templately Page | |
| 85 | - wp_safe_redirect( admin_url( 'admin.php?page=templately&path=elementor/packs' ) ); | |
| 86 | - exit; | |
| 87 | 35 | } |
| 88 | 36 | } |