Activator.php
3 months ago
Assets.php
3 weeks ago
Blocks.php
11 months ago
Database.php
8 months ago
Encrypt.php
8 months ago
Activator.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Hostinger\Reach\Setup; |
| 4 | |
| 5 | use Hostinger\Reach\Boot; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | die; |
| 9 | } |
| 10 | |
| 11 | class Activator { |
| 12 | public function __construct( string $plugin_file_name ) { |
| 13 | register_activation_hook( $plugin_file_name, array( $this, 'activate_plugin' ) ); |
| 14 | add_action( 'plugins_loaded', array( $this, 'boot' ) ); |
| 15 | add_action( 'admin_init', array( $this, 'maybe_redirect' ) ); |
| 16 | } |
| 17 | |
| 18 | public function activate_plugin(): void { |
| 19 | if ( has_action( 'litespeed_purge_all' ) ) { |
| 20 | do_action( 'litespeed_purge_all' ); |
| 21 | } |
| 22 | |
| 23 | add_option( 'hostinger_reach_activation_redirect', true ); |
| 24 | } |
| 25 | |
| 26 | public function maybe_redirect(): void { |
| 27 | if ( ! get_option( 'hostinger_reach_activation_redirect' ) ) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | delete_option( 'hostinger_reach_activation_redirect' ); |
| 32 | |
| 33 | $referer = wp_get_referer(); |
| 34 | if ( ! $referer || strpos( $referer, 'plugin-install.php' ) === false ) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | wp_safe_redirect( admin_url( 'admin.php?page=hostinger-reach' ) ); |
| 39 | exit; |
| 40 | } |
| 41 | |
| 42 | public function boot(): void { |
| 43 | $boot = Boot::get_instance(); |
| 44 | $boot->plugins_loaded(); |
| 45 | } |
| 46 | } |
| 47 |