PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / trunk
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! vtrunk
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
templately / includes / Core / Maintenance.php

Maintenance.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! trunk, at includes/Core/Maintenance.php

93 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Core;
4
5 use Templately\Admin\Roles;
6
7 class Maintenance {
8 /**
9 * Init Maintenance
10 *
11 * @return void
12 * @since 2.0.1
13 */
14 public static function init() {
15 register_activation_hook( TEMPLATELY_PLUGIN_BASENAME, [ __CLASS__, 'activation' ] );
16 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
20 // Runtime capability hooks — setup() only ever runs on activation, so the
21 // administrator grant needs a home that runs on every request.
22 Roles::init();
23 }
24
25 /**
26 * Runs on activation
27 *
28 * @return void
29 * @since 2.0.1
30 */
31 public static function activation( $network_wide ) {
32 // Initialize Roles
33 ( new Roles() )->setup();
34
35 if ( wp_doing_ajax() ) {
36 return;
37 }
38
39 if ( is_multisite() && $network_wide ) {
40 return;
41 }
42
43 set_transient( 'templately_activation_redirect', true, MINUTE_IN_SECONDS );
44 }
45
46 /**
47 * Runs on activation
48 *
49 * @return void
50 * @since 2.0.1
51 */
52 public static function deactivation($network_wide) {
53 // De-initialize Roles
54 ( new Roles() )->setup( true );
55 if ( is_multisite() && $network_wide ) {
56 return;
57 }
58
59 set_transient( 'templately_activation_redirect', true, MINUTE_IN_SECONDS );
60 }
61
62
63 /**
64 * Runs on uninstallation.
65 *
66 * @return void
67 * @since 2.0.1
68 */
69 public static function uninstall() {
70
71 }
72
73 /**
74 * Redirect on Active
75 */
76 public static function maybe_redirect_templately() {
77 if ( ! get_transient( 'templately_activation_redirect' ) ) {
78 return;
79 }
80 if ( wp_doing_ajax() ) {
81 return;
82 }
83
84 delete_transient( 'templately_activation_redirect' );
85 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
86 return;
87 }
88 // Safe Redirect to Templately Page
89 wp_safe_redirect( admin_url( 'admin.php?page=templately&path=elementor/packs' ) );
90 exit;
91 }
92 }
93