| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | class Hooks { |
| 11 | 11 | /** |
| 12 | 12 | * @var Helper |
| 13 | 13 | */ |
| 14 | - private Helper $helper; | |
| 14 | + private Helper $helper; | |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @var Utils |
| 18 | 18 | */ |
| @@ -17,44 +17,47 @@ | ||
| 17 | 17 | * @var Utils |
| 18 | 18 | */ |
| 19 | 19 | private Utils $utils; |
| 20 | 20 | |
| 21 | - public function __construct( $utils ) { | |
| 22 | - $this->helper = new Helper(); | |
| 23 | - $this->utils = $utils ?? new Utils(); | |
| 24 | - add_action( 'admin_footer', array( $this, 'rate_plugin' ) ); | |
| 25 | - add_filter( 'wp_kses_allowed_html', array( $this, 'custom_kses_allowed_html' ), 10, 1 ); | |
| 26 | - } | |
| 21 | + public function __construct() { | |
| 22 | + $this->helper = new Helper(); | |
| 23 | + $this->utils = new Utils(); | |
| 24 | + add_action( 'admin_footer', array( $this, 'rate_plugin' ) ); | |
| 25 | + add_action( 'admin_init', array( $this, 'message_about_plugin_split' ) ); | |
| 26 | + } | |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | - public function rate_plugin(): void { | |
| 32 | - $admin_path = parse_url( admin_url(), PHP_URL_PATH ); | |
| 33 | - | |
| 34 | - if ( ! $this->utils->isThisPage( $admin_path . 'admin.php?page=' . Menu::MENU_SLUG ) ) { | |
| 31 | + public function rate_plugin(): void { | |
| 32 | + if ( !$this->utils->isThisPage('wp-admin/admin.php?page=' . Menu::MENU_SLUG) ) { | |
| 35 | 33 | return; |
| 36 | 34 | } |
| 37 | 35 | |
| 38 | 36 | require_once HOSTINGER_ABSPATH . 'includes/Admin/Views/Partials/RateUs.php'; |
| 39 | - } | |
| 37 | + } | |
| 40 | 38 | |
| 39 | + public function message_about_plugin_split(): void { | |
| 40 | + $plugin_split_notice_hidden = get_transient( 'hts_plugin_split_notice_hidden' ); | |
| 41 | + if ( $plugin_split_notice_hidden === false & version_compare( HOSTINGER_VERSION, '3.0.0', '>=' ) ) { | |
| 42 | + if ( !$this->utils->isPluginActive( 'hostinger-easy-onboarding' ) ) { | |
| 43 | + add_action( 'admin_notices', array( $this, 'custom_admin_notice' ) ); | |
| 44 | + } | |
| 45 | + } | |
| 46 | + } | |
| 41 | 47 | |
| 48 | + public function custom_admin_notice() { | |
| 49 | + ?> | |
| 50 | + <div id="hostinger-plugin-split-notice" class="hts-plugin-split notice is-dismissible"> | |
| 51 | + <h2><?php echo esc_html__('Hostinger plugin updates', 'hostinger'); ?></h2> | |
| 52 | + <p><?php echo esc_html__('The Hostinger plugin has been split into two different plugins:', 'hostinger'); ?></p> | |
| 53 | + <ul> | |
| 54 | + <li><strong><?php echo esc_html__('Hostinger Tools', 'hostinger'); ?></strong> <?php echo esc_html__('offers a toolkit for easier site maintenance.', 'hostinger'); ?></li> | |
| 55 | + <li><strong><?php echo esc_html__('Hostinger Easy Onboarding', 'hostinger'); ?></strong> <?php echo esc_html__('provides guidance and learning resources for beginners to get started with building a site using WordPress.', 'hostinger'); ?></li> | |
| 56 | + </ul> | |
| 57 | + <button id="plugin-split-close" type="button" class="plugin-split-close notice-dismiss"><?php echo esc_html__('Got it', 'hostinger'); ?></button> | |
| 58 | + </div> | |
| 59 | + <?php | |
| 60 | + wp_nonce_field( 'hts_close_plugin_split', 'hts_close_plugin_split_nonce', true ); | |
| 61 | + } | |
| 42 | 62 | |
| 43 | - public function custom_kses_allowed_html( $allowed ) { | |
| 44 | - $allowed['svg'] = array( | |
| 45 | - 'xmlns' => true, | |
| 46 | - 'width' => true, | |
| 47 | - 'height' => true, | |
| 48 | - 'viewBox' => true, | |
| 49 | - 'fill' => true, | |
| 50 | - 'style' => true, | |
| 51 | - 'class' => true, | |
| 52 | - ); | |
| 53 | - $allowed['path'] = array( | |
| 54 | - 'd' => true, | |
| 55 | - 'fill' => true, | |
| 56 | - ); | |
| 57 | - | |
| 58 | - return $allowed; | |
| 59 | - } | |
| 60 | 63 | } |