| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; |
| 8 | 8 | use RadiusTheme\SB\Helpers\Fns; |
| 9 | 9 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 10 | 10 | |
| 11 | - | |
| 12 | 11 | class AdminInit { |
| 13 | 12 | /** |
| 14 | 13 | * Parent Menu Page Slug |
| 15 | 14 | */ |
| @@ -31,10 +30,8 @@ | ||
| 31 | 30 | |
| 32 | 31 | use SingletonTrait; |
| 33 | 32 | |
| 34 | 33 | public function __construct() { |
| 35 | - // $this->menu_link_part = admin_url( 'admin.php?page=rtsb' ); | |
| 36 | - $this->remove_all_notices(); | |
| 37 | 34 | $this->init(); |
| 38 | 35 | $this->ajax_actions(); |
| 39 | 36 | $this->upgrade(); |
| 40 | 37 | } |
| @@ -45,10 +42,12 @@ | ||
| 45 | 42 | * @return void |
| 46 | 43 | */ |
| 47 | 44 | public function ajax_actions() { |
| 48 | 45 | Ajax\DefaultTemplate::instance(); |
| 46 | + if ( defined( 'ELEMENTOR_VERSION' ) ) { // Elementor Check. | |
| 47 | + Ajax\CreateTemplate::instance(); | |
| 48 | + } | |
| 49 | 49 | Ajax\ModalTemplate::instance(); |
| 50 | - Ajax\CreateTemplate::instance(); | |
| 51 | 50 | Ajax\AdminSettings::instance(); |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | 53 | /** |
| @@ -63,8 +62,9 @@ | ||
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | public function init() { |
| 66 | 65 | add_action( 'admin_menu', [ $this, 'add_menu' ], 25 ); |
| 66 | + add_action( 'in_admin_header', [ $this, 'in_admin_header_functionality' ], 1000 ); | |
| 67 | 67 | PluginRow::instance(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function add_menu() { |
| @@ -129,25 +129,37 @@ | ||
| 129 | 129 | Fns::renderView( 'themes' ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * Remove admin notices | |
| 133 | + * Admin Header | |
| 134 | 134 | */ |
| 135 | - public function remove_all_notices() { | |
| 136 | - add_action( | |
| 137 | - 'in_admin_header', | |
| 138 | - function () { | |
| 139 | - $screen = get_current_screen(); | |
| 140 | - | |
| 141 | - if ( in_array( | |
| 142 | - $screen->base, | |
| 143 | - [ 'shopbuilder_page_rtsb-settings', 'shopbuilder_page_rtsb-license', 'shopbuilder_page_rtsb-themes' ], | |
| 144 | - true | |
| 145 | - ) ) { | |
| 146 | - remove_all_actions( 'admin_notices' ); | |
| 147 | - remove_all_actions( 'all_admin_notices' ); | |
| 148 | - } | |
| 149 | - }, | |
| 150 | - 1000 | |
| 151 | - ); | |
| 135 | + public function in_admin_header_functionality() { | |
| 136 | + $screen = get_current_screen(); | |
| 137 | + $isBuilderTemplate = 'edit-rtsb_builder' === $screen->id; | |
| 138 | + $pages = [ | |
| 139 | + 'shopbuilder_page_rtsb-get-help', | |
| 140 | + 'shopbuilder_page_rtsb-settings', | |
| 141 | + 'shopbuilder_page_rtsb-license', | |
| 142 | + 'shopbuilder_page_rtsb-themes', | |
| 143 | + ]; | |
| 144 | + $isSettingsPage = in_array( $screen->base, $pages, true ); | |
| 145 | + if ( $isBuilderTemplate || $isSettingsPage ) { | |
| 146 | + remove_all_actions( 'admin_notices' ); | |
| 147 | + remove_all_actions( 'all_admin_notices' ); | |
| 148 | + } | |
| 149 | + if ( ! defined( 'ELEMENTOR_VERSION' ) && $isBuilderTemplate ) { | |
| 150 | + ?> | |
| 151 | + <div class='rtsb-message-for-elementor-missing'> | |
| 152 | + <div class="rtsb-builder-notice-content"> | |
| 153 | + <?php | |
| 154 | + echo sprintf( | |
| 155 | + /* translators: %s: Elementor */ | |
| 156 | + esc_html__( 'To build your WooCommerce pages, please Install and Activate the %s Plugin.', 'shopbuilder' ), | |
| 157 | + '<a href="' . esc_url( admin_url( 'plugin-install.php?s=elementor&tab=search&type=term' ) ) . '" target="_blank">' . esc_html__( 'Elementor Website Builder', 'shopbuilder' ) . '</a>' | |
| 158 | + ); | |
| 159 | + ?> | |
| 160 | + </div> | |
| 161 | + </div> | |
| 162 | + <?php | |
| 163 | + } | |
| 152 | 164 | } |
| 153 | 165 | } |