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