PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.1.3
ShopBuilder – WooCommerce Builder For Elementor v3.1.3
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 +128 -37 2.0.23.1.3 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,16 +65,29 @@
55 65 * @return void
56 66 */
57 67 public function upgrade() {
58 68 Notice\Upgrade::instance();
59 - Notice\BlackFriday::instance();
69 + // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
70 + // Notice\BFDiscount::instance();.
71 + Notice\Review::instance();
60 72 }
61 73
74 + /**
75 + * Init.
76 + *
77 + * @return void
78 + */
62 79 public function init() {
63 80 add_action( 'admin_menu', [ $this, 'add_menu' ], 25 );
81 + add_action( 'in_admin_header', [ $this, 'in_admin_header_functionality' ], 1000 );
64 82 PluginRow::instance();
65 83 }
66 84
85 + /**
86 + * Add menu.
87 + *
88 + * @return void
89 + */
67 90 public function add_menu() {
68 91 self::$parent_menu_hook = add_menu_page(
69 92 esc_html__( 'ShopBuilder', 'shopbuilder' ),
70 93 esc_html__( 'ShopBuilder', 'shopbuilder' ),
@@ -82,11 +105,8 @@
82 105 self::MENU_CAPABILITY,
83 106 'rtsb-settings',
84 107 [ $this, 'settings_page' ],
85 108 );
86 -
87 - do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY );
88 - /*
89 109 add_submenu_page(
90 110 self::MENU_PAGE_SLUG,
91 111 esc_html__( 'Get Help', 'shopbuilder' ),
92 112 esc_html__( 'Get Help', 'shopbuilder' ),
@@ -93,48 +113,119 @@
93 113 self::MENU_CAPABILITY,
94 114 'rtsb-get-help',
95 115 [ $this, 'get_help_page' ],
96 116 );
97 - */
98 - // Remove Parent Submenu
117 + add_submenu_page(
118 + self::MENU_PAGE_SLUG,
119 + esc_html__( 'Themes & Apps', 'shopbuilder' ),
120 + esc_html__( 'Themes & Apps', 'shopbuilder' ),
121 + self::MENU_CAPABILITY,
122 + 'rtsb-themes',
123 + [ $this, 'get_themes_page' ],
124 + );
125 + do_action( 'rtsb/add/more/submenu', self::MENU_PAGE_SLUG, self::MENU_CAPABILITY );
126 +
127 + // Remove Parent Submenu.
99 128 remove_submenu_page( self::MENU_PAGE_SLUG, self::MENU_PAGE_SLUG );
100 129 }
101 130
102 - function redirect_to_content() {
103 - wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) );
131 + /**
132 + * Redirect to content.
133 + *
134 + * @return void
135 + */
136 + public function redirect_to_content() {
137 + wp_redirect( admin_url( 'admin.php?page=rtsb-settings' ) ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
104 138 }
105 139
106 -
140 + /**
141 + * Settings Page.
142 + *
143 + * @return void
144 + */
107 145 public function settings_page() {
108 146 ?>
109 - <div class="wrap rtsb-admin-wrap">
110 - <div id="rtsb-admin-app"></div>
111 - </div>
147 + <div class="wrap rtsb-admin-wrap">
148 + <div id="rtsb-admin-app"></div>
149 + </div>
112 150 <?php
113 151 }
114 152
153 + /**
154 + * Help Page.
155 + *
156 + * @return void
157 + */
115 158 public function get_help_page() {
116 - ?>
117 - <div class="wrap rtsb-get-help-wrap">
118 - Get Help
119 - </div>
120 - <?php
159 + Fns::renderView( 'help' );
121 160 }
122 161
123 162 /**
124 - * Remove admin notices
163 + * Themes Page.
164 + *
165 + * @return void
125 166 */
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 - );
167 + public function get_themes_page() {
168 + Fns::renderView( 'themes' );
138 169 }
139 170
171 + /**
172 + * Admin Header
173 + */
174 + public function in_admin_header_functionality() {
175 + $screen = get_current_screen();
176 + $isBuilderTemplate = 'edit-rtsb_builder' === $screen->id;
177 + $pages = [
178 + 'shopbuilder_page_rtsb-get-help',
179 + 'shopbuilder_page_rtsb-settings',
180 + 'shopbuilder_page_rtsb-license',
181 + 'shopbuilder_page_rtsb-themes',
182 + ];
183 + $isSettingsPage = in_array( $screen->base, $pages, true );
184 + if ( $isBuilderTemplate || $isSettingsPage ) {
185 + remove_all_actions( 'admin_notices' );
186 + remove_all_actions( 'all_admin_notices' );
187 + }
188 +
189 + $load_elementor_scripts = Fns::should_load_elementor_scripts();
190 +
191 + if ( $isBuilderTemplate ) {
192 + if ( ! defined( 'ELEMENTOR_VERSION' ) && $load_elementor_scripts ) {
193 + ?>
194 + <div class='rtsb-message-for-elementor-missing'>
195 + <div class="rtsb-builder-notice-content">
196 + <?php
197 + echo sprintf(
198 + /* translators: %s: Elementor */
199 + esc_html__( 'To build your WooCommerce pages, please Install and Activate the %s Plugin.', 'shopbuilder' ),
200 + '<a href="' . esc_url( admin_url( 'plugin-install.php?s=elementor&tab=search&type=term' ) ) . '" target="_blank">' . esc_html__( 'Elementor Website Builder', 'shopbuilder' ) . '</a>'
201 + );
202 + ?>
203 + </div>
204 + </div>
205 + <?php
206 + } elseif ( defined( 'ELEMENTOR_VERSION' ) && ! $load_elementor_scripts ) {
207 + ?>
208 + <div class='rtsb-message-for-elementor-missing'>
209 + <div class="rtsb-builder-notice-content">
210 + <?php esc_html_e( 'Elementor is installed, but script loading is disabled. Please enable "Load Elementor Scripts" in the Advanced Optimization Settings.', 'shopbuilder' ); ?>
211 + </div>
212 + </div>
213 + <?php
214 + } elseif ( ! defined( 'ELEMENTOR_VERSION' ) && ! $load_elementor_scripts ) {
215 + ?>
216 + <div class='rtsb-message-for-elementor-missing'>
217 + <div class="rtsb-builder-notice-content">
218 + <?php
219 + echo sprintf(
220 + /* translators: %s: Elementor */
221 + esc_html__( 'To build your WooCommerce pages, please Install and Activate the %s Plugin.', 'shopbuilder' ),
222 + '<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>'
223 + );
224 + ?>
225 + </div>
226 + </div>
227 + <?php
228 + }
229 + }
230 + }
140 231 }