PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 0.1.4-beta
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v0.1.4-beta
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 5 years ago base 5 years ago core 5 years ago languages 5 years ago modules 5 years ago templates 5 years ago traits 5 years ago utils 5 years ago widgets 5 years ago autoloader.php 5 years ago plugin.php 5 years ago readme.txt 5 years ago shopengine.php 5 years ago
plugin.php
382 lines
1 <?php
2
3 namespace ShopEngine;
4
5 use ShopEngine\Core\Builders\Base;
6 use ShopEngine\Core\Query_Modifier;
7 use ShopEngine\Modules\Manifest as Module_Manifest;
8 use ShopEngine\Widgets\Manifest;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Plugin final Class.
14 * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install.
15 *
16 * @since 1.0.0
17 */
18 final class Plugin {
19
20 private static $instance;
21
22 /**
23 * __construct function
24 * @since 1.0.0
25 */
26 public function __construct() {
27 // load autoload method
28 Autoloader::run();
29 }
30
31
32 /**
33 * Public function init.
34 * call function for all
35 *
36 * @since 1.0.0
37 */
38 public function init() {
39
40 $error = false;
41
42 // check woocommerce plugin
43 if(!did_action('woocommerce_loaded')) {
44 add_action('admin_notices', array($this, 'missing_woocommerce'));
45
46 $error = true;
47 }
48
49 // Check if Elementor installed and activated.
50 if(!did_action('elementor/loaded')) {
51 add_action('admin_notices', array($this, 'missing_elementor'));
52
53 $error = true;
54 }
55
56 // Check for required Elementor version.
57 if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
58 add_action('admin_notices', array($this, 'failed_elementor_version'));
59
60 $error = true;
61 }
62
63 if($error) {
64
65 return;
66 }
67
68 // Load custom elementor controls
69 new \ShopEngine\Core\Elementor_Controls\Init();
70
71 //Loading the scripts and styles
72 add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
73 add_action( 'elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor'] );
74
75 //woocommece theme support
76 if( !current_theme_supports('woocommerce') ) {
77 add_theme_support( 'woocommerce' );
78 add_theme_support( 'wc-product-gallery-zoom' );
79 add_theme_support( 'wc-product-gallery-lightbox' );
80 add_theme_support( 'wc-product-gallery-slider' );
81 }
82
83
84 #Registering new post-type & etc
85 Base::instance()->init();
86
87 \ShopEngine\Core\Settings\Base::instance()->init();
88
89 (new Module_Manifest)->init();
90
91 // working get instance of elementor widget
92 (new Manifest)->init();
93
94 Query_Modifier::instance()->init();
95
96 // view count
97 add_action( 'wp_head', [$this, 'shopengine_track_product_views']);
98 }
99
100
101 /**
102 * Public function version.
103 * set for plugin version
104 *
105 * @since 1.0.0
106 */
107 public function version() {
108 return '1.0.0';
109 }
110
111
112 /**
113 * Public function package_type.
114 * set for plugin package type
115 *
116 * @since 1.0.0
117 */
118 public function package_type() {
119 return 'free';
120 }
121
122
123 /**
124 * Public function plugin_url.
125 * set for plugin url
126 *
127 * @since 1.0.0
128 */
129 public function plugin_url() {
130 return trailingslashit(plugin_dir_url(__FILE__));
131 }
132
133
134 /**
135 * Public function plugin_dir.
136 * set for plugin dir
137 *
138 * @since 1.0.0
139 */
140 public function plugin_dir() {
141 return trailingslashit(plugin_dir_path(__FILE__));
142 }
143
144
145 /**
146 * Public function core_url .
147 * set for plugin core folder url
148 *
149 * @since 1.0.0
150 */
151 public function core_url() {
152 return $this->plugin_url() . 'core/';
153 }
154
155
156 /**
157 * Public function core_dir .
158 * set for plugin core folder dir
159 *
160 * @since 1.0.0
161 */
162 public function core_dir() {
163 return $this->plugin_dir() . 'core/';
164 }
165
166
167 /**
168 * Public function base_url .
169 * set for plugin base folder url
170 *
171 * @since 1.0.0
172 */
173 public function base_url() {
174 return $this->plugin_url() . 'base/';
175 }
176
177
178 /**
179 * Public function base_dir .
180 * set for plugin base folder dir
181 *
182 * @since 1.0.0
183 */
184 public function base_dir() {
185 return $this->plugin_dir() . 'base/';
186 }
187
188
189 /**
190 * Public function utils_url .
191 * set for plugin utils folder url
192 *
193 * @since 1.0.0
194 */
195 public function utils_url() {
196 return $this->plugin_url() . 'utils/';
197 }
198
199
200 /**
201 * Public function utils_dir .
202 * set for plugin utils folder dir
203 *
204 * @since 1.0.0
205 */
206 public function utils_dir() {
207 return $this->plugin_dir() . 'utils/';
208 }
209
210
211 /**
212 * Public function widgets_url .
213 * set for plugin widget folder url
214 *
215 * @since 1.0.0
216 */
217 public function widgets_url() {
218 return $this->plugin_url() . 'widgets/';
219 }
220
221
222 /**
223 * Public function widgets_dir .
224 * set for plugin widget folder dir
225 *
226 * @since 1.0.0
227 */
228 public function widgets_dir() {
229 return $this->plugin_dir() . 'widgets/';
230 }
231
232
233 /**
234 * Public function shopengine_track_product_views
235 * Adding Product Views Count Meta
236 */
237 public function shopengine_track_product_views($product_id){
238 if ( class_exists('WooCommerce') && !is_product() ) return;
239 $product_id = get_the_id();
240
241 $count_key = 'shopengine_product_views_count';
242 $count = get_post_meta($product_id, $count_key, true);
243 if($count==''){
244 $count = 1;
245 delete_post_meta($product_id, $count_key);
246 add_post_meta($product_id, $count_key, '1');
247 }else{
248 $count++;
249 update_post_meta($product_id, $count_key, $count);
250 }
251 }
252
253 /**
254 * Public function js_css_public .
255 * Include public function
256 *
257 * @since 1.0.0
258 */
259 public function js_css_public() {
260 wp_enqueue_style('shopengine-icon', plugin_dir_url(__FILE__) . 'assets/css/shopengine-icon.css', false, $this->version());
261 wp_enqueue_style('shopengine-simple-scrollbar-css', plugin_dir_url(__FILE__) . 'assets/css/simple-scrollbar.css', false, $this->version());
262 wp_enqueue_style('shopengine-public-css', plugin_dir_url(__FILE__) . 'assets/css/public-style.css', false, $this->version());
263 wp_enqueue_script('shopengine-simple-scrollbar.js-js', plugin_dir_url(__FILE__) . 'assets/js/simple-scrollbar.js', array(), $this->version(), true);
264 wp_enqueue_script('shopengine-filter-js', plugin_dir_url(__FILE__) . 'assets/js/filter.js', array(), $this->version(), true);
265 wp_enqueue_script('shopengine-js', plugin_dir_url(__FILE__) . 'assets/js/public.js', array(), $this->version(), true);
266
267 wp_localize_script('shopengine-js', 'shopEngineApiSettings', [
268 'resturl' => get_rest_url(),
269 'rest_nonce' => wp_create_nonce('wp_rest'),
270 ]);
271 }
272
273 public function js_css_elementor() {
274 wp_enqueue_style('shopnegine-panel-icon', plugin_dir_url(__FILE__) . 'assets/css/shopengine-icon.css', false, $this->version());
275 wp_enqueue_style('shopnegine-editor-css', plugin_dir_url(__FILE__) . 'assets/css/editor.css', false, $this->version());
276 }
277
278 public function force_load_woocommerce_css($styles) {
279
280 $styles['woocommerce-general'] = array(
281 'src' => WC()->plugin_url() . '/assets/css/woocommerce.css',
282 'deps' => '',
283 'version' => \Automattic\Jetpack\Constants::get_constant('WC_VERSION'),
284 'media' => 'all',
285 'has_rtl' => true,
286 );
287
288 return $styles;
289 }
290
291
292 public function missing_woocommerce() {
293
294 if(isset($_GET['activate'])) {
295 unset($_GET['activate']);
296 }
297
298 if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
299
300 $btn['label'] = esc_html__('Activate Woocommerce', 'shopengine');
301 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
302
303 } else {
304
305 $btn['label'] = esc_html__('Install Woocommerce', 'shopengine');
306 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce');
307 }
308
309 Utils\Notice::push(
310 [
311 'id' => 'unsupported-elementor-version',
312 'type' => 'error',
313 'dismissible' => true,
314 'btn' => $btn,
315 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
316 ]
317 );
318 }
319
320
321 public function missing_elementor() {
322
323 if(isset($_GET['activate'])) {
324 unset($_GET['activate']);
325 }
326
327 if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
328
329 $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
330 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
331
332 } else {
333
334 $btn['label'] = esc_html__('Install Elementor', 'shopengine');
335 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
336 }
337
338 Utils\Notice::push(
339 [
340 'id' => 'unsupported-elementor-version',
341 'type' => 'error',
342 'dismissible' => true,
343 'btn' => $btn,
344 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
345 ]
346 );
347 }
348
349
350 public function failed_elementor_version() {
351
352 $btn['label'] = esc_html__('Update Elementor', 'shopengine');
353 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor');
354
355 Utils\Notice::push(
356 [
357 'id' => 'unsupported-elementor-version',
358 'type' => 'error',
359 'dismissible' => true,
360 'btn' => $btn,
361 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
362 ]
363 );
364 }
365
366
367
368 public function flush_rewrites() {
369 $form_cpt = new Core\Builders\Cpt();
370 $form_cpt->flush_rewrites();
371 }
372
373
374 public static function instance() {
375 if(!self::$instance) {
376 self::$instance = new self();
377 }
378
379 return self::$instance;
380 }
381
382 }