PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets / 4.9.5
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / core / settings / base.php
shopengine / core / settings Last commit date
screens 4 years ago action.php 1 week ago api.php 1 week ago base.php 1 week ago plugin-status.php 4 years ago
base.php
249 lines
1 <?php
2
3 namespace ShopEngine\Core\Settings;
4
5 use ShopEngine\Core\Builders\Action;
6 use ShopEngine\Core\PageTemplates\Page_Templates;
7 use ShopEngine\Core\Template_Cpt;
8 use ShopEngine\Traits\Singleton;
9
10 defined('ABSPATH') || exit;
11
12 class Base {
13 use Singleton;
14
15 private $menu_link_part;
16
17
18 /**
19 *
20 * @since 1.0.0
21 *
22 */
23 public function init() {
24
25 new Api();
26
27 $this->menu_link_part = admin_url('edit.php?post_type=' . \ShopEngine\Core\Template_Cpt::TYPE);
28
29 // check permission for manage user
30 if(current_user_can('manage_options')) {
31 add_action('admin_menu', [$this, 'menu_getting_started']);
32 add_action('admin_menu', [$this, 'menu_others'], 100);
33 }
34
35 add_action('admin_enqueue_scripts', function () {
36 //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Just checking post type shopengine template or not
37 if(isset($_REQUEST['post_type']) && sanitize_text_field(wp_unslash($_REQUEST['post_type'])) === \ShopEngine\Core\Template_Cpt::TYPE) {
38
39 if(function_exists('wc_get_products') && !\ShopEngine\Core\Builders\Templates::has_simple_product()) {
40
41 \ShopEngine\Core\Builders\Templates::create_wc_simple_product();
42 }
43 }
44 } );
45
46 add_action('before_delete_post', function($post_id, $post) {
47 if('shopengine-template' === $post->post_type) {
48 Action::delete_template_form_activated_list($post_id);
49 }
50 }, 10, 2);
51
52 add_action('admin_head', [$this, 'admin_head_enqueue_scripts']);
53 add_action('admin_enqueue_scripts', [$this, 'js_css_admin']);
54 add_action('admin_footer', [$this, 'content']);
55 }
56
57 public function admin_head_enqueue_scripts() {
58 echo "<script>
59 jQuery(document).ready( function($) {
60 $('.toplevel_page_shopengine-settings').find('.wp-first-item').css({display:'none'});
61 $('.shopengine_pro_aware').parent().attr('target','_blank');
62 });
63 </script>";
64 }
65
66 public function js_css_admin() {
67
68 wp_enqueue_style('shopengine-admin-style-common', \ShopEngine::plugin_url() . 'assets/css/admin-style-common.css', false, \ShopEngine::version());
69 wp_enqueue_style('shopnegine-panel-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
70
71 if (is_plugin_active('tiktok-for-business/tiktok-for-woocommerce.php')) {
72 wp_dequeue_style('tts_order_css');
73 wp_dequeue_script('tts_order_js');
74 }
75
76 // get screen id
77 $screen = get_current_screen();
78
79 $cptName = \ShopEngine\Core\Template_Cpt::TYPE;
80
81 $dashboardPage = 'toplevel_page_shopengine-settings';
82
83 if(in_array($screen->id, ['edit-' . $cptName, 'shopengine_page_mt-form-settings', $dashboardPage])) {
84
85 wp_enqueue_script('htm', \ShopEngine::plugin_url() . 'assets/js/htm.js', null, \ShopEngine::version(), true);
86
87 wp_enqueue_script('shopengine-admin-js', \ShopEngine::plugin_url() . 'assets/js/app.js', ['htm', 'jquery', 'wp-element', 'wp-i18n'], \ShopEngine::version(), true);
88
89 wp_set_script_translations('shopengine-admin-js', 'shopengine', \ShopEngine::plugin_dir() . 'languages');
90
91 // page template lists
92 $page_templates = Page_Templates::instance()->getTemplates();
93
94 wp_localize_script('shopengine-admin-js', 'shopengine_admin_var', [
95 'version' => \ShopEngine::version(),
96 'package_type' => \ShopEngine::package_type(),
97 'license_status' => \ShopEngine::license_status(),
98 'cpt' => $cptName,
99 'resturl' => get_rest_url(),
100 'adminurl' => get_admin_url(),
101 'siteurl' => get_option('siteurl'),
102 'rest_nonce' => wp_create_nonce('wp_rest'),
103 'plugin_url' => \ShopEngine::plugin_url(),
104 'pricing_page' => \ShopEngine::landing_page(),
105 'form_prefix' => \ShopEngine::SHOPENGINE_PREFIX,
106 'template_types' => json_encode($page_templates),
107 'elementor_installed' => did_action('elementor/loaded') ? 'yes' : 'no',
108 'gutenberg_installed' => did_action('shopengine-gutenberg-addon/before_loaded') ? 'yes' : 'no',
109 'supported_builders' => $this->get_supported_builders(),
110 'default_builder' => $this->get_default_builder(),
111 'both_builders_active' => (did_action('elementor/loaded') && did_action('shopengine-gutenberg-addon/before_loaded')) ? 'yes' : 'no',
112 'license_activated_message' => sprintf(esc_html__('Congratulations! Your product is activated for "%s"', 'shopengine'), parse_url(home_url(), PHP_URL_HOST)),
113 'is_rtl' => is_rtl() ? 'true' : 'false',
114 'ajaxurl' => admin_url( ).'admin-ajax.php',
115 'nonce' => wp_create_nonce(),
116 'banner_show' => \ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' )
117 ]);
118
119 wp_enqueue_style('shopengine-admin-style', \ShopEngine::plugin_url() . 'assets/css/admin-style.css', false, \ShopEngine::version());
120 }
121
122 if($screen->id == 'edit-shopengine-entry' || $screen->id == 'shopengine-entry') {
123 wp_enqueue_style('shopengine-ui', \ShopEngine::plugin_url() . 'assets/css/design-ui.css', false, \ShopEngine::version());
124 wp_enqueue_script('shopengine-entry-script', \ShopEngine::plugin_url() . 'assets/js/admin-entry-script.js', [], \ShopEngine::version(), true);
125 }
126 }
127
128
129 function menu_getting_started() {
130 add_menu_page(
131 esc_html__('ShopEngine', 'shopengine'),
132 esc_html__('ShopEngine', 'shopengine'),
133 'manage_options',
134 'shopengine-settings',
135 [$this, 'redirect_to_content'],
136 \ShopEngine::plugin_url() . 'assets/images/icons/shopengine_icon_white.svg',
137 '58.7'
138 );
139
140 add_submenu_page(
141 'shopengine-settings',
142 esc_html__('Getting Started', 'shopengine'),
143 esc_html__('Getting Started', 'shopengine'),
144 'manage_options',
145 $this->menu_link_part . '#getting-started'
146 );
147 }
148
149 public function menu_others() {
150 add_submenu_page(
151 'shopengine-settings',
152 esc_html__('Add-ons', 'shopengine'),
153 esc_html__('Add-ons', 'shopengine'),
154 'manage_options',
155 $this->menu_link_part . '#shopengine-modules'
156 );
157
158 add_submenu_page(
159 'shopengine-settings',
160 esc_html__('Widgets', 'shopengine'),
161 esc_html__('Widgets', 'shopengine'),
162 'manage_options',
163 $this->menu_link_part . '#shopengine-widgets'
164 );
165
166 add_submenu_page(
167 'shopengine-settings',
168 esc_html__('Get Help', 'shopengine'),
169 esc_html__('Get Help', 'shopengine'),
170 'manage_options',
171 $this->menu_link_part . '#shopengine-get-help'
172 );
173
174 // license activation & go premium menu links
175 if(\ShopEngine::package_type() != 'free') { // is pro
176 add_submenu_page(
177 'shopengine-settings',
178 '<span style="color: #49dd85;" class="shopengine_pro_license pro">' . esc_html__('License', 'shopengine') . '</span>',
179 '<span style="color: #49dd85;" class="shopengine_pro_license pro">' . esc_html__('License', 'shopengine') . '</span>',
180 'manage_options',
181 $this->menu_link_part . '#shopengine-license'
182 );
183 } else { // is free
184 add_submenu_page(
185 'shopengine-settings',
186 '<span style="color: #f9b015;" class="shopengine_pro_aware pro">' . esc_html__('Upgrade to Premium', 'shopengine') . '</span>',
187 '<span style="color: #f9b015;" class="shopengine_pro_aware pro">' . esc_html__('Upgrade to Premium', 'shopengine') . '</span>',
188 'manage_options',
189 \ShopEngine::landing_page()
190 );
191 }
192 }
193
194 function redirect_to_content() {
195 wp_safe_redirect($this->menu_link_part . '#getting-started');
196 exit;
197 }
198
199 function content() {
200 $screen = get_current_screen();
201
202 if($screen->id == 'edit-' . Template_Cpt::TYPE) {
203 include_once \ShopEngine::plugin_dir() . 'core/settings/screens/default.php';
204 }
205 }
206
207 /**
208 * Get supported builders based on active plugins
209 *
210 * @return array
211 */
212 private function get_supported_builders() {
213 $builders = [];
214
215 // Check if Elementor is active
216 if(did_action('elementor/loaded')) {
217 $builders[\ShopEngine\Core\Builders\Action::EDIT_WITH_ELEMENTOR] = 'Elementor';
218 }
219
220 // Check if Blocks for ShopEngine (Gutenberg addon) is active
221 if(did_action('shopengine-gutenberg-addon/before_loaded')) {
222 $builders[\ShopEngine\Core\Builders\Action::EDIT_WITH_GUTENBERG] = 'Gutenberg';
223 }
224
225 return $builders;
226 }
227
228 /**
229 * Get default builder based on active plugins
230 *
231 * @return string
232 */
233 private function get_default_builder() {
234 // Prefer Elementor if it's active
235 if(did_action('elementor/loaded')) {
236 return \ShopEngine\Core\Builders\Action::EDIT_WITH_ELEMENTOR;
237 }
238
239 // Use Gutenberg if the addon is active
240 if(did_action('shopengine-gutenberg-addon/before_loaded')) {
241 return \ShopEngine\Core\Builders\Action::EDIT_WITH_GUTENBERG;
242 }
243
244 // Fallback to Elementor if neither is active
245 return \ShopEngine\Core\Builders\Action::EDIT_WITH_ELEMENTOR;
246 }
247
248 }
249