PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 1.3.4
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v1.3.4
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 / plugin.php
shopengine Last commit date
assets 4 years ago base 4 years ago compatibility 4 years ago core 4 years ago languages 4 years ago libs 4 years ago modules 4 years ago traits 5 years ago utils 4 years ago widgets 4 years ago autoloader.php 5 years ago plugin.php 4 years ago readme.txt 4 years ago shopengine.php 4 years ago
plugin.php
354 lines
1 <?php
2
3 namespace ShopEngine;
4
5 use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest;
6 use ShopEngine\Core\Builders\Base;
7 use ShopEngine\Core\Query_Modifier;
8 use ShopEngine\Core\Template_Cpt;
9 use ShopEngine\Libs\License\License_Route;
10 use ShopEngine\Libs\Updater\Init as Updater;
11 use ShopEngine\Modules\Manifest as Module_Manifest;
12 use ShopEngine\Widgets\Manifest;
13
14 defined('ABSPATH') || exit;
15
16 /**
17 * Plugin final Class.
18 * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install.
19 *
20 * @since 1.0.0
21 */
22 final class Plugin {
23
24 private static $instance;
25
26 /**
27 * __construct function
28 * @since 1.0.0
29 */
30 public function __construct() {
31 // load autoload method
32 Autoloader::run();
33 }
34
35
36 /**
37 * Public function init.
38 * call function for all
39 *
40 * @since 1.0.0
41 */
42 public function init() {
43
44 $error = false;
45
46 // check woocommerce plugin
47 if(!did_action('woocommerce_loaded')) {
48 add_action('admin_notices', [$this, 'missing_woocommerce']);
49
50 $error = true;
51 }
52
53 // Check if Elementor installed and activated.
54 if(!did_action('elementor/loaded')) {
55 add_action('admin_notices', [$this, 'missing_elementor']);
56
57 $error = true;
58 }
59
60 // Check for required Elementor version.
61 if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
62 add_action('admin_notices', [$this, 'failed_elementor_version']);
63
64 $error = true;
65 }
66
67 if($error) {
68
69 return;
70 }
71
72
73 /**
74 * Routes initialization
75 *
76 */
77 new License_Route();
78
79 /**
80 * Run pro plugin updater here....
81 *
82 */
83 add_action('admin_init', function () {
84 if(class_exists('ShopEngine_Pro')) {
85 new Updater();
86 }
87
88 });
89
90 global $pagenow;
91
92 if(is_admin() && $pagenow == 'post.php' && $_REQUEST['action'] === 'edit') {
93
94 $pid = $_REQUEST['post'];
95 $po = get_post($pid);
96
97 if($po->post_type === Template_Cpt::TYPE) {
98
99 $url = get_admin_url(). 'edit.php?post_type='.Template_Cpt::TYPE.'#'.Template_Cpt::TYPE;
100
101 wp_safe_redirect( $url );
102 exit;
103 }
104 }
105
106 add_action('wp_loaded', function (){
107
108 if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) {
109
110 $pid = (int) $_REQUEST['preview_id'];
111
112 $po = get_post($pid);
113
114 if($po->post_type === Template_Cpt::TYPE) {
115
116 $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid);
117
118 if(empty($template) || !isset($template['url'])){
119
120 die('There are some errors.');
121 }
122
123 $param = [
124 'shopengine_template_id' => $pid,
125 'preview_nonce' => wp_create_nonce( 'template_preview_' . $pid ),
126 'change_template' => '1'
127 ];
128
129 $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param);
130
131 wp_safe_redirect( $url );
132 exit;
133 }
134 }
135 });
136
137
138 /**
139 * Ensuring woocommerce functions are loaded before theme is modifying those
140 *
141 */
142 require_once WC_ABSPATH . '/includes/wc-template-functions.php';
143
144
145 // Load custom elementor controls
146 new \ShopEngine\Core\Elementor_Controls\Init();
147
148 //Loading the scripts and styles
149 add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
150 add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']);
151
152 //woocommece theme support
153 if(!current_theme_supports('woocommerce')) {
154 add_theme_support('woocommerce');
155 add_theme_support('wc-product-gallery-zoom');
156 add_theme_support('wc-product-gallery-lightbox');
157 add_theme_support('wc-product-gallery-slider');
158 }
159
160
161 #Registering new post-type & etc
162 Base::instance()->init();
163
164 \ShopEngine\Core\Settings\Base::instance()->init();
165
166 (new Module_Manifest)->init();
167
168 // working get instance of elementor widget
169 (new Manifest)->init();
170
171 Query_Modifier::instance()->init();
172
173 (new Conflict_Manifest)->init();
174
175 // view count
176 add_action('wp_head', [$this, 'shopengine_track_product_views']);
177
178 // database migrations
179 // (new \ShopEngine\Compatibility\Migrations\Migration())->init();
180 (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init();
181 }
182
183
184 /**
185 * Public function shopengine_track_product_views
186 * Adding Product Views Count Meta
187 */
188 public function shopengine_track_product_views($product_id) {
189 if(class_exists('WooCommerce') && !is_product()) {
190 return;
191 }
192 $product_id = get_the_id();
193
194 $count_key = 'shopengine_product_views_count';
195 $count = get_post_meta($product_id, $count_key, true);
196 if($count == '') {
197 $count = 1;
198 delete_post_meta($product_id, $count_key);
199 add_post_meta($product_id, $count_key, '1');
200 } else {
201 $count++;
202 update_post_meta($product_id, $count_key, $count);
203 }
204 }
205
206 /**
207 * Public function js_css_public .
208 * Include public function
209 *
210 * @since 1.0.0
211 */
212 public function js_css_public() {
213 wp_enqueue_style('shopengine-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
214 wp_enqueue_style('shopengine-simple-scrollbar-css', \ShopEngine::plugin_url() . 'assets/css/simple-scrollbar.css', false, \ShopEngine::version());
215 wp_enqueue_style('shopengine-public-css', \ShopEngine::plugin_url() . 'assets/css/public-style.css', false, \ShopEngine::version());
216
217 // Modal Stylesheet
218 wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version());
219
220 // Modal Script
221 wp_register_script('shopengine-modal-script', \ShopEngine::plugin_url() . 'assets/js/shopengine-modal.js', ['jquery'], \ShopEngine::version(), true);
222
223 wp_enqueue_script('shopengine-simple-scrollbar.js-js', \ShopEngine::plugin_url() . 'assets/js/simple-scrollbar.js', [], \ShopEngine::version(), true);
224 wp_enqueue_script('shopengine-filter-js', \ShopEngine::plugin_url() . 'assets/js/filter.js', [], \ShopEngine::version(), true);
225 wp_enqueue_script('shopengine-js', \ShopEngine::plugin_url() . 'assets/js/public.js', [], \ShopEngine::version(), true);
226
227
228 wp_localize_script('shopengine-js', 'shopEngineApiSettings', [
229 'resturl' => get_rest_url(),
230 'rest_nonce' => wp_create_nonce('wp_rest'),
231 ]);
232
233
234 /**
235 * Registering libs css/js
236 *
237 */
238
239 wp_register_style(
240 'lib-sqv-css',
241 \ShopEngine::plugin_url() . '/assets/sqv/smart-quick-view.css',
242 [],
243 \ShopEngine::version()
244 );
245
246 wp_register_script(
247 'lib-sqv-js',
248 \ShopEngine::plugin_url() . 'assets/sqv/smart-quick-view.js',
249 ['jquery', 'wc-single-product'],
250 \ShopEngine::version(),
251 true
252 );
253 }
254
255 public function js_css_elementor() {
256 wp_enqueue_style('shopnegine-panel-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
257
258 if('shopengine-template' === get_post_type()):
259 wp_enqueue_style('shopnegine-editor-css', \ShopEngine::plugin_url() . 'assets/css/editor.css', false, \ShopEngine::version());
260 endif;
261 }
262
263
264 public function missing_woocommerce() {
265
266 if(isset($_GET['activate'])) {
267 unset($_GET['activate']);
268 }
269
270 if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
271
272 $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine');
273 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
274
275 } else {
276
277 $btn['label'] = esc_html__('Install WooCommerce', 'shopengine');
278 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce');
279 }
280
281 Utils\Notice::push(
282 [
283 'id' => 'missing-woo',
284 'type' => 'error',
285 'dismissible' => true,
286 'btn' => $btn,
287 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '4.1.0'),
288 ]
289 );
290 }
291
292
293 public function missing_elementor() {
294
295 if(isset($_GET['activate'])) {
296 unset($_GET['activate']);
297 }
298
299 if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
300
301 $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
302 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
303
304 } else {
305
306 $btn['label'] = esc_html__('Install Elementor', 'shopengine');
307 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
308 }
309
310 Utils\Notice::push(
311 [
312 'id' => 'missing-elementor',
313 'type' => 'error',
314 'dismissible' => true,
315 'btn' => $btn,
316 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
317 ]
318 );
319 }
320
321
322 public function failed_elementor_version() {
323
324 $btn['label'] = esc_html__('Update Elementor', 'shopengine');
325 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor');
326
327 Utils\Notice::push(
328 [
329 'id' => 'unsupported-elementor-version',
330 'type' => 'error',
331 'dismissible' => true,
332 'btn' => $btn,
333 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
334 ]
335 );
336 }
337
338
339 public function flush_rewrites() {
340 $form_cpt = new Core\Builders\Cpt();
341 $form_cpt->flush_rewrites();
342 }
343
344
345 public static function instance() {
346 if(!self::$instance) {
347 self::$instance = new self();
348 }
349
350 return self::$instance;
351 }
352
353 }
354