PluginProbe
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets / 4.6.6
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets v4.6.6
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 All 85 releases
← All changes | plugin.php +556 -424 2.2.04.6.6 View file →
@@ -1,424 +1,556 @@
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_elementor_version = false;
54 -
55 - // Check if Elementor installed and activated.
56 - if(!did_action('elementor/loaded')) {
57 -
58 - if(!did_action('shopengine-gutenberg-addon/before_loaded')) {
59 -
60 - add_action('admin_notices', [$this, 'missing_elementor']);
61 -
62 - $error = true;
63 - }
64 - }
65 -
66 - // Check for required Elementor version.
67 - if(did_action('elementor/loaded') && defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
68 -
69 - add_action('admin_notices', [$this, 'failed_elementor_version']);
70 -
71 - $error = true;
72 - }
73 -
74 - if($error) {
75 - return;
76 - }
77 -
78 - add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) {
79 -
80 - $custom_links[] = '<a href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>';
81 -
82 - foreach ($custom_links as $custom_link):
83 - array_unshift($links, $custom_link);
84 - endforeach;
85 -
86 - if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) {
87 - $links[] = '<a href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank">' . esc_html__('Go Pro', 'shopengine') . '</a>';
88 - }
89 - return $links;
90 - });
91 -
92 -
93 - /**
94 - * Routes initialization
95 - *
96 - */
97 - new License_Route();
98 -
99 - /**
100 - * Run pro plugin updater here....
101 - *
102 - */
103 - add_action('admin_init', function () {
104 - if(class_exists('ShopEngine_Pro')) {
105 - new Updater();
106 - }
107 - });
108 -
109 -
110 - add_action('wp_loaded', function () {
111 -
112 - if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) {
113 -
114 - $pid = (int)$_REQUEST['preview_id'];
115 -
116 - $po = get_post($pid);
117 -
118 - if($po->post_type === Template_Cpt::TYPE) {
119 -
120 - $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid);
121 -
122 - if(empty($template) || !isset($template['url'])) {
123 - return;
124 - }
125 -
126 - $param = [
127 - 'shopengine_template_id' => $pid,
128 - 'preview_nonce' => wp_create_nonce('template_preview_' . $pid),
129 - 'change_template' => '1',
130 - ];
131 -
132 - $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param);
133 -
134 - wp_safe_redirect($url);
135 - exit;
136 - }
137 - }
138 - });
139 -
140 - // avoid themes for loading woocommerce functions
141 - $avoid_themes = ['avada'];
142 -
143 - if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) {
144 - /**
145 - * Ensuring woocommerce functions are loaded before theme is modifying those
146 - *
147 - */
148 - require_once WC_ABSPATH . '/includes/wc-template-functions.php';
149 - }
150 -
151 -
152 - if(did_action('elementor/loaded')) {
153 - // Load custom elementor controls
154 - new \ShopEngine\Core\Elementor_Controls\Init();
155 -
156 - //Loading the scripts and styles
157 - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']);
158 - }
159 -
160 -
161 - //Loading public scripts and styles
162 - add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
163 -
164 - //woocommece theme support
165 - if(!current_theme_supports('woocommerce')) {
166 - add_theme_support('woocommerce');
167 - add_theme_support('wc-product-gallery-zoom');
168 - add_theme_support('wc-product-gallery-lightbox');
169 - add_theme_support('wc-product-gallery-slider');
170 - }
171 -
172 -
173 - #Registering new post-type & etc
174 - Base::instance()->init();
175 -
176 - \ShopEngine\Core\Settings\Base::instance()->init();
177 -
178 - new Libs\Select_Api\Base();
179 -
180 - (new Module_Manifest())->init();
181 -
182 - // working get instance of elementor widget
183 - (new Manifest())->init();
184 -
185 - Query_Modifier::instance()->init();
186 -
187 - (new Conflict_Manifest())->init();
188 -
189 - // view count
190 - add_action('get_header', [$this, 'shopengine_track_product_views']);
191 -
192 - // database migrations
193 - // (new \ShopEngine\Compatibility\Migrations\Migration())->init();
194 - (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init();
195 -
196 -
197 - // call service providers
198 -
199 - $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php';
200 - $method = 'init';
201 - foreach( $service_providers as $service_provider ){
202 -
203 - if(class_exists($service_provider) && method_exists($service_provider, $method)) {
204 - $instance = new $service_provider();
205 - $instance->$method();
206 - }
207 -
208 - }
209 -
210 -
211 -
212 - add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3);
213 - }
214 -
215 -
216 - // add async and defer attributes to enqueued scripts
217 - public function filter_load_type($tag, $handle, $src) {
218 -
219 - if(strpos($handle, '-async') !== false) {
220 - $tag = str_replace(' src', ' async="async" src', $tag);
221 - }
222 -
223 - if(strpos($handle, '-defer') !== false) {
224 - $tag = str_replace('<script ', '<script defer ', $tag);
225 - }
226 -
227 - return $tag;
228 - }
229 -
230 - /**
231 - * Public function shopengine_track_product_views
232 - * Adding Product Views Count Meta
233 - */
234 - public function shopengine_track_product_views() {
235 -
236 - if(class_exists('WooCommerce') && !is_product()) {
237 - return;
238 - }
239 -
240 - $product_id = get_the_id();
241 -
242 - $cookie_name = "shopengine_recent_viewed_product";
243 -
244 - if(isset($_COOKIE[$cookie_name])) {
245 -
246 - $cookie_ids = $_COOKIE[$cookie_name];
247 - $product_ids = explode(',', $cookie_ids);
248 -
249 - if(!is_array($product_ids)) {
250 - $product_ids = [$product_ids];
251 - }
252 -
253 - $product_ids = array_combine($product_ids, $product_ids);
254 - unset($product_ids[$product_id]);
255 - $product_ids[] = $product_id;
256 -
257 - $cookie_value = implode(',', $product_ids);
258 -
259 - } else {
260 - $cookie_value = $product_id;
261 - }
262 -
263 - setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' );
264 -
265 - $count_key = 'shopengine_product_views_count';
266 - $count = get_post_meta($product_id, $count_key, true);
267 -
268 - if($count == '') {
269 - $count = 1;
270 - delete_post_meta($product_id, $count_key);
271 - add_post_meta($product_id, $count_key, '1');
272 - } else {
273 - $count++;
274 - update_post_meta($product_id, $count_key, $count);
275 - }
276 - }
277 -
278 - /**
279 - * Public function js_css_public .
280 - * Include public function
281 - *
282 - * @since 1.0.0
283 - */
284 - public function js_css_public() {
285 - wp_enqueue_style('shopengine-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
286 - wp_enqueue_style('shopengine-simple-scrollbar-css', \ShopEngine::plugin_url() . 'assets/css/simple-scrollbar.css', false, \ShopEngine::version());
287 - wp_enqueue_style('shopengine-public-css', \ShopEngine::plugin_url() . 'assets/css/public-style.css', false, \ShopEngine::version());
288 -
289 - // Modal Stylesheet
290 - wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version());
291 -
292 - // Modal Script
293 - wp_register_script('shopengine-modal-script', \ShopEngine::plugin_url() . 'assets/js/shopengine-modal.js', ['jquery'], \ShopEngine::version(), true);
294 -
295 - wp_enqueue_script('shopengine-simple-scrollbar.js-js', \ShopEngine::plugin_url() . 'assets/js/simple-scrollbar.js', [], \ShopEngine::version(), true);
296 - wp_enqueue_script('shopengine-filter-js', \ShopEngine::plugin_url() . 'assets/js/filter.js', [], \ShopEngine::version(), true);
297 - wp_enqueue_script('shopengine-js', \ShopEngine::plugin_url() . 'assets/js/public.js', [], \ShopEngine::version(), true);
298 -
299 -
300 - wp_localize_script('shopengine-js', 'shopEngineApiSettings', [
301 - 'resturl' => get_rest_url(),
302 - 'rest_nonce' => wp_create_nonce('wp_rest'),
303 - ]);
304 -
305 -
306 - /**
307 - * Registering libs css/js
308 - *
309 - */
310 -
311 - wp_register_style(
312 - 'lib-sqv-css',
313 - \ShopEngine::plugin_url() . '/assets/sqv/smart-quick-view.css',
314 - [],
315 - \ShopEngine::version()
316 - );
317 -
318 - wp_register_script(
319 - 'lib-sqv-js',
320 - \ShopEngine::plugin_url() . 'assets/sqv/smart-quick-view.js',
321 - ['jquery', 'wc-single-product'],
322 - \ShopEngine::version(),
323 - true
324 - );
325 - }
326 -
327 - public function js_css_elementor() {
328 - wp_enqueue_style('shopnegine-panel-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
329 -
330 - if('shopengine-template' === get_post_type()):
331 - wp_enqueue_style('shopnegine-editor-css', \ShopEngine::plugin_url() . 'assets/css/editor.css', false, \ShopEngine::version());
332 - endif;
333 - }
334 -
335 -
336 - public function missing_woocommerce() {
337 -
338 - if(isset($_GET['activate'])) {
339 - unset($_GET['activate']);
340 - }
341 -
342 - if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
343 -
344 - $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine');
345 - $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
346 -
347 - } else {
348 -
349 - $btn['label'] = esc_html__('Install WooCommerce', 'shopengine');
350 - $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce');
351 - }
352 -
353 - Utils\Notice::push(
354 - [
355 - 'id' => 'missing-woo',
356 - 'type' => 'error',
357 - 'dismissible' => true,
358 - 'btn' => $btn,
359 - 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '4.1.0'),
360 - ]
361 - );
362 - }
363 -
364 -
365 - public function missing_elementor() {
366 -
367 - if(isset($_GET['activate'])) {
368 - unset($_GET['activate']);
369 - }
370 -
371 - if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
372 -
373 - $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
374 - $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
375 -
376 - } else {
377 -
378 - $btn['label'] = esc_html__('Install Elementor', 'shopengine');
379 - $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
380 - }
381 -
382 - Utils\Notice::push(
383 - [
384 - 'id' => 'missing-elementor',
385 - 'type' => 'error',
386 - 'dismissible' => true,
387 - 'btn' => $btn,
388 - 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
389 - ]
390 - );
391 - }
392 -
393 -
394 - public function failed_elementor_version() {
395 -
396 - $btn['label'] = esc_html__('Update Elementor', 'shopengine');
397 - $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor');
398 -
399 - Utils\Notice::push(
400 - [
401 - 'id' => 'unsupported-elementor-version',
402 - 'type' => 'error',
403 - 'dismissible' => true,
404 - 'btn' => $btn,
405 - 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
406 - ]
407 - );
408 - }
409 -
410 -
411 - public function flush_rewrites() {
412 - $form_cpt = new Core\Builders\Cpt();
413 - $form_cpt->flush_rewrites();
414 - }
415 -
416 -
417 - public static function instance() {
418 - if(!self::$instance) {
419 - self::$instance = new self();
420 - }
421 -
422 - return self::$instance;
423 - }
424 -}
1 +<?php
2 +
3 +namespace ShopEngine;
4 +
5 +defined('ABSPATH') || exit;
6 +
7 +use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest;
8 +use ShopEngine\Core\Builders\Base;
9 +use ShopEngine\Compatibility\Migrations\LangMigration;
10 +use ShopEngine\Core\Query_Modifier;
11 +use ShopEngine\Core\Wc_Customizer\Register_Settings;
12 +use ShopEngine\Core\Template_Cpt;
13 +use ShopEngine\Libs\License\License_Route;
14 +use ShopEngine\Libs\Rating\Rating;
15 +use ShopEngine\Libs\Updater\Init as Updater;
16 +use ShopEngine\Modules\Manifest as Module_Manifest;
17 +use ShopEngine\Widgets\Manifest;
18 +
19 +
20 +/**
21 + * Plugin final Class.
22 + * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install.
23 + *
24 + * @since 1.0.0
25 + */
26 +final class Plugin {
27 +
28 + private static $instance;
29 +
30 + /**
31 + * __construct function
32 + * @since 1.0.0
33 + */
34 + public function __construct() {
35 + // load autoload method
36 + Autoloader::run();
37 + add_action( 'wp_ajax_shopengine_admin_action', [\ShopEngine\Utils\Util::class, 'shopengine_admin_action'] );
38 + }
39 +
40 + public function utils_url()
41 + {
42 + return $this->plugin_url() . 'utils/';
43 + }
44 + /**
45 + * Public function init.
46 + * call function for all
47 + *
48 + * @since 1.0.0
49 + */
50 + public function init() {
51 +
52 + $error = false;
53 +
54 + // init notice class
55 + \Oxaim\Libs\Notice::init();
56 +
57 + // check woocommerce plugin
58 + if(!did_action('woocommerce_loaded')) {
59 + add_action('admin_notices', [$this, 'missing_woocommerce']);
60 +
61 + $error = true;
62 + }
63 +
64 + $check_elementor_version = false;
65 +
66 + // Check if Elementor installed and activated.
67 + if(!did_action('elementor/loaded')) {
68 +
69 + if(!did_action('shopengine-gutenberg-addon/before_loaded')) {
70 +
71 + add_action('admin_notices', [$this, 'missing_elementor']);
72 +
73 + $error = true;
74 + }
75 + }
76 +
77 + // Check for required Elementor version.
78 + if(did_action('elementor/loaded') && defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
79 +
80 + add_action('admin_notices', [$this, 'failed_elementor_version']);
81 +
82 + $error = true;
83 + }
84 +
85 + if($error) {
86 + return;
87 + }
88 +
89 + add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) {
90 + $free = esc_html__("Go To Shopengine","shopengine");
91 + $pro = esc_html__("Go To ShopenginePro","shopengine");
92 +
93 + $custom_links[] = '<a title="' . $free . '" href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>';
94 +
95 + foreach ($custom_links as $custom_link):
96 + array_unshift($links, $custom_link);
97 + endforeach;
98 +
99 + if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) {
100 + $links[] = '<a title="' . $pro . '" href="https://wpmet.com/plugin/shopengine/pricing/" style="color:#FCB214;font-weight:700" target="_blank" rel="noopener">' . esc_html__('Go Pro', 'shopengine') . '</a>';
101 + }
102 + return $links;
103 + });
104 +
105 + /**
106 + * EmailKit Global Class initialization
107 + *
108 + */
109 + if( !did_action('edit_with_emailkit_loaded') && class_exists('\Wpmet\Libs\Emailkit') && \ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true' ) {
110 +
111 + new \Wpmet\Libs\Emailkit();
112 + }
113 +
114 +
115 + /**
116 + * Routes initialization
117 + *
118 + */
119 + new License_Route();
120 +
121 + /**
122 + * Run pro plugin updater here....
123 + *
124 + */
125 + add_action('admin_init', function () {
126 + if(class_exists('ShopEngine_Pro')) {
127 + new Updater();
128 + }
129 + new \ShopEngine\Compatibility\Migrations\Direct_Checkout;
130 + });
131 +
132 +
133 + add_action('wp_loaded', function () {
134 + /**
135 + * migrate data
136 + */
137 + LangMigration::instance()->init();
138 + });
139 +
140 + // avoid themes for loading woocommerce functions
141 + $avoid_themes = ['avada', 'avada child', 'woodmart', 'woodmart child'];
142 + if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) {
143 + /**
144 + * Ensuring woocommerce functions are loaded before theme is modifying those
145 + *
146 + */
147 + require_once WC_ABSPATH . '/includes/wc-template-functions.php';
148 + }
149 +
150 +
151 + if(did_action('elementor/loaded')) {
152 + // Load custom elementor controls
153 + new \ShopEngine\Core\Elementor_Controls\Init();
154 +
155 + //Loading the scripts and styles
156 + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']);
157 + }
158 +
159 +
160 + //Loading public scripts and styles
161 + add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
162 +
163 + //woocommece theme support
164 + if(!current_theme_supports('woocommerce')) {
165 + add_theme_support('woocommerce');
166 + add_theme_support('wc-product-gallery-zoom');
167 + add_theme_support('wc-product-gallery-lightbox');
168 + add_theme_support('wc-product-gallery-slider');
169 + }
170 +
171 +
172 + $filter_string = ''; // elementskit,metform-pro
173 + $filter_string .= ((!in_array('elementskit/elementskit.php', apply_filters('active_plugins', get_option('active_plugins')))) ? '' : ',elementskit');
174 + $filter_string .= (!class_exists('\MetForm\Plugin') ? '' : ',metform');
175 + $filter_string .= (!class_exists('\MetForm_Pro\Plugin') ? '' : ',metform-pro');
176 +
177 + #Registering new post-type & etc
178 + Base::instance()->init();
179 +
180 +
181 + Rating::instance('shopengine')
182 + ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' )
183 + ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' )
184 + ->set_priority( 11 )
185 + ->set_first_appear_day( 7 )
186 + ->set_condition( true )
187 + ->call();
188 +
189 + if ( is_admin() && \ShopEngine\Utils\Util::get_settings( 'shopengine_user_consent_for_banner', 'true' ) == 'true' ) {
190 +
191 + /**
192 + * Show WPMET stories widget in dashboard
193 + */
194 +
195 + \Wpmet\Libs\Stories::instance('shopengine')
196 +
197 + ->set_filter($filter_string)
198 + ->set_plugin('ShopEngine', 'https://wpmet.com/plugin/shopengine/')
199 + ->set_api_url('https://api.wpmet.com/public/stories/')
200 + ->call();
201 +
202 + // banner
203 + \Wpmet\Libs\Banner::instance('shopengine')
204 + ->set_filter(ltrim($filter_string, ','))
205 + ->set_api_url('https://api.wpmet.com/public/jhanda')
206 + ->set_plugin_screens('edit-shopengine-template')
207 + ->set_plugin_screens('edit-shopengine-template')
208 + ->call();
209 + }
210 +
211 + $apps_img_path = \ShopEngine::plugin_url() . 'assets/images/apps-page/';
212 + /**
213 + * Show our plugins menu for others wpmet plugins
214 + */
215 + \ShopEngine\Wpmet\Libs\Plugins::instance()->init('shopengine')
216 + ->set_parent_menu_slug('shopengine-settings')
217 + ->set_submenu_name('Our Plugins')
218 + ->set_section_title('Get More out of Your WooCommerce Website!')
219 + ->set_section_description('Install other plugins from us and take your WooCommerce site to the next level for absolutely free!')
220 + ->set_items_per_row(4)
221 + ->set_plugins(
222 + [
223 + 'elementskit-lite/elementskit-lite.php' => [
224 + 'name' => esc_html__('ElementsKit', 'shopengine'),
225 + 'url' => 'https://wordpress.org/plugins/elementskit-lite/',
226 + 'icon' => $apps_img_path. 'elementskit.gif',
227 + 'desc' => esc_html__('All-in-one Elementor addon trusted by 1 Million+ users, makes your website builder process easier with ultimate freedom.', 'shopengine'),
228 + 'docs' => 'https://wpmet.com/doc/elementskit/',
229 + ],
230 + 'getgenie/getgenie.php' => [
231 + 'name' => esc_html__('GetGenie', 'shopengine'),
232 + 'url' => 'https://wordpress.org/plugins/getgenie/',
233 + 'icon' => $apps_img_path.'getgenie.gif',
234 + 'desc' => esc_html__('Your personal AI assistant for content and SEO. Write content that ranks on Google with NLP keywords and SERP analysis data.', 'shopengine'),
235 + 'docs' => 'https://getgenie.ai/docs/',
236 + ],
237 + 'gutenkit-blocks-addon/gutenkit-blocks-addon.php' => [
238 + 'name' => esc_html__('GutenKit', 'shopengine'),
239 + 'url' => 'https://wordpress.org/plugins/gutenkit-blocks-addon/',
240 + 'icon' => $apps_img_path. 'guten-kit.png',
241 + 'desc' => esc_html__('Gutenberg blocks, patterns, and templates that extend the page-building experience using the WordPress block editor.', 'shopengine'),
242 + 'docs' => 'https://wpmet.com/doc/gutenkit/',
243 + ],
244 + 'metform/metform.php' => [
245 + 'name' => esc_html__('MetForm', 'shopengine'),
246 + 'url' => 'https://wordpress.org/plugins/metform/',
247 + 'icon' => $apps_img_path. 'metform.png',
248 + 'desc' => esc_html__('Drag & drop form builder for Elementor to create contact forms, multi-step forms, and more — smoother, faster, and better!', 'shopengine'),
249 + 'docs' => 'https://wpmet.com/doc/metform/',
250 + ],
251 + 'emailkit/EmailKit.php' => [
252 + 'name' => esc_html__('EmailKit', 'shopengine'),
253 + 'url' => 'https://wordpress.org/plugins/emailkit/',
254 + 'icon' => $apps_img_path . 'emailkit.png',
255 + 'desc' => esc_html__('Advanced email customizer for WooCommerce and WordPress. Build, customize, and send emails from WordPress to boost your sales!', 'shopengine'),
256 + 'docs' => 'https://wpmet.com/doc/emailkit/',
257 + ],
258 + 'wp-social/wp-social.php' => [
259 + 'name' => esc_html__('WP Social', 'shopengine'),
260 + 'url' => 'https://wordpress.org/plugins/wp-social/',
261 + 'icon' => $apps_img_path . 'wp-social.png',
262 + 'desc' => esc_html__('Add social share, login, and engagement counter — unified solution for all social media with tons of different styles for your website.', 'shopengine'),
263 + 'docs' => 'https://wpmet.com/doc/wp-social/',
264 + ],
265 + 'wp-ultimate-review/wp-ultimate-review.php' => [
266 + 'name' => esc_html__('WP Ultimate Review', 'shopengine'),
267 + 'url' => 'https://wordpress.org/plugins/wp-ultimate-review/',
268 + 'icon' => $apps_img_path . 'ultimate-review.png',
269 + 'desc' => esc_html__('Collect and showcase reviews on your website to build brand credibility and social proof with the easiest solution.','shopengine'),
270 + 'docs' => 'https://wpmet.com/doc/wp-ultimate-review/',
271 + ],
272 + 'wp-fundraising-donation/wp-fundraising.php' => [
273 + 'name' => esc_html__('FundEngine', 'shopengine'),
274 + 'url' => 'https://wordpress.org/plugins/wp-fundraising-donation/',
275 + 'icon' => $apps_img_path . 'fundengine.png',
276 + 'desc' => esc_html__('Create fundraising, crowdfunding, and donation websites with PayPal and Stripe payment gateway integration.', 'shopengine'),
277 + 'docs' => 'https://wpmet.com/doc/fundengine/',
278 + ],
279 + 'blocks-for-shopengine/shopengine-gutenberg-addon.php' => [
280 + 'name' => esc_html__('Blocks for ShopEngine', 'shopengine'),
281 + 'url' => 'https://wordpress.org/plugins/blocks-for-shopengine/',
282 + 'icon' => $apps_img_path. 'shopengine.gif',
283 + 'desc' => esc_html__('All in one WooCommerce solution for Gutenberg! Build your WooCommerce pages in a block editor with full customization.', 'shopengine'),
284 + 'docs' => 'https://wpmet.com/doc/shopengine/shopengine-gutenberg/',
285 + ],
286 + 'genie-image-ai/genie-image-ai.php' => [
287 + 'name' => esc_html__('Genie Image', 'shopengine'),
288 + 'url' => 'https://wordpress.org/plugins/genie-image-ai/',
289 + 'icon' => $apps_img_path . 'genie-image.png',
290 + 'desc' => esc_html__('AI-powered text-to-image generator for WordPress with OpenAI’s DALL-E 2 technology to generate high-quality images in one click.
291 + ', 'shopengine'),
292 + 'docs' => 'https://getgenie.ai/docs/',
293 + ],
294 + ]
295 + )
296 + ->call();
297 +
298 +
299 +
300 + \ShopEngine\Core\MultiLanguage\Language::instance()->init();
301 +
302 + \ShopEngine\Core\Settings\Base::instance()->init();
303 +
304 +
305 + new Libs\Select_Api\Base();
306 +
307 + (new Module_Manifest())->init();
308 +
309 + // working get instance of elementor widget
310 + (new Manifest())->init();
311 +
312 + Query_Modifier::instance()->init();
313 +
314 + (new Conflict_Manifest())->init();
315 +
316 + // view count
317 + add_action('get_header', [$this, 'shopengine_track_product_views']);
318 +
319 + // database migrations
320 + // (new \ShopEngine\Compatibility\Migrations\Migration())->init();
321 + // (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init();
322 +
323 +
324 + // call service providers
325 +
326 + $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php';
327 + $method = 'init';
328 + foreach( $service_providers as $service_provider ){
329 +
330 + if(class_exists($service_provider) && method_exists($service_provider, $method)) {
331 + $instance = new $service_provider();
332 + $instance->$method();
333 + }
334 +
335 + }
336 +
337 + add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3);
338 +
339 + //it will register an option in customizer for woocommerce products catelog. It's related with our Arcive Products widget.
340 + Register_Settings::instance()->init();
341 + }
342 +
343 +
344 + // add async and defer attributes to enqueued scripts
345 + public function filter_load_type($tag, $handle, $src) {
346 +
347 + if(strpos($handle, '-async') !== false) {
348 + $tag = str_replace(' src', ' async="async" src', $tag);
349 + }
350 +
351 + if(strpos($handle, '-defer') !== false) {
352 + $tag = str_replace('<script ', '<script defer ', $tag);
353 + }
354 +
355 + return $tag;
356 + }
357 +
358 + /**
359 + * Public function shopengine_track_product_views
360 + * Adding Product Views Count Meta
361 + */
362 + public function shopengine_track_product_views() {
363 +
364 + if(class_exists('WooCommerce') && !is_product()) {
365 + return;
366 + }
367 +
368 + $product_id = get_the_id();
369 +
370 + $cookie_name = "shopengine_recent_viewed_product";
371 +
372 + if(isset($_COOKIE[$cookie_name])) {
373 +
374 + $cookie_ids = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name]));
375 + $product_ids = explode(',', $cookie_ids);
376 +
377 + if(!is_array($product_ids)) {
378 + $product_ids = [$product_ids];
379 + }
380 +
381 + $product_ids = array_combine($product_ids, $product_ids);
382 + unset($product_ids[$product_id]);
383 + $product_ids[] = $product_id;
384 +
385 + $cookie_value = implode(',', $product_ids);
386 +
387 + } else {
388 + $cookie_value = $product_id;
389 + }
390 +
391 + setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' );
392 +
393 + $count_key = 'shopengine_product_views_count';
394 + $count = get_post_meta($product_id, $count_key, true);
395 +
396 + if($count == '') {
397 + $count = 1;
398 + delete_post_meta($product_id, $count_key);
399 + add_post_meta($product_id, $count_key, '1');
400 + } else {
401 + $count++;
402 + update_post_meta($product_id, $count_key, $count);
403 + }
404 + }
405 +
406 + /**
407 + * Public function js_css_public .
408 + * Include public function
409 + *
410 + * @since 1.0.0
411 + */
412 + public function js_css_public() {
413 + wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version());
414 +
415 + // Modal Stylesheet
416 + wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version());
417 +
418 + // Modal Script
419 + wp_register_script('shopengine-modal-script', \ShopEngine::plugin_url() . 'assets/js/shopengine-modal.js', ['jquery'], \ShopEngine::version(), true);
420 +
421 + wp_enqueue_script('shopengine-simple-scrollbar.js-js', \ShopEngine::plugin_url() . 'assets/js/simple-scrollbar.js', [], \ShopEngine::version(), true);
422 + wp_enqueue_script('shopengine-filter-js', \ShopEngine::plugin_url() . 'assets/js/filter.js', [], \ShopEngine::version(), true);
423 + wp_enqueue_script('shopengine-js', \ShopEngine::plugin_url() . 'assets/js/public.js', [], \ShopEngine::version(), true);
424 +
425 +
426 + wp_localize_script('shopengine-js', 'shopEngineApiSettings', [
427 + 'resturl' => get_rest_url(),
428 + 'rest_nonce' => wp_create_nonce('wp_rest'),
429 + ]);
430 +
431 +
432 + /**
433 + * Registering libs css/js
434 + *
435 + */
436 +
437 + wp_register_style(
438 + 'lib-sqv-css',
439 + \ShopEngine::plugin_url() . '/assets/sqv/smart-quick-view.css',
440 + [],
441 + \ShopEngine::version()
442 + );
443 +
444 + wp_register_script(
445 + 'lib-sqv-js',
446 + \ShopEngine::plugin_url() . 'assets/sqv/smart-quick-view.js',
447 + ['jquery', 'wc-single-product'],
448 + \ShopEngine::version(),
449 + true
450 + );
451 + }
452 +
453 + public function js_css_elementor() {
454 + wp_enqueue_style('shopnegine-panel-icon', \ShopEngine::plugin_url() . 'assets/css/shopengine-icon.css', false, \ShopEngine::version());
455 +
456 + if('shopengine-template' === get_post_type()):
457 + wp_enqueue_style('shopnegine-editor-css', \ShopEngine::plugin_url() . 'assets/css/editor.css', false, \ShopEngine::version());
458 + endif;
459 + }
460 +
461 +
462 + public function missing_woocommerce() {
463 +
464 + if(!current_user_can('manage_options')) {
465 + return;
466 + }
467 +
468 + if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
469 +
470 + $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine');
471 + $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
472 +
473 + } else {
474 +
475 + $btn['label'] = esc_html__('Install WooCommerce', 'shopengine');
476 + $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce');
477 + }
478 +
479 + Utils\Notice::push(
480 + [
481 + 'id' => 'missing-woo',
482 + 'type' => 'error',
483 + 'dismissible' => true,
484 + 'is_required' => true,
485 + 'btn' => $btn,
486 + 'message' => sprintf(esc_html__('ShopEngine requires woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '4.1.0'),
487 + ]
488 + );
489 + }
490 +
491 +
492 + public function missing_elementor() {
493 +
494 + if(!current_user_can('manage_options')) {
495 + return;
496 + }
497 +
498 + if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
499 +
500 + $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
501 + $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
502 +
503 + } else {
504 +
505 + $btn['label'] = esc_html__('Install Elementor', 'shopengine');
506 + $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
507 + }
508 +
509 + Utils\Notice::push(
510 + [
511 + 'id' => 'missing-elementor',
512 + 'type' => 'error',
513 + 'is_required' => true,
514 + 'dismissible' => true,
515 + 'btn' => $btn,
516 + 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
517 + ]
518 + );
519 + }
520 +
521 +
522 + public function failed_elementor_version() {
523 +
524 + if(!current_user_can('manage_options')) {
525 + return;
526 + }
527 +
528 + $btn['label'] = esc_html__('Update Elementor', 'shopengine');
529 + $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor');
530 +
531 + Utils\Notice::push(
532 + [
533 + 'id' => 'unsupported-elementor-version',
534 + 'type' => 'error',
535 + 'dismissible' => true,
536 + 'btn' => $btn,
537 + 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
538 + ]
539 + );
540 + }
541 +
542 +
543 + public function flush_rewrites() {
544 + $form_cpt = new Core\Builders\Cpt();
545 + $form_cpt->flush_rewrites();
546 + }
547 +
548 +
549 + public static function instance() {
550 + if(!self::$instance) {
551 + self::$instance = new self();
552 + }
553 +
554 + return self::$instance;
555 + }
556 +}