PluginProbe
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets / 1.3.3
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution with eCommerce Templates & Woo Widgets v1.3.3
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 +40 -168 4.1.11.3.3 View file →
@@ -3,13 +3,10 @@
3 3 namespace ShopEngine;
4 4
5 5 use ShopEngine\Compatibility\Conflicts\Manifest as Conflict_Manifest;
6 6 use ShopEngine\Core\Builders\Base;
7 -use ShopEngine\Compatibility\Migrations\LangMigration;
8 7 use ShopEngine\Core\Query_Modifier;
9 -use ShopEngine\Core\Template_Cpt;
10 8 use ShopEngine\Libs\License\License_Route;
11 -use ShopEngine\Libs\Rating\Rating;
12 9 use ShopEngine\Libs\Updater\Init as Updater;
13 10 use ShopEngine\Modules\Manifest as Module_Manifest;
14 11 use ShopEngine\Widgets\Manifest;
15 12
@@ -51,50 +48,28 @@
51 48
52 49 $error = true;
53 50 }
54 51
55 - $check_elementor_version = false;
56 -
57 52 // Check if Elementor installed and activated.
58 - if(!did_action('elementor/loaded')) {
53 + if(!did_action('elementor/loaded')) {
54 + add_action('admin_notices', [$this, 'missing_elementor']);
59 55
60 - if(!did_action('shopengine-gutenberg-addon/before_loaded')) {
56 + $error = true;
57 + }
61 58
62 - add_action('admin_notices', [$this, 'missing_elementor']);
63 -
64 - $error = true;
65 - }
66 - }
67 -
68 59 // Check for required Elementor version.
69 - if(did_action('elementor/loaded') && defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
60 + if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
61 + add_action('admin_notices', [$this, 'failed_elementor_version']);
70 62
71 - add_action('admin_notices', [$this, 'failed_elementor_version']);
63 + $error = true;
64 + }
72 65
73 - $error = true;
74 - }
66 + if($error) {
75 67
76 - if($error) {
77 68 return;
78 69 }
79 -
80 - add_filter("plugin_action_links_shopengine/shopengine.php", function ($links) {
81 - $free = esc_html__("Go To Shopengine","shopengine");
82 - $pro = esc_html__("Go To ShopenginePro","shopengine");
83 70
84 - $custom_links[] = '<a title="' . $free . '" href="'.admin_url('edit.php?post_type=shopengine-template#getting-started').'" target="_blank">' . esc_html__('Settings', 'shopengine') . '</a>';
85 71
86 - foreach ($custom_links as $custom_link):
87 - array_unshift($links, $custom_link);
88 - endforeach;
89 -
90 - if (!is_plugin_active('shopengine-pro/shopengine-pro.php')) {
91 - $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>';
92 - }
93 - return $links;
94 - });
95 -
96 -
97 72 /**
98 73 * Routes initialization
99 74 *
100 75 */
@@ -107,71 +82,24 @@
107 82 add_action('admin_init', function () {
108 83 if(class_exists('ShopEngine_Pro')) {
109 84 new Updater();
110 85 }
111 - new \ShopEngine\Compatibility\Migrations\Direct_Checkout;
112 86 });
113 87
114 88
115 - add_action('wp_loaded', function () {
116 - //phpcs:ignore WordPress.Security.NonceVerification.Recommended --It's a fronted user part, not possible to verify nonce here
117 - if(isset($_REQUEST['preview']) && $_REQUEST['preview'] == 'true' && !empty($_REQUEST['preview_id'])) {
89 + /**
90 + * Ensuring woocommerce functions are loaded before theme is modifying those
91 + *
92 + */
93 + require_once WC_ABSPATH . '/includes/wc-template-functions.php';
118 94
119 - $pid = (int)$_REQUEST['preview_id']; //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here
120 95
121 - $po = get_post($pid);
96 + // Load custom elementor controls
97 + new \ShopEngine\Core\Elementor_Controls\Init();
122 98
123 - if($po->post_type === Template_Cpt::TYPE) {
124 -
125 - $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($pid);
126 -
127 - if(empty($template) || !isset($template['url'])) {
128 - return;
129 - }
130 -
131 - $param = [
132 - 'shopengine_template_id' => $pid,
133 - 'preview_nonce' => wp_create_nonce('template_preview_' . $pid),
134 - 'change_template' => '1',
135 - ];
136 -
137 - $tem_url = (get_post_meta($pid, 'shopengine_template__post_meta__type' , true) == 'order') ? $po->guid : $template['url'];
138 - $url = \ShopEngine\Utils\Helper::add_to_url($tem_url, $param);
139 -
140 - wp_safe_redirect($url);
141 - exit;
142 - }
143 - }
144 -
145 - /**
146 - * migrate data
147 - */
148 - LangMigration::instance()->init();
149 - });
150 -
151 - // avoid themes for loading woocommerce functions
152 - $avoid_themes = ['avada', 'avada child'];
153 -
154 - if(!in_array(strtolower(wp_get_theme()), $avoid_themes)) {
155 - /**
156 - * Ensuring woocommerce functions are loaded before theme is modifying those
157 - *
158 - */
159 - require_once WC_ABSPATH . '/includes/wc-template-functions.php';
160 - }
161 -
162 -
163 - if(did_action('elementor/loaded')) {
164 - // Load custom elementor controls
165 - new \ShopEngine\Core\Elementor_Controls\Init();
166 -
167 - //Loading the scripts and styles
168 - add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']);
169 - }
170 -
171 -
172 - //Loading public scripts and styles
99 + //Loading the scripts and styles
173 100 add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
101 + add_action('elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor']);
174 102
175 103 //woocommece theme support
176 104 if(!current_theme_supports('woocommerce')) {
177 105 add_theme_support('woocommerce');
@@ -179,111 +107,44 @@
179 107 add_theme_support('wc-product-gallery-lightbox');
180 108 add_theme_support('wc-product-gallery-slider');
181 109 }
182 110
111 +
183 112 #Registering new post-type & etc
184 113 Base::instance()->init();
185 114
186 - Rating::instance('shopengine')
187 - ->set_plugin( 'ShopEngine', 'https://wpmet.com/wordpress.org/rating/shopengine' )
188 - ->set_plugin_logo( 'https://ps.w.org/shopengine/assets/icon-256x256.gif?rev=2505061', 'width:150px !important' )
189 - ->set_priority( 10 )
190 - ->set_first_appear_day( 7 )
191 - ->set_condition( true )
192 - ->call();
193 -
194 - \ShopEngine\Core\MultiLanguage\Language::instance()->init();
195 -
196 115 \ShopEngine\Core\Settings\Base::instance()->init();
197 116
198 - new Libs\Select_Api\Base();
117 + (new Module_Manifest)->init();
199 118
200 - (new Module_Manifest())->init();
201 -
202 119 // working get instance of elementor widget
203 - (new Manifest())->init();
120 + (new Manifest)->init();
204 121
205 122 Query_Modifier::instance()->init();
206 123
207 - (new Conflict_Manifest())->init();
124 + (new Conflict_Manifest)->init();
208 125
209 126 // view count
210 - add_action('get_header', [$this, 'shopengine_track_product_views']);
127 + add_action('wp_head', [$this, 'shopengine_track_product_views']);
211 128
212 129 // database migrations
213 130 // (new \ShopEngine\Compatibility\Migrations\Migration())->init();
214 - // (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init();
215 -
216 -
217 - // call service providers
218 -
219 - $service_providers = include \ShopEngine::plugin_dir().'core/service-provider-manager.php';
220 - $method = 'init';
221 - foreach( $service_providers as $service_provider ){
222 -
223 - if(class_exists($service_provider) && method_exists($service_provider, $method)) {
224 - $instance = new $service_provider();
225 - $instance->$method();
226 - }
227 -
228 - }
229 -
230 - add_filter('script_loader_tag', [$this, 'filter_load_type'], 99, 3);
131 + (new \ShopEngine\Compatibility\Migrations\Temp_Migration())->init();
231 132 }
232 133
233 134
234 - // add async and defer attributes to enqueued scripts
235 - public function filter_load_type($tag, $handle, $src) {
236 -
237 - if(strpos($handle, '-async') !== false) {
238 - $tag = str_replace(' src', ' async="async" src', $tag);
239 - }
240 -
241 - if(strpos($handle, '-defer') !== false) {
242 - $tag = str_replace('<script ', '<script defer ', $tag);
243 - }
244 -
245 - return $tag;
246 - }
247 -
248 135 /**
249 136 * Public function shopengine_track_product_views
250 137 * Adding Product Views Count Meta
251 138 */
252 - public function shopengine_track_product_views() {
253 -
139 + public function shopengine_track_product_views($product_id) {
254 140 if(class_exists('WooCommerce') && !is_product()) {
255 141 return;
256 142 }
257 -
258 143 $product_id = get_the_id();
259 144
260 - $cookie_name = "shopengine_recent_viewed_product";
261 -
262 - if(isset($_COOKIE[$cookie_name])) {
263 -
264 - $cookie_ids = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name]));
265 - $product_ids = explode(',', $cookie_ids);
266 -
267 - if(!is_array($product_ids)) {
268 - $product_ids = [$product_ids];
269 - }
270 -
271 - $product_ids = array_combine($product_ids, $product_ids);
272 - unset($product_ids[$product_id]);
273 - $product_ids[] = $product_id;
274 -
275 - $cookie_value = implode(',', $product_ids);
276 -
277 - } else {
278 - $cookie_value = $product_id;
279 - }
280 -
281 - setcookie($cookie_name, $cookie_value, strtotime('+30 days'), '/' );
282 -
283 145 $count_key = 'shopengine_product_views_count';
284 146 $count = get_post_meta($product_id, $count_key, true);
285 -
286 147 if($count == '') {
287 148 $count = 1;
288 149 delete_post_meta($product_id, $count_key);
289 150 add_post_meta($product_id, $count_key, '1');
@@ -298,16 +159,18 @@
298 159 * Include public function
299 160 *
300 161 * @since 1.0.0
301 162 */
302 - public function js_css_public() {
303 - wp_register_style('shopengine-public', \ShopEngine::plugin_url() . 'assets/css/shopengine-public.css', false, \ShopEngine::version());
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());
304 167
305 168 // Modal Stylesheet
306 - wp_register_style('shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version());
169 + wp_register_style( 'shopengine-modal-styles', \ShopEngine::plugin_url() . 'assets/css/shopengine-modal.css', false, \ShopEngine::version() );
307 170
308 171 // Modal Script
309 - wp_register_script('shopengine-modal-script', \ShopEngine::plugin_url() . 'assets/js/shopengine-modal.js', ['jquery'], \ShopEngine::version(), true);
172 + wp_register_script( 'shopengine-modal-script', \ShopEngine::plugin_url() . 'assets/js/shopengine-modal.js', ['jquery'], \ShopEngine::version(), true );
310 173
311 174 wp_enqueue_script('shopengine-simple-scrollbar.js-js', \ShopEngine::plugin_url() . 'assets/js/simple-scrollbar.js', [], \ShopEngine::version(), true);
312 175 wp_enqueue_script('shopengine-filter-js', \ShopEngine::plugin_url() . 'assets/js/filter.js', [], \ShopEngine::version(), true);
313 176 wp_enqueue_script('shopengine-js', \ShopEngine::plugin_url() . 'assets/js/public.js', [], \ShopEngine::version(), true);
@@ -350,8 +213,12 @@
350 213
351 214
352 215 public function missing_woocommerce() {
353 216
217 + if(isset($_GET['activate'])) {
218 + unset($_GET['activate']);
219 + }
220 +
354 221 if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
355 222
356 223 $btn['label'] = esc_html__('Activate WooCommerce', 'shopengine');
357 224 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
@@ -375,8 +242,12 @@
375 242
376 243
377 244 public function missing_elementor() {
378 245
246 + if(isset($_GET['activate'])) {
247 + unset($_GET['activate']);
248 + }
249 +
379 250 if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
380 251
381 252 $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
382 253 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
@@ -428,5 +299,6 @@
428 299 }
429 300
430 301 return self::$instance;
431 302 }
303 +
432 304 }