| @@ -1,22 +1,13 @@ | ||
| 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 | |
| 12 | -use RadiusTheme\SB\Helpers\Fns; | |
| 7 | +use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; | |
| 13 | 8 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 14 | -use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; | |
| 15 | 9 | |
| 16 | -/** | |
| 17 | - * Admin Init. | |
| 18 | - */ | |
| 19 | 10 | class AdminInit { |
| 20 | 11 | /** |
| 21 | 12 | * Parent Menu Page Slug |
| 22 | 13 | */ |
| @@ -31,16 +22,17 @@ | ||
| 31 | 22 | * Parent Menu Hook |
| 32 | 23 | * |
| 33 | 24 | * @var string |
| 34 | 25 | */ |
| 35 | - public static $parent_menu_hook = ''; | |
| 26 | + static $parent_menu_hook = ''; | |
| 36 | 27 | |
| 28 | + //private $menu_link_part; | |
| 29 | + | |
| 37 | 30 | use SingletonTrait; |
| 38 | 31 | |
| 39 | - /** | |
| 40 | - * Class constructor. | |
| 41 | - */ | |
| 42 | 32 | public function __construct() { |
| 33 | + // $this->menu_link_part = admin_url( 'admin.php?page=rtsb' ); | |
| 34 | + $this->remove_all_notices(); | |
| 43 | 35 | $this->init(); |
| 44 | 36 | $this->ajax_actions(); |
| 45 | 37 | $this->upgrade(); |
| 46 | 38 | } |
| @@ -51,12 +43,10 @@ | ||
| 51 | 43 | * @return void |
| 52 | 44 | */ |
| 53 | 45 | public function ajax_actions() { |
| 54 | 46 | Ajax\DefaultTemplate::instance(); |
| 55 | - if ( defined( 'ELEMENTOR_VERSION' ) ) { // Elementor Check. | |
| 56 | - Ajax\CreateTemplate::instance(); | |
| 57 | - } | |
| 58 | 47 | Ajax\ModalTemplate::instance(); |
| 48 | + Ajax\CreateTemplate::instance(); | |
| 59 | 49 | Ajax\AdminSettings::instance(); |
| 60 | 50 | } |
| 61 | 51 | |
| 62 | 52 | /** |
| @@ -65,32 +55,15 @@ | ||
| 65 | 55 | * @return void |
| 66 | 56 | */ |
| 67 | 57 | public function upgrade() { |
| 68 | 58 | 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 | - Notice\Review::instance(); | |
| 74 | - Notice\CachePermission::instance(); | |
| 75 | 59 | } |
| 76 | 60 | |
| 77 | - /** | |
| 78 | - * Init. | |
| 79 | - * | |
| 80 | - * @return void | |
| 81 | - */ | |
| 82 | 61 | public function init() { |
| 83 | 62 | 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. | |
| 63 | + PluginRow::instance(); | |
| 86 | 64 | } |
| 87 | 65 | |
| 88 | - /** | |
| 89 | - * Add menu. | |
| 90 | - * | |
| 91 | - * @return void | |
| 92 | - */ | |
| 93 | 66 | public function add_menu() { |
| 94 | 67 | self::$parent_menu_hook = add_menu_page( |
| 95 | 68 | esc_html__( 'ShopBuilder', 'shopbuilder' ), |
| 96 | 69 | esc_html__( 'ShopBuilder', 'shopbuilder' ), |
| @@ -108,8 +81,11 @@ | ||
| 108 | 81 | self::MENU_CAPABILITY, |
| 109 | 82 | 'rtsb-settings', |
| 110 | 83 | [ $this, 'settings_page' ], |
| 111 | 84 | ); |
| 85 | + | |
| 86 | + do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY ); | |
| 87 | + /* | |
| 112 | 88 | add_submenu_page( |
| 113 | 89 | self::MENU_PAGE_SLUG, |
| 114 | 90 | esc_html__( 'Get Help', 'shopbuilder' ), |
| 115 | 91 | esc_html__( 'Get Help', 'shopbuilder' ), |
| @@ -116,119 +92,48 @@ | ||
| 116 | 92 | self::MENU_CAPABILITY, |
| 117 | 93 | 'rtsb-get-help', |
| 118 | 94 | [ $this, 'get_help_page' ], |
| 119 | 95 | ); |
| 120 | - add_submenu_page( | |
| 121 | - self::MENU_PAGE_SLUG, | |
| 122 | - esc_html__( 'Themes', 'shopbuilder' ), | |
| 123 | - esc_html__( 'Themes', 'shopbuilder' ), | |
| 124 | - self::MENU_CAPABILITY, | |
| 125 | - 'rtsb-themes', | |
| 126 | - [ $this, 'get_themes_page' ], | |
| 127 | - ); | |
| 128 | - do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY ); | |
| 129 | - | |
| 130 | - // Remove Parent Submenu. | |
| 96 | + */ | |
| 97 | + // Remove Parent Submenu | |
| 131 | 98 | remove_submenu_page( self::MENU_PAGE_SLUG, self::MENU_PAGE_SLUG ); |
| 132 | 99 | } |
| 133 | 100 | |
| 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 | |
| 101 | + function redirect_to_content() { | |
| 102 | + wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) ); | |
| 141 | 103 | } |
| 142 | 104 | |
| 143 | - /** | |
| 144 | - * Settings Page. | |
| 145 | - * | |
| 146 | - * @return void | |
| 147 | - */ | |
| 105 | + | |
| 148 | 106 | public function settings_page() { |
| 149 | 107 | ?> |
| 150 | - <div class="wrap rtsb-admin-wrap"> | |
| 151 | - <div id="rtsb-admin-app"></div> | |
| 152 | - </div> | |
| 108 | + <div class="wrap rtsb-admin-wrap"> | |
| 109 | + <div id="rtsb-admin-app"></div> | |
| 110 | + </div> | |
| 153 | 111 | <?php |
| 154 | 112 | } |
| 155 | 113 | |
| 156 | - /** | |
| 157 | - * Help Page. | |
| 158 | - * | |
| 159 | - * @return void | |
| 160 | - */ | |
| 161 | 114 | public function get_help_page() { |
| 162 | - Fns::renderView( 'help' ); | |
| 115 | + ?> | |
| 116 | + <div class="wrap rtsb-get-help-wrap"> | |
| 117 | + Get Help | |
| 118 | + </div> | |
| 119 | + <?php | |
| 163 | 120 | } |
| 164 | 121 | |
| 165 | 122 | /** |
| 166 | - * Themes Page. | |
| 167 | - * | |
| 168 | - * @return void | |
| 123 | + * Remove admin notices | |
| 169 | 124 | */ |
| 170 | - public function get_themes_page() { | |
| 171 | - Fns::renderView( 'themes' ); | |
| 125 | + public function remove_all_notices() { | |
| 126 | + add_action( | |
| 127 | + 'in_admin_header', | |
| 128 | + function () { | |
| 129 | + $screen = get_current_screen(); | |
| 130 | + if ( in_array( $screen->base, [ 'shopbuilder_page_rtsb-settings', 'shopbuilder_page_rtsb-license' ]) ) { | |
| 131 | + remove_all_actions( 'admin_notices' ); | |
| 132 | + remove_all_actions( 'all_admin_notices' ); | |
| 133 | + } | |
| 134 | + }, | |
| 135 | + 1000 | |
| 136 | + ); | |
| 172 | 137 | } |
| 173 | 138 | |
| 174 | - /** | |
| 175 | - * Admin Header | |
| 176 | - */ | |
| 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 | - } | |
| 191 | - | |
| 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 | - } | |
| 233 | - } | |
| 234 | 139 | } |