PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 0.1.3-beta
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v0.1.3-beta
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 5 years ago base 5 years ago core 5 years ago languages 5 years ago modules 5 years ago traits 5 years ago utils 5 years ago widgets 5 years ago autoloader.php 5 years ago plugin.php 5 years ago readme.txt 5 years ago shopengine.php 5 years ago
plugin.php
351 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\Widgets\Manifest;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Plugin final Class.
14 * Handles dynamically loading classes only when needed. Check Elementor Plugin, Woocomerce Plugin Loaded or Install.
15 *
16 * @since 1.0.0
17 */
18 final class Plugin {
19
20 private static $instance;
21
22 /**
23 * __construct function
24 * @since 1.0.0
25 */
26 public function __construct() {
27 // load autoload method
28 Autoloader::run();
29 }
30
31
32 /**
33 * Public function init.
34 * call function for all
35 *
36 * @since 1.0.0
37 */
38 public function init() {
39
40 $error = false;
41
42 // check woocommerce plugin
43 if(!did_action('woocommerce_loaded')) {
44 add_action('admin_notices', array($this, 'missing_woocommerce'));
45
46 $error = true;
47 }
48
49 // Check if Elementor installed and activated.
50 if(!did_action('elementor/loaded')) {
51 add_action('admin_notices', array($this, 'missing_elementor'));
52
53 $error = true;
54 }
55
56 // Check for required Elementor version.
57 if(defined('ELEMENTOR_VERSION') && !version_compare(ELEMENTOR_VERSION, '3.0.0', '>=')) {
58 add_action('admin_notices', array($this, 'failed_elementor_version'));
59
60 $error = true;
61 }
62
63 if($error) {
64
65 return;
66 }
67
68 //Loading the scripts and styles
69 add_action('wp_enqueue_scripts', [$this, 'js_css_public']);
70 add_action( 'elementor/editor/after_enqueue_styles', [$this, 'js_css_elementor'] );
71
72 //woocommece theme support
73 if( !current_theme_supports('woocommerce') ) {
74 add_theme_support( 'woocommerce' );
75 add_theme_support( 'wc-product-gallery-zoom' );
76 add_theme_support( 'wc-product-gallery-lightbox' );
77 add_theme_support( 'wc-product-gallery-slider' );
78 }
79
80
81 #Registering new post-type & etc
82 Base::instance()->init();
83
84 \ShopEngine\Core\Settings\Base::instance()->init();
85
86 (new Module_Manifest)->init();
87
88 // working get instance of elementor widget
89 (new Manifest)->init();
90
91 Query_Modifier::instance()->init();
92 }
93
94
95 /**
96 * Public function version.
97 * set for plugin version
98 *
99 * @since 1.0.0
100 */
101 public function version() {
102 return '1.0.0';
103 }
104
105
106 /**
107 * Public function package_type.
108 * set for plugin package type
109 *
110 * @since 1.0.0
111 */
112 public function package_type() {
113 return 'free';
114 }
115
116
117 /**
118 * Public function plugin_url.
119 * set for plugin url
120 *
121 * @since 1.0.0
122 */
123 public function plugin_url() {
124 return trailingslashit(plugin_dir_url(__FILE__));
125 }
126
127
128 /**
129 * Public function plugin_dir.
130 * set for plugin dir
131 *
132 * @since 1.0.0
133 */
134 public function plugin_dir() {
135 return trailingslashit(plugin_dir_path(__FILE__));
136 }
137
138
139 /**
140 * Public function core_url .
141 * set for plugin core folder url
142 *
143 * @since 1.0.0
144 */
145 public function core_url() {
146 return $this->plugin_url() . 'core/';
147 }
148
149
150 /**
151 * Public function core_dir .
152 * set for plugin core folder dir
153 *
154 * @since 1.0.0
155 */
156 public function core_dir() {
157 return $this->plugin_dir() . 'core/';
158 }
159
160
161 /**
162 * Public function base_url .
163 * set for plugin base folder url
164 *
165 * @since 1.0.0
166 */
167 public function base_url() {
168 return $this->plugin_url() . 'base/';
169 }
170
171
172 /**
173 * Public function base_dir .
174 * set for plugin base folder dir
175 *
176 * @since 1.0.0
177 */
178 public function base_dir() {
179 return $this->plugin_dir() . 'base/';
180 }
181
182
183 /**
184 * Public function utils_url .
185 * set for plugin utils folder url
186 *
187 * @since 1.0.0
188 */
189 public function utils_url() {
190 return $this->plugin_url() . 'utils/';
191 }
192
193
194 /**
195 * Public function utils_dir .
196 * set for plugin utils folder dir
197 *
198 * @since 1.0.0
199 */
200 public function utils_dir() {
201 return $this->plugin_dir() . 'utils/';
202 }
203
204
205 /**
206 * Public function widgets_url .
207 * set for plugin widget folder url
208 *
209 * @since 1.0.0
210 */
211 public function widgets_url() {
212 return $this->plugin_url() . 'widgets/';
213 }
214
215
216 /**
217 * Public function widgets_dir .
218 * set for plugin widget folder dir
219 *
220 * @since 1.0.0
221 */
222 public function widgets_dir() {
223 return $this->plugin_dir() . 'widgets/';
224 }
225
226
227 /**
228 * Public function js_css_public .
229 * Include public function
230 *
231 * @since 1.0.0
232 */
233 public function js_css_public() {
234 wp_enqueue_style('shopengine-icon', plugin_dir_url(__FILE__) . 'assets/css/shopengine-icon.css', false, $this->version());
235 wp_enqueue_style('shopengine-simple-scrollbar-css', plugin_dir_url(__FILE__) . 'assets/css/simple-scrollbar.css', false, $this->version());
236 wp_enqueue_style('shopengine-public-css', plugin_dir_url(__FILE__) . 'assets/css/public-style.css', false, $this->version());
237 wp_enqueue_script('shopengine-simple-scrollbar.js-js', plugin_dir_url(__FILE__) . 'assets/js/simple-scrollbar.js', array(), $this->version(), true);
238 wp_enqueue_script('shopengine-filter-js', plugin_dir_url(__FILE__) . 'assets/js/filter.js', array(), $this->version(), true);
239 wp_enqueue_script('shopengine-js', plugin_dir_url(__FILE__) . 'assets/js/public.js', array(), $this->version(), true);
240 }
241
242 public function js_css_elementor() {
243 wp_enqueue_style('shopnegine-panel-icon', plugin_dir_url(__FILE__) . 'assets/css/shopengine-icon.css', false, $this->version());
244 wp_enqueue_style('shopnegine-editor-css', plugin_dir_url(__FILE__) . 'assets/css/editor.css', false, $this->version());
245 }
246
247 public function force_load_woocommerce_css($styles) {
248
249 $styles['woocommerce-general'] = array(
250 'src' => WC()->plugin_url() . '/assets/css/woocommerce.css',
251 'deps' => '',
252 'version' => \Automattic\Jetpack\Constants::get_constant('WC_VERSION'),
253 'media' => 'all',
254 'has_rtl' => true,
255 );
256
257 return $styles;
258 }
259
260
261 public function missing_woocommerce() {
262
263 if(isset($_GET['activate'])) {
264 unset($_GET['activate']);
265 }
266
267 if(file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')) {
268
269 $btn['label'] = esc_html__('Activate Woocommerce', 'shopengine');
270 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php&plugin_status=all&paged=1', 'activate-plugin_woocommerce/woocommerce.php');
271
272 } else {
273
274 $btn['label'] = esc_html__('Install Woocommerce', 'shopengine');
275 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce');
276 }
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 woocommerce Plugin, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
285 ]
286 );
287 }
288
289
290 public function missing_elementor() {
291
292 if(isset($_GET['activate'])) {
293 unset($_GET['activate']);
294 }
295
296 if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
297
298 $btn['label'] = esc_html__('Activate Elementor', 'shopengine');
299 $btn['url'] = wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php');
300
301 } else {
302
303 $btn['label'] = esc_html__('Install Elementor', 'shopengine');
304 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
305 }
306
307 Utils\Notice::push(
308 [
309 'id' => 'unsupported-elementor-version',
310 'type' => 'error',
311 'dismissible' => true,
312 'btn' => $btn,
313 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
314 ]
315 );
316 }
317
318
319 public function failed_elementor_version() {
320
321 $btn['label'] = esc_html__('Update Elementor', 'shopengine');
322 $btn['url'] = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=elementor'), 'upgrade-plugin_elementor');
323
324 Utils\Notice::push(
325 [
326 'id' => 'unsupported-elementor-version',
327 'type' => 'error',
328 'dismissible' => true,
329 'btn' => $btn,
330 'message' => sprintf(esc_html__('ShopEngine requires Elementor version %1$s+, which is currently NOT RUNNING.', 'shopengine'), '3.0.0'),
331 ]
332 );
333 }
334
335
336
337 public function flush_rewrites() {
338 $form_cpt = new Core\Builders\Cpt();
339 $form_cpt->flush_rewrites();
340 }
341
342
343 public static function instance() {
344 if(!self::$instance) {
345 self::$instance = new self();
346 }
347
348 return self::$instance;
349 }
350
351 }