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