PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.0
ShopBuilder – WooCommerce Builder For Elementor v3.4.0
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/Admin/AdminInit.php +132 -37 2.0.13.4.0 View file →
@@ -1,13 +1,22 @@
1 1 <?php
2 +/**
3 + * Admin Init.
4 + *
5 + * @package RadiusTheme\SB
6 + */
2 7
3 8 namespace RadiusTheme\SB\Controllers\Admin;
4 9
5 10 defined( 'ABSPATH' ) || exit();
6 11
12 +use RadiusTheme\SB\Helpers\Fns;
13 +use RadiusTheme\SB\Traits\SingletonTrait;
7 14 use RadiusTheme\SB\Controllers\Admin\Ajax as Ajax;
8 -use RadiusTheme\SB\Traits\SingletonTrait;
9 15
16 +/**
17 + * Admin Init.
18 + */
10 19 class AdminInit {
11 20 /**
12 21 * Parent Menu Page Slug
13 22 */
@@ -22,17 +31,16 @@
22 31 * Parent Menu Hook
23 32 *
24 33 * @var string
25 34 */
26 - static $parent_menu_hook = '';
35 + public static $parent_menu_hook = '';
27 36
28 - //private $menu_link_part;
29 -
30 37 use SingletonTrait;
31 38
39 + /**
40 + * Class constructor.
41 + */
32 42 public function __construct() {
33 - // $this->menu_link_part = admin_url( 'admin.php?page=rtsb' );
34 - $this->remove_all_notices();
35 43 $this->init();
36 44 $this->ajax_actions();
37 45 $this->upgrade();
38 46 }
@@ -43,10 +51,12 @@
43 51 * @return void
44 52 */
45 53 public function ajax_actions() {
46 54 Ajax\DefaultTemplate::instance();
55 + if ( defined( 'ELEMENTOR_VERSION' ) ) { // Elementor Check.
56 + Ajax\CreateTemplate::instance();
57 + }
47 58 Ajax\ModalTemplate::instance();
48 - Ajax\CreateTemplate::instance();
49 59 Ajax\AdminSettings::instance();
50 60 }
51 61
52 62 /**
@@ -55,15 +65,32 @@
55 65 * @return void
56 66 */
57 67 public function upgrade() {
58 68 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();
59 75 }
60 76
77 + /**
78 + * Init.
79 + *
80 + * @return void
81 + */
61 82 public function init() {
62 83 add_action( 'admin_menu', [ $this, 'add_menu' ], 25 );
63 - PluginRow::instance();
84 + add_action( 'in_admin_header', [ $this, 'in_admin_header_functionality' ], 1000 );
85 + // PluginRow registered earlier in ShopBuilder::init() so it survives dependency failures.
64 86 }
65 87
88 + /**
89 + * Add menu.
90 + *
91 + * @return void
92 + */
66 93 public function add_menu() {
67 94 self::$parent_menu_hook = add_menu_page(
68 95 esc_html__( 'ShopBuilder', 'shopbuilder' ),
69 96 esc_html__( 'ShopBuilder', 'shopbuilder' ),
@@ -81,11 +108,8 @@
81 108 self::MENU_CAPABILITY,
82 109 'rtsb-settings',
83 110 [ $this, 'settings_page' ],
84 111 );
85 -
86 - do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY );
87 - /*
88 112 add_submenu_page(
89 113 self::MENU_PAGE_SLUG,
90 114 esc_html__( 'Get Help', 'shopbuilder' ),
91 115 esc_html__( 'Get Help', 'shopbuilder' ),
@@ -92,48 +116,119 @@
92 116 self::MENU_CAPABILITY,
93 117 'rtsb-get-help',
94 118 [ $this, 'get_help_page' ],
95 119 );
96 - */
97 - // Remove Parent Submenu
120 + add_submenu_page(
121 + self::MENU_PAGE_SLUG,
122 + esc_html__( 'Themes & Apps', 'shopbuilder' ),
123 + esc_html__( 'Themes & Apps', '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.
98 131 remove_submenu_page( self::MENU_PAGE_SLUG, self::MENU_PAGE_SLUG );
99 132 }
100 133
101 - function redirect_to_content() {
102 - wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) );
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
103 141 }
104 142
105 -
143 + /**
144 + * Settings Page.
145 + *
146 + * @return void
147 + */
106 148 public function settings_page() {
107 149 ?>
108 - <div class="wrap rtsb-admin-wrap">
109 - <div id="rtsb-admin-app"></div>
110 - </div>
150 + <div class="wrap rtsb-admin-wrap">
151 + <div id="rtsb-admin-app"></div>
152 + </div>
111 153 <?php
112 154 }
113 155
156 + /**
157 + * Help Page.
158 + *
159 + * @return void
160 + */
114 161 public function get_help_page() {
115 - ?>
116 - <div class="wrap rtsb-get-help-wrap">
117 - Get Help
118 - </div>
119 - <?php
162 + Fns::renderView( 'help' );
120 163 }
121 164
122 165 /**
123 - * Remove admin notices
166 + * Themes Page.
167 + *
168 + * @return void
124 169 */
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 - );
170 + public function get_themes_page() {
171 + Fns::renderView( 'themes' );
137 172 }
138 173
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 + }
139 234 }