PluginProbe
WPZOOM Addons for Elementor – Starter Templates & Widgets / 1.4.7
WPZOOM Addons for Elementor – Starter Templates & Widgets v1.4.7
1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 trunk 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 All 78 releases
wpzoom-elementor-addons / wpzoom-elementor-addons.php

wpzoom-elementor-addons.php in WPZOOM Addons for Elementor – Starter Templates & Widgets 1.4.7, at wpzoom-elementor-addons.php

537 lines 19.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Elementor Addons by WPZOOM
4 * Plugin URI: https://www.wpzoom.com/plugins/wpzoom-elementor-addons/
5 * Description: A plugin that provides a collection of Elementor Templates and advanced widgets created by the WPZOOM team
6 * Version: 1.4.7
7 * Author: WPZOOM
8 * Author URI: https://www.wpzoom.com/
9 * Text Domain: wpzoom-elementor-addons
10 * License: GNU General Public License v2
11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
12 * Requires at least: 6.5
13 * Tested up to: 7.0
14 * Elementor tested up to: 4.99
15 * Elementor Pro tested up to: 4.99
16 *
17 * @package WPZOOM_Elementor_Addons
18 */
19
20 namespace WPZOOM_Elementor_Addons;
21
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit; // Exit if accessed directly.
24 }
25
26 if ( ! defined( 'WPZOOM_EL_ADDONS_VER' ) ) {
27 define( 'WPZOOM_EL_ADDONS_VER', get_file_data( __FILE__, [ 'Version' ] )[0] ); // phpcs:ignore
28 }
29
30 define( 'WPZOOM_EL_ADDONS__FILE__', __FILE__ );
31 define( 'WPZOOM_EL_ADDONS_PLUGIN_BASE', plugin_basename( WPZOOM_EL_ADDONS__FILE__ ) );
32 define( 'WPZOOM_EL_ADDONS_PLUGIN_DIR', dirname( WPZOOM_EL_ADDONS_PLUGIN_BASE ) );
33
34 define( 'WPZOOM_EL_ADDONS_PATH', plugin_dir_path( WPZOOM_EL_ADDONS__FILE__ ) );
35 define( 'WPZOOM_EL_ADDONS_URL', plugin_dir_url( WPZOOM_EL_ADDONS__FILE__ ) );
36
37 // Instance the plugin
38 WPZOOM_Elementor_Addons::instance();
39
40 /**
41 * Main WPZOOM Elementor Addons Class
42 *
43 * The main class that initiates and runs the plugin.
44 *
45 * @since 1.0.0
46 */
47 final class WPZOOM_Elementor_Addons {
48 /**
49 * Minimum Elementor Version
50 *
51 * @var string Minimum Elementor version required to run the plugin.
52 * @since 1.0.0
53 */
54 const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
55
56 /**
57 * Minimum PHP Version
58 *
59 * @var string Minimum PHP version required to run the plugin.
60 * @since 1.0.0
61 */
62 const MINIMUM_PHP_VERSION = '7.4';
63
64 /**
65 * Instance
66 *
67 * @var WPZOOM_Elementor_Addons The single instance of the class.
68 * @since 1.0.0
69 * @access private
70 * @static
71 */
72 private static $_instance = null;
73
74 /**
75 * Instance
76 *
77 * Ensures only one instance of the class is loaded or can be loaded.
78 *
79 * @since 1.0.0
80 * @access public
81 * @static
82 * @return WPZOOM_Elementor_Addons An instance of the class.
83 */
84 public static function instance() {
85 if ( is_null( self::$_instance ) ) {
86 self::$_instance = new self();
87 }
88 return self::$_instance;
89 }
90
91 /**
92 * Constructor
93 *
94 * @since 1.0.0
95 * @access public
96 */
97 public function __construct() {
98
99 self::includes();
100
101 add_action( 'init', array( $this, 'i18n' ) );
102 add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
103
104 add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'plugin_css' ) );
105 add_action( 'elementor/preview/enqueue_styles', array( $this, 'plugin_css' ) );
106
107 add_action( 'elementor/editor/footer', array( $this, 'plugin_scripts' ) );
108 add_action( 'elementor/editor/footer', array( $this, 'insert_js_templates' ) );
109
110 // Initialize Pro plugin promotion
111 add_action( 'admin_notices', array( $this, 'pro_plugin_promotion_notice' ) );
112
113 // Enqueue admin styles for modern notices
114 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
115 add_action( 'wp_ajax_wpzoom_dismiss_pro_notice', array( $this, 'dismiss_pro_notice' ) );
116
117 }
118
119 /**
120 * Load Textdomain
121 *
122 * Load plugin localization files.
123 *
124 * Fired by `init` action hook.
125 *
126 * @since 1.0.0
127 * @access public
128 */
129 public function i18n() {
130 load_plugin_textdomain( 'wpzoom-elementor-addons', false, WPZOOM_EL_ADDONS_PLUGIN_DIR . '/languages' );
131 }
132
133 /**
134 * Includes files
135 * @method includes
136 *
137 * @return void
138 */
139 public function includes() {
140
141 include_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-elementor-controls.php';
142 include_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-elementor-widgets.php';
143 include_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-template-manager.php';
144 include_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-elementor-ajax-posts-grid.php';
145
146 }
147
148 /**
149 * Get Editor Templates
150 *
151 * @return void
152 */
153 public function insert_js_templates() {
154 ob_start();
155 require_once WPZOOM_EL_ADDONS_PATH . 'includes/editor-templates/templates.php';
156 ob_end_flush();
157 }
158
159 /**
160 * Enqueue plugin styles.
161 */
162 public function plugin_css() {
163 wp_enqueue_style( 'wpzoom-elementor-addons', WPZOOM_EL_ADDONS_URL . 'assets/css/wpzoom-elementor-addons.css', array(), WPZOOM_EL_ADDONS_VER );
164 wp_enqueue_style( 'select2', WPZOOM_EL_ADDONS_URL . 'assets/vendors/select2/select2.css', array(), WPZOOM_EL_ADDONS_VER );
165 }
166
167 /**
168 * Enqueue plugin scripts.
169 */
170 public function plugin_scripts() {
171 wp_enqueue_script( 'select2', WPZOOM_EL_ADDONS_URL . 'assets/vendors/select2/select2.full.min.js', array( 'jquery' ), WPZOOM_EL_ADDONS_VER, true );
172 wp_enqueue_script( 'wpzoom-elementor-addons', WPZOOM_EL_ADDONS_URL . 'assets/js/wpzoom-elementor-addons.js', array( 'jquery', 'wp-util', 'select2' ), WPZOOM_EL_ADDONS_VER, true );
173
174 // Count pages (templates), excluding separator entries
175 $pages_count = 0;
176 $templates_json = WPZOOM_EL_ADDONS_PATH . 'includes/data/templates/json/info.json';
177 if ( file_exists( $templates_json ) ) {
178 $data = json_decode( file_get_contents( $templates_json ), true );
179 if ( is_array( $data ) ) {
180 $pages_count = count( array_filter( $data, function( $item ) {
181 return empty( $item['separator'] );
182 } ) );
183 }
184 }
185
186 // Count sections
187 $sections_count = 0;
188 $sections_json = WPZOOM_EL_ADDONS_PATH . 'includes/data/sections/json/info.json';
189 if ( file_exists( $sections_json ) ) {
190 $data = json_decode( file_get_contents( $sections_json ), true );
191 if ( is_array( $data ) ) { $sections_count = count( $data ); }
192 }
193
194 // Count wireframes
195 $wireframes_count = 0;
196 $wireframes_json = WPZOOM_EL_ADDONS_PATH . 'includes/data/wireframes/json/info.json';
197 if ( file_exists( $wireframes_json ) ) {
198 $data = json_decode( file_get_contents( $wireframes_json ), true );
199 if ( is_array( $data ) ) { $wireframes_count = count( $data ); }
200 }
201
202 // Localize script with admin URL for Pro plugin links
203 wp_localize_script( 'wpzoom-elementor-addons', 'wpzoom_admin_data', array(
204 'admin_url' => admin_url(),
205 'get_pro_url' => 'https://www.wpzoom.com/plugins/wpzoom-elementor-addons/',
206 'pages_count' => $pages_count,
207 'sections_count' => $sections_count,
208 'wireframes_count' => $wireframes_count,
209 ) );
210 }
211
212 /**
213 * On Plugins Loaded
214 *
215 * Checks if Elementor has loaded, and performs some compatibility checks.
216 * If All checks pass, inits the plugin.
217 *
218 * Fired by `plugins_loaded` action hook.
219 *
220 * @since 1.0.0
221 * @access public
222 */
223 public function on_plugins_loaded() {
224 if ( $this->is_compatible() ) {
225 add_action( 'elementor/init', array( $this, 'init' ) );
226
227 // Setup some extra stuff for specific widgets.
228 require_once WPZOOM_EL_ADDONS_PATH . 'includes/widgets/featured-category/category-image.php';
229 new \WPZOOMElementorWidgets\Featured_Category_Image();
230 }
231 }
232
233 /**
234 * Compatibility Checks
235 *
236 * Checks if the installed version of Elementor meets the plugin's minimum requirement.
237 * Checks if the installed PHP version meets the plugin's minimum requirement.
238 *
239 * @since 1.0.0
240 * @access public
241 */
242 public function is_compatible() {
243 // Check if Elementor installed and activated
244 if ( ! did_action( 'elementor/loaded' ) ) {
245 add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
246 return false;
247 }
248
249 // Check for required Elementor version
250 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
251 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
252 return false;
253 }
254
255 // Check for required PHP version
256 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
257 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
258 return false;
259 }
260
261 return true;
262 }
263
264 /**
265 * Initialize the plugin
266 *
267 * Load the plugin only after Elementor (and other plugins) are loaded.
268 * Load the files required to run the plugin.
269 *
270 * Fired by `plugins_loaded` action hook.
271 *
272 * @since 1.0.0
273 * @access public
274 */
275 public function init() {
276 // Load template library (import handler) only after Elementor has loaded,
277 // so WPZOOM_Library_Source is registered and get_content_from_elementor_export_file works.
278 require_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-template-library.php';
279 }
280
281
282 /**
283 * Admin notice
284 *
285 * Warning when the site doesn't have Elementor installed or activated.
286 *
287 * @since 1.0.0
288 * @access public
289 */
290 public function admin_notice_missing_main_plugin() {
291
292
293 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
294
295 $plugin = 'elementor/elementor.php';
296 $installed_plugins = get_plugins();
297 $is_elementor_installed = isset( $installed_plugins[ $plugin ] );
298
299 if ( $is_elementor_installed ) {
300
301 $message = sprintf(
302 /* translators: 1: Plugin name 2: Elementor */
303 esc_html__( '"%1$s" requires "%2$s" to be activated.', 'wpzoom-elementor-addons' ),
304 '<strong>' . esc_html__( 'WPZOOM Elementor Addons', 'wpzoom-elementor-addons' ) . '</strong>',
305 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>'
306 );
307
308 $button_text = esc_html__( 'Activate Elementor', 'wpzoom-elementor-addons' );
309 $button_link = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
310
311 } else {
312
313 $message = sprintf(
314 /* translators: 1: Plugin name 2: Elementor */
315 esc_html__( '"%1$s" requires "%2$s" to be installed.', 'wpzoom-elementor-addons' ),
316 '<strong>' . esc_html__( 'WPZOOM Elementor Addons', 'wpzoom-elementor-addons' ) . '</strong>',
317 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>'
318 );
319
320 $button_text = esc_html__( 'Install Elementor', 'wpzoom-elementor-addons' );
321 $button_link = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
322
323 }
324
325 $button = sprintf(
326 /* translators: 1: Button URL 2: Button text */
327 '<a class="button button-primary" href="%1$s">%2$s</a>',
328 esc_url( $button_link ),
329 esc_html( $button_text )
330 );
331
332 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p> <p>%2$s</p></div>', $message, $button );
333
334 }
335
336 /**
337 * Admin notice
338 *
339 * Warning when the site doesn't have a minimum required Elementor version.
340 *
341 * @since 1.0.0
342 * @access public
343 */
344 public function admin_notice_minimum_elementor_version() {
345 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
346
347 $message = sprintf(
348 /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
349 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpzoom-elementor-addons' ),
350 '<strong>' . esc_html__( 'Elementor Test Extension', 'wpzoom-elementor-addons' ) . '</strong>',
351 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>',
352 self::MINIMUM_ELEMENTOR_VERSION
353 );
354
355 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
356 }
357
358 /**
359 * Admin notice
360 *
361 * Warning when the site doesn't have a minimum required PHP version.
362 *
363 * @since 1.0.0
364 * @access public
365 */
366 public function admin_notice_minimum_php_version() {
367 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
368
369 $message = sprintf(
370 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
371 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpzoom-elementor-addons' ),
372 '<strong>' . esc_html__( 'Elementor Test Extension', 'wpzoom-elementor-addons' ) . '</strong>',
373 '<strong>' . esc_html__( 'PHP', 'wpzoom-elementor-addons' ) . '</strong>',
374 self::MINIMUM_PHP_VERSION
375 );
376 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
377 }
378
379 /**
380 * Enqueue admin styles for modern notices
381 *
382 * @since 1.0.0
383 * @access public
384 */
385 public function enqueue_admin_styles() {
386 wp_enqueue_style(
387 'wpzoom-elementor-addons-admin-notices',
388 plugins_url( 'assets/css/admin-notices.css', WPZOOM_EL_ADDONS__FILE__ ),
389 array(),
390 WPZOOM_EL_ADDONS_VER
391 );
392 }
393
394 /**
395 * Pro plugin promotion notice
396 *
397 * Shows a notice promoting the Pro plugin when it's not active.
398 *
399 * @since 1.0.0
400 * @access public
401 */
402 public function pro_plugin_promotion_notice() {
403 // Only show to administrators
404 if ( ! current_user_can( 'manage_options' ) ) {
405 return;
406 }
407
408 // Don't show if Pro plugin is active
409 if ( class_exists( 'WPZOOM_Elementor_Addons_Pro' ) ) {
410 return;
411 }
412
413 // Don't show if WPZOOM premium theme is active (they get access anyway)
414 if ( class_exists( 'WPZOOM' ) ) {
415 return;
416 }
417
418 // Don't show on the Pro plugin license page
419 if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpzoom-addons-pro' ) {
420 return;
421 }
422
423 // Check if notice was dismissed
424 if ( get_option( 'wpzoom_pro_notice_dismissed', false ) ) {
425 return;
426 }
427
428 // Only show on relevant admin pages
429 $screen = get_current_screen();
430 $allowed_screens = [
431 'dashboard',
432 'plugins',
433 'elementor_page_elementor-system-info',
434 'toplevel_page_elementor',
435 'edit-elementor_library'
436 ];
437
438 if ( ! $screen || ! in_array( $screen->id, $allowed_screens ) ) {
439 return;
440 }
441
442 ?>
443 <div class="notice notice-info wpzoom-modern-notice is-dismissible" data-notice="wpzoom-pro">
444 <div class="wpzoom-notice-header notice-info">
445 <div class="wpzoom-notice-icon"><svg height="40" viewBox="0 0 512 512" width="40" xmlns="http://www.w3.org/2000/svg"><title/><path d="M448,256c0-106-86-192-192-192S64,150,64,256s86,192,192,192S448,362,448,256Z" style="fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:32px"/><path d="M216.32,334.44,330.77,265.3a10.89,10.89,0,0,0,0-18.6L216.32,177.56A10.78,10.78,0,0,0,200,186.87V325.13A10.78,10.78,0,0,0,216.32,334.44Z"/ fill="#fff"></svg></div>
446 <div class="wpzoom-notice-content">
447 <h3 class="wpzoom-notice-title">
448 <?php esc_html_e( 'Slideshow with Video Backgrounds for Elementor now Available!', 'wpzoom-elementor-addons' ); ?>
449 <span class="wpzoom-notice-badge wpzoom-notice-badge-pro"><?php esc_html_e( 'PRO', 'wpzoom-elementor-addons' ); ?></span>
450 </h3>
451 <p class="wpzoom-notice-description">
452 <?php esc_html_e( 'Unlock the new Video Slideshow widget and get access to all premium Elementor templates.', 'wpzoom-elementor-addons' ); ?>
453 </p>
454 </div>
455 <button type="button" class="wpzoom-notice-dismiss" aria-label="<?php esc_attr_e( 'Dismiss notice', 'wpzoom-elementor-addons' ); ?>"></button>
456 </div>
457
458 <div class="wpzoom-notice-body">
459 <p>
460 <?php esc_html_e( 'Upgrade today to unlock the new Video Slideshow widget and access all premium Elementor templates with advanced features and priority support.', 'wpzoom-elementor-addons' ); ?>
461 </p>
462
463 <div class="wpzoom-notice-features">
464 <div class="wpzoom-notice-feature">
465 <div class="wpzoom-notice-feature-icon">🎥</div>
466 <div class="wpzoom-notice-feature-content">
467 <h4><?php esc_html_e( 'Video Slideshow Widget', 'wpzoom-elementor-addons' ); ?></h4>
468 <p><?php esc_html_e( 'Create stunning video slideshows with multiple sources and advanced controls.', 'wpzoom-elementor-addons' ); ?></p>
469 </div>
470 </div>
471 <div class="wpzoom-notice-feature">
472 <div class="wpzoom-notice-feature-icon">🎨</div>
473 <div class="wpzoom-notice-feature-content">
474 <h4><?php esc_html_e( '130+ Elementor Templates', 'wpzoom-elementor-addons' ); ?></h4>
475 <p><?php esc_html_e( 'Access to exclusive Elementor templates and professional designs.', 'wpzoom-elementor-addons' ); ?></p>
476 </div>
477 </div>
478 <div class="wpzoom-notice-feature">
479 <div class="wpzoom-notice-feature-icon">🚀</div>
480 <div class="wpzoom-notice-feature-content">
481 <h4><?php esc_html_e( 'Priority Support', 'wpzoom-elementor-addons' ); ?></h4>
482 <p><?php esc_html_e( 'Get priority support and regular updates for your Pro license.', 'wpzoom-elementor-addons' ); ?></p>
483 </div>
484 </div>
485 </div>
486
487 <div class="wpzoom-notice-actions">
488 <a href="https://www.wpzoom.com/plugins/wpzoom-elementor-addons/" target="_blank" class="wpzoom-notice-btn wpzoom-notice-btn-primary">
489 <?php esc_html_e( 'Get the Pro Version', 'wpzoom-elementor-addons' ); ?>
490 </a>
491 <a href="https://demo.wpzoom.com/inspiro-lite/video-slideshow-demo/" target="_blank" class="wpzoom-notice-btn wpzoom-notice-btn-secondary">
492 <?php esc_html_e( 'View Demo', 'wpzoom-elementor-addons' ); ?>
493 </a>
494 </div>
495 </div>
496 </div>
497 <script>
498 jQuery(document).ready(function($) {
499 // Handle both WordPress default dismiss button and custom dismiss button
500 $(document).on('click', '[data-notice="wpzoom-pro"] .notice-dismiss, [data-notice="wpzoom-pro"] .wpzoom-notice-dismiss', function() {
501 $.post(ajaxurl, {
502 action: 'wpzoom_dismiss_pro_notice',
503 nonce: '<?php echo wp_create_nonce( 'wpzoom_dismiss_pro_notice' ); ?>'
504 });
505
506 // If custom dismiss button, hide the notice
507 if ($(this).hasClass('wpzoom-notice-dismiss')) {
508 $(this).closest('.wpzoom-modern-notice').fadeOut();
509 }
510 });
511 });
512 </script>
513 <?php
514 }
515
516 /**
517 * Dismiss Pro notice
518 *
519 * AJAX handler for dismissing the Pro plugin promotion notice.
520 *
521 * @since 1.0.0
522 * @access public
523 */
524 public function dismiss_pro_notice() {
525 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpzoom_dismiss_pro_notice' ) ) {
526 wp_die( 'Security check failed' );
527 }
528
529 if ( ! current_user_can( 'manage_options' ) ) {
530 wp_die( 'Insufficient permissions' );
531 }
532
533 update_option( 'wpzoom_pro_notice_dismissed', true );
534 wp_die();
535 }
536 }
537