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