| @@ -1,22 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Admin Init. | |
| 4 | - * | |
| 5 | - * @package RadiusTheme\SB | |
| 6 | - */ | |
| 7 | 2 | |
| 8 | 3 | namespace RadiusTheme\SB\Controllers\Admin; |
| 9 | 4 | |
| 10 | 5 | defined( 'ABSPATH' ) || exit(); |
| 11 | 6 | |
| 7 | +use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; | |
| 12 | 8 | use RadiusTheme\SB\Helpers\Fns; |
| 13 | 9 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 14 | -use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; | |
| 15 | 10 | |
| 16 | -/** | |
| 17 | - * Admin Init. | |
| 18 | - */ | |
| 11 | + | |
| 19 | 12 | class AdminInit { |
| 20 | 13 | /** |
| 21 | 14 | * Parent Menu Page Slug |
| 22 | 15 | */ |
| @@ -31,16 +24,17 @@ | ||
| 31 | 24 | * Parent Menu Hook |
| 32 | 25 | * |
| 33 | 26 | * @var string |
| 34 | 27 | */ |
| 35 | - public static $parent_menu_hook = ''; | |
| 28 | + static $parent_menu_hook = ''; | |
| 36 | 29 | |
| 30 | + // private $menu_link_part; | |
| 31 | + | |
| 37 | 32 | use SingletonTrait; |
| 38 | 33 | |
| 39 | - /** | |
| 40 | - * Class constructor. | |
| 41 | - */ | |
| 42 | 34 | public function __construct() { |
| 35 | + // $this->menu_link_part = admin_url( 'admin.php?page=rtsb' ); | |
| 36 | + $this->remove_all_notices(); | |
| 43 | 37 | $this->init(); |
| 44 | 38 | $this->ajax_actions(); |
| 45 | 39 | $this->upgrade(); |
| 46 | 40 | } |
| @@ -51,12 +45,10 @@ | ||
| 51 | 45 | * @return void |
| 52 | 46 | */ |
| 53 | 47 | public function ajax_actions() { |
| 54 | 48 | Ajax\DefaultTemplate::instance(); |
| 55 | - if ( defined( 'ELEMENTOR_VERSION' ) ) { // Elementor Check. | |
| 56 | - Ajax\CreateTemplate::instance(); | |
| 57 | - } | |
| 58 | 49 | Ajax\ModalTemplate::instance(); |
| 50 | + Ajax\CreateTemplate::instance(); | |
| 59 | 51 | Ajax\AdminSettings::instance(); |
| 60 | 52 | } |
| 61 | 53 | |
| 62 | 54 | /** |
| @@ -65,32 +57,17 @@ | ||
| 65 | 57 | * @return void |
| 66 | 58 | */ |
| 67 | 59 | public function upgrade() { |
| 68 | 60 | Notice\Upgrade::instance(); |
| 69 | - // phpcs:ignore Squiz.PHP.CommentedOutCode.Found | |
| 70 | - // Notice\BFDiscount::instance();. | |
| 71 | - // phpcs:ignore Squiz.PHP.CommentedOutCode.Found | |
| 72 | - // Notice\BlackFridayV2::instance();. | |
| 73 | 61 | Notice\Review::instance(); |
| 74 | - Notice\CachePermission::instance(); | |
| 62 | + Notice\EarlyBirdDiscount::instance(); | |
| 75 | 63 | } |
| 76 | 64 | |
| 77 | - /** | |
| 78 | - * Init. | |
| 79 | - * | |
| 80 | - * @return void | |
| 81 | - */ | |
| 82 | 65 | public function init() { |
| 83 | 66 | add_action( 'admin_menu', [ $this, 'add_menu' ], 25 ); |
| 84 | - add_action( 'in_admin_header', [ $this, 'in_admin_header_functionality' ], 1000 ); | |
| 85 | - // PluginRow registered earlier in ShopBuilder::init() so it survives dependency failures. | |
| 67 | + PluginRow::instance(); | |
| 86 | 68 | } |
| 87 | 69 | |
| 88 | - /** | |
| 89 | - * Add menu. | |
| 90 | - * | |
| 91 | - * @return void | |
| 92 | - */ | |
| 93 | 70 | public function add_menu() { |
| 94 | 71 | self::$parent_menu_hook = add_menu_page( |
| 95 | 72 | esc_html__( 'ShopBuilder', 'shopbuilder' ), |
| 96 | 73 | esc_html__( 'ShopBuilder', 'shopbuilder' ), |
| @@ -126,26 +103,17 @@ | ||
| 126 | 103 | [ $this, 'get_themes_page' ], |
| 127 | 104 | ); |
| 128 | 105 | do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY ); |
| 129 | 106 | |
| 130 | - // Remove Parent Submenu. | |
| 107 | + // Remove Parent Submenu | |
| 131 | 108 | remove_submenu_page( self::MENU_PAGE_SLUG, self::MENU_PAGE_SLUG ); |
| 132 | 109 | } |
| 133 | 110 | |
| 134 | - /** | |
| 135 | - * Redirect to content. | |
| 136 | - * | |
| 137 | - * @return void | |
| 138 | - */ | |
| 139 | - public function redirect_to_content() { | |
| 140 | - wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect | |
| 111 | + function redirect_to_content() { | |
| 112 | + wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) ); | |
| 141 | 113 | } |
| 142 | 114 | |
| 143 | - /** | |
| 144 | - * Settings Page. | |
| 145 | - * | |
| 146 | - * @return void | |
| 147 | - */ | |
| 115 | + | |
| 148 | 116 | public function settings_page() { |
| 149 | 117 | ?> |
| 150 | 118 | <div class="wrap rtsb-admin-wrap"> |
| 151 | 119 | <div id="rtsb-admin-app"></div> |
| @@ -152,83 +120,34 @@ | ||
| 152 | 120 | </div> |
| 153 | 121 | <?php |
| 154 | 122 | } |
| 155 | 123 | |
| 156 | - /** | |
| 157 | - * Help Page. | |
| 158 | - * | |
| 159 | - * @return void | |
| 160 | - */ | |
| 161 | 124 | public function get_help_page() { |
| 162 | 125 | Fns::renderView( 'help' ); |
| 163 | 126 | } |
| 164 | 127 | |
| 165 | - /** | |
| 166 | - * Themes Page. | |
| 167 | - * | |
| 168 | - * @return void | |
| 169 | - */ | |
| 170 | 128 | public function get_themes_page() { |
| 171 | 129 | Fns::renderView( 'themes' ); |
| 172 | 130 | } |
| 173 | 131 | |
| 174 | 132 | /** |
| 175 | - * Admin Header | |
| 133 | + * Remove admin notices | |
| 176 | 134 | */ |
| 177 | - public function in_admin_header_functionality() { | |
| 178 | - $screen = get_current_screen(); | |
| 179 | - $isBuilderTemplate = 'edit-rtsb_builder' === $screen->id; | |
| 180 | - $pages = [ | |
| 181 | - 'shopbuilder_page_rtsb-get-help', | |
| 182 | - 'shopbuilder_page_rtsb-settings', | |
| 183 | - 'shopbuilder_page_rtsb-license', | |
| 184 | - 'shopbuilder_page_rtsb-themes', | |
| 185 | - ]; | |
| 186 | - $isSettingsPage = in_array( $screen->base, $pages, true ); | |
| 187 | - if ( $isBuilderTemplate || $isSettingsPage ) { | |
| 188 | - remove_all_actions( 'admin_notices' ); | |
| 189 | - remove_all_actions( 'all_admin_notices' ); | |
| 190 | - } | |
| 135 | + public function remove_all_notices() { | |
| 136 | + add_action( | |
| 137 | + 'in_admin_header', | |
| 138 | + function () { | |
| 139 | + $screen = get_current_screen(); | |
| 191 | 140 | |
| 192 | - $load_elementor_scripts = Fns::should_load_elementor_scripts(); | |
| 193 | - | |
| 194 | - if ( $isBuilderTemplate ) { | |
| 195 | - if ( ! defined( 'ELEMENTOR_VERSION' ) && $load_elementor_scripts ) { | |
| 196 | - ?> | |
| 197 | - <div class='rtsb-message-for-elementor-missing'> | |
| 198 | - <div class="rtsb-builder-notice-content"> | |
| 199 | - <?php | |
| 200 | - echo sprintf( | |
| 201 | - /* translators: %s: Elementor */ | |
| 202 | - esc_html__( 'To build your WooCommerce pages, please Install and Activate the %s Plugin.', 'shopbuilder' ), | |
| 203 | - '<a href="' . esc_url( admin_url( 'plugin-install.php?s=elementor&tab=search&type=term' ) ) . '" target="_blank">' . esc_html__( 'Elementor Website Builder', 'shopbuilder' ) . '</a>' | |
| 204 | - ); | |
| 205 | - ?> | |
| 206 | - </div> | |
| 207 | - </div> | |
| 208 | - <?php | |
| 209 | - } elseif ( defined( 'ELEMENTOR_VERSION' ) && ! $load_elementor_scripts ) { | |
| 210 | - ?> | |
| 211 | - <div class='rtsb-message-for-elementor-missing'> | |
| 212 | - <div class="rtsb-builder-notice-content"> | |
| 213 | - <?php esc_html_e( 'Elementor is installed, but script loading is disabled. Please enable "Load Elementor Scripts" in the Advanced Optimization Settings.', 'shopbuilder' ); ?> | |
| 214 | - </div> | |
| 215 | - </div> | |
| 216 | - <?php | |
| 217 | - } elseif ( ! defined( 'ELEMENTOR_VERSION' ) && ! $load_elementor_scripts ) { | |
| 218 | - ?> | |
| 219 | - <div class='rtsb-message-for-elementor-missing'> | |
| 220 | - <div class="rtsb-builder-notice-content"> | |
| 221 | - <?php | |
| 222 | - echo sprintf( | |
| 223 | - /* translators: %s: Elementor */ | |
| 224 | - esc_html__( 'To build your WooCommerce pages, please Install and Activate the %s Plugin.', 'shopbuilder' ), | |
| 225 | - '<a href="' . esc_url( admin_url( 'plugin-install.php?s=Elementor%2520Website%2520Builder&tab=search&type=term' ) ) . '" target="_blank">' . esc_html__( 'Elementor Website Builder', 'shopbuilder' ) . '</a>' | |
| 226 | - ); | |
| 227 | - ?> | |
| 228 | - </div> | |
| 229 | - </div> | |
| 230 | - <?php | |
| 231 | - } | |
| 232 | - } | |
| 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 | + ); | |
| 233 | 152 | } |
| 234 | 153 | } |