| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | defined( 'ABSPATH' ) || exit(); |
| 6 | 6 | |
| 7 | 7 | use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax; |
| 8 | +use RadiusTheme\SB\Helpers\Fns; | |
| 8 | 9 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 9 | 10 | |
| 10 | 11 | class AdminInit { |
| 11 | 12 | /** |
| @@ -24,15 +25,13 @@ | ||
| 24 | 25 | * @var string |
| 25 | 26 | */ |
| 26 | 27 | static $parent_menu_hook = ''; |
| 27 | 28 | |
| 28 | - //private $menu_link_part; | |
| 29 | + // private $menu_link_part; | |
| 29 | 30 | |
| 30 | 31 | use SingletonTrait; |
| 31 | 32 | |
| 32 | 33 | public function __construct() { |
| 33 | - // $this->menu_link_part = admin_url( 'admin.php?page=rtsb' ); | |
| 34 | - $this->remove_all_notices(); | |
| 35 | 34 | $this->init(); |
| 36 | 35 | $this->ajax_actions(); |
| 37 | 36 | $this->upgrade(); |
| 38 | 37 | } |
| @@ -43,10 +42,12 @@ | ||
| 43 | 42 | * @return void |
| 44 | 43 | */ |
| 45 | 44 | public function ajax_actions() { |
| 46 | 45 | Ajax\DefaultTemplate::instance(); |
| 46 | + if ( defined( 'ELEMENTOR_VERSION' ) ) { // Elementor Check. | |
| 47 | + Ajax\CreateTemplate::instance(); | |
| 48 | + } | |
| 47 | 49 | Ajax\ModalTemplate::instance(); |
| 48 | - Ajax\CreateTemplate::instance(); | |
| 49 | 50 | Ajax\AdminSettings::instance(); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | /** |
| @@ -55,13 +56,15 @@ | ||
| 55 | 56 | * @return void |
| 56 | 57 | */ |
| 57 | 58 | public function upgrade() { |
| 58 | 59 | Notice\Upgrade::instance(); |
| 59 | - Notice\BlackFriday::instance(); | |
| 60 | + Notice\BFDiscount::instance(); | |
| 61 | + Notice\Review::instance(); | |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | public function init() { |
| 63 | 65 | add_action( 'admin_menu', [ $this, 'add_menu' ], 25 ); |
| 66 | + add_action( 'in_admin_header', [ $this, 'in_admin_header_functionality' ], 1000 ); | |
| 64 | 67 | PluginRow::instance(); |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | public function add_menu() { |
| @@ -82,11 +85,8 @@ | ||
| 82 | 85 | self::MENU_CAPABILITY, |
| 83 | 86 | 'rtsb-settings', |
| 84 | 87 | [ $this, 'settings_page' ], |
| 85 | 88 | ); |
| 86 | - | |
| 87 | - do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY ); | |
| 88 | - /* | |
| 89 | 89 | add_submenu_page( |
| 90 | 90 | self::MENU_PAGE_SLUG, |
| 91 | 91 | esc_html__( 'Get Help', 'shopbuilder' ), |
| 92 | 92 | esc_html__( 'Get Help', 'shopbuilder' ), |
| @@ -93,9 +93,18 @@ | ||
| 93 | 93 | self::MENU_CAPABILITY, |
| 94 | 94 | 'rtsb-get-help', |
| 95 | 95 | [ $this, 'get_help_page' ], |
| 96 | 96 | ); |
| 97 | - */ | |
| 97 | + add_submenu_page( | |
| 98 | + self::MENU_PAGE_SLUG, | |
| 99 | + esc_html__( 'Themes & Apps', 'shopbuilder' ), | |
| 100 | + esc_html__( 'Themes & Apps', 'shopbuilder' ), | |
| 101 | + self::MENU_CAPABILITY, | |
| 102 | + 'rtsb-themes', | |
| 103 | + [ $this, 'get_themes_page' ], | |
| 104 | + ); | |
| 105 | + do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY ); | |
| 106 | + | |
| 98 | 107 | // Remove Parent Submenu |
| 99 | 108 | remove_submenu_page( self::MENU_PAGE_SLUG, self::MENU_PAGE_SLUG ); |
| 100 | 109 | } |
| 101 | 110 | |
| @@ -105,36 +114,52 @@ | ||
| 105 | 114 | |
| 106 | 115 | |
| 107 | 116 | public function settings_page() { |
| 108 | 117 | ?> |
| 109 | - <div class="wrap rtsb-admin-wrap"> | |
| 110 | - <div id="rtsb-admin-app"></div> | |
| 111 | - </div> | |
| 118 | + <div class="wrap rtsb-admin-wrap"> | |
| 119 | + <div id="rtsb-admin-app"></div> | |
| 120 | + </div> | |
| 112 | 121 | <?php |
| 113 | 122 | } |
| 114 | 123 | |
| 115 | 124 | public function get_help_page() { |
| 116 | - ?> | |
| 117 | - <div class="wrap rtsb-get-help-wrap"> | |
| 118 | - Get Help | |
| 119 | - </div> | |
| 120 | - <?php | |
| 125 | + Fns::renderView( 'help' ); | |
| 121 | 126 | } |
| 122 | 127 | |
| 128 | + public function get_themes_page() { | |
| 129 | + Fns::renderView( 'themes' ); | |
| 130 | + } | |
| 131 | + | |
| 123 | 132 | /** |
| 124 | - * Remove admin notices | |
| 133 | + * Admin Header | |
| 125 | 134 | */ |
| 126 | - public function remove_all_notices() { | |
| 127 | - add_action( | |
| 128 | - 'in_admin_header', | |
| 129 | - function () { | |
| 130 | - $screen = get_current_screen(); | |
| 131 | - if ( in_array( $screen->base, [ 'shopbuilder_page_rtsb-settings', 'shopbuilder_page_rtsb-license' ]) ) { | |
| 132 | - remove_all_actions( 'admin_notices' ); | |
| 133 | - remove_all_actions( 'all_admin_notices' ); | |
| 134 | - } | |
| 135 | - }, | |
| 136 | - 1000 | |
| 137 | - ); | |
| 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 | + } | |
| 138 | 164 | } |
| 139 | - | |
| 140 | 165 | } |