PluginProbe
WPZOOM Addons for Elementor – Starter Templates & Widgets / trunk
WPZOOM Addons for Elementor – Starter Templates & Widgets vtrunk
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 trunk, at wpzoom-elementor-addons.php

552 lines 21.1 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.12
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.1
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 'i18n' => array(
210 'insert_page' => __( 'Insert Page', 'wpzoom-elementor-addons' ),
211 'insert_section' => __( 'Insert Section', 'wpzoom-elementor-addons' ),
212 'insert_wireframe' => __( 'Insert Wireframe', 'wpzoom-elementor-addons' ),
213 'unlock_with_pro' => __( 'Unlock with Pro', 'wpzoom-elementor-addons' ),
214 'wpzoom_library' => __( 'WPZOOM Library', 'wpzoom-elementor-addons' ),
215
216 'locked_template' => __( 'This template is only available with WPZOOM Elementor Addons Pro license. Please visit wpzoom.com to get your license key.', 'wpzoom-elementor-addons' ),
217 'license_required' => __( 'This template requires WPZOOM Elementor Addons Pro license.', 'wpzoom-elementor-addons' ),
218 'enter_license' => __( 'Enter License Key', 'wpzoom-elementor-addons' ),
219 'get_license' => __( 'Get License Key', 'wpzoom-elementor-addons' ),
220 'import_failed' => __( 'The template could not be imported. Please try again.', 'wpzoom-elementor-addons' ),
221 'import_invalid' => __( 'The template could not be imported. Invalid template data.', 'wpzoom-elementor-addons' ),
222 'import_error' => __( 'The template could not be imported. Please try again or get in touch with the WPZOOM team.', 'wpzoom-elementor-addons' ),
223 ),
224 ) );
225 }
226
227 /**
228 * On Plugins Loaded
229 *
230 * Checks if Elementor has loaded, and performs some compatibility checks.
231 * If All checks pass, inits the plugin.
232 *
233 * Fired by `plugins_loaded` action hook.
234 *
235 * @since 1.0.0
236 * @access public
237 */
238 public function on_plugins_loaded() {
239 if ( $this->is_compatible() ) {
240 add_action( 'elementor/init', array( $this, 'init' ) );
241
242 // Setup some extra stuff for specific widgets.
243 require_once WPZOOM_EL_ADDONS_PATH . 'includes/widgets/featured-category/category-image.php';
244 new \WPZOOMElementorWidgets\Featured_Category_Image();
245 }
246 }
247
248 /**
249 * Compatibility Checks
250 *
251 * Checks if the installed version of Elementor meets the plugin's minimum requirement.
252 * Checks if the installed PHP version meets the plugin's minimum requirement.
253 *
254 * @since 1.0.0
255 * @access public
256 */
257 public function is_compatible() {
258 // Check if Elementor installed and activated
259 if ( ! did_action( 'elementor/loaded' ) ) {
260 add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
261 return false;
262 }
263
264 // Check for required Elementor version
265 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
266 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
267 return false;
268 }
269
270 // Check for required PHP version
271 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
272 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
273 return false;
274 }
275
276 return true;
277 }
278
279 /**
280 * Initialize the plugin
281 *
282 * Load the plugin only after Elementor (and other plugins) are loaded.
283 * Load the files required to run the plugin.
284 *
285 * Fired by `plugins_loaded` action hook.
286 *
287 * @since 1.0.0
288 * @access public
289 */
290 public function init() {
291 // Load template library (import handler) only after Elementor has loaded,
292 // so WPZOOM_Library_Source is registered and get_content_from_elementor_export_file works.
293 require_once WPZOOM_EL_ADDONS_PATH . 'includes/wpzoom-template-library.php';
294 }
295
296
297 /**
298 * Admin notice
299 *
300 * Warning when the site doesn't have Elementor installed or activated.
301 *
302 * @since 1.0.0
303 * @access public
304 */
305 public function admin_notice_missing_main_plugin() {
306
307
308 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
309
310 $plugin = 'elementor/elementor.php';
311 $installed_plugins = get_plugins();
312 $is_elementor_installed = isset( $installed_plugins[ $plugin ] );
313
314 if ( $is_elementor_installed ) {
315
316 $message = sprintf(
317 /* translators: 1: Plugin name 2: Elementor */
318 esc_html__( '"%1$s" requires "%2$s" to be activated.', 'wpzoom-elementor-addons' ),
319 '<strong>' . esc_html__( 'WPZOOM Elementor Addons', 'wpzoom-elementor-addons' ) . '</strong>',
320 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>'
321 );
322
323 $button_text = esc_html__( 'Activate Elementor', 'wpzoom-elementor-addons' );
324 $button_link = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
325
326 } else {
327
328 $message = sprintf(
329 /* translators: 1: Plugin name 2: Elementor */
330 esc_html__( '"%1$s" requires "%2$s" to be installed.', 'wpzoom-elementor-addons' ),
331 '<strong>' . esc_html__( 'WPZOOM Elementor Addons', 'wpzoom-elementor-addons' ) . '</strong>',
332 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>'
333 );
334
335 $button_text = esc_html__( 'Install Elementor', 'wpzoom-elementor-addons' );
336 $button_link = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
337
338 }
339
340 $button = sprintf(
341 /* translators: 1: Button URL 2: Button text */
342 '<a class="button button-primary" href="%1$s">%2$s</a>',
343 esc_url( $button_link ),
344 esc_html( $button_text )
345 );
346
347 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p> <p>%2$s</p></div>', $message, $button );
348
349 }
350
351 /**
352 * Admin notice
353 *
354 * Warning when the site doesn't have a minimum required Elementor version.
355 *
356 * @since 1.0.0
357 * @access public
358 */
359 public function admin_notice_minimum_elementor_version() {
360 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
361
362 $message = sprintf(
363 /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
364 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpzoom-elementor-addons' ),
365 '<strong>' . esc_html__( 'Elementor Test Extension', 'wpzoom-elementor-addons' ) . '</strong>',
366 '<strong>' . esc_html__( 'Elementor', 'wpzoom-elementor-addons' ) . '</strong>',
367 self::MINIMUM_ELEMENTOR_VERSION
368 );
369
370 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
371 }
372
373 /**
374 * Admin notice
375 *
376 * Warning when the site doesn't have a minimum required PHP version.
377 *
378 * @since 1.0.0
379 * @access public
380 */
381 public function admin_notice_minimum_php_version() {
382 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
383
384 $message = sprintf(
385 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
386 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpzoom-elementor-addons' ),
387 '<strong>' . esc_html__( 'Elementor Test Extension', 'wpzoom-elementor-addons' ) . '</strong>',
388 '<strong>' . esc_html__( 'PHP', 'wpzoom-elementor-addons' ) . '</strong>',
389 self::MINIMUM_PHP_VERSION
390 );
391 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
392 }
393
394 /**
395 * Enqueue admin styles for modern notices
396 *
397 * @since 1.0.0
398 * @access public
399 */
400 public function enqueue_admin_styles() {
401 wp_enqueue_style(
402 'wpzoom-elementor-addons-admin-notices',
403 plugins_url( 'assets/css/admin-notices.css', WPZOOM_EL_ADDONS__FILE__ ),
404 array(),
405 WPZOOM_EL_ADDONS_VER
406 );
407 }
408
409 /**
410 * Pro plugin promotion notice
411 *
412 * Shows a notice promoting the Pro plugin when it's not active.
413 *
414 * @since 1.0.0
415 * @access public
416 */
417 public function pro_plugin_promotion_notice() {
418 // Only show to administrators
419 if ( ! current_user_can( 'manage_options' ) ) {
420 return;
421 }
422
423 // Don't show if Pro plugin is active
424 if ( class_exists( 'WPZOOM_Elementor_Addons_Pro' ) ) {
425 return;
426 }
427
428 // Don't show if WPZOOM premium theme is active (they get access anyway)
429 if ( class_exists( 'WPZOOM' ) ) {
430 return;
431 }
432
433 // Don't show on the Pro plugin license page
434 if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpzoom-addons-pro' ) {
435 return;
436 }
437
438 // Check if notice was dismissed
439 if ( get_option( 'wpzoom_pro_notice_dismissed', false ) ) {
440 return;
441 }
442
443 // Only show on relevant admin pages
444 $screen = get_current_screen();
445 $allowed_screens = [
446 'dashboard',
447 'plugins',
448 'elementor_page_elementor-system-info',
449 'toplevel_page_elementor',
450 'edit-elementor_library'
451 ];
452
453 if ( ! $screen || ! in_array( $screen->id, $allowed_screens ) ) {
454 return;
455 }
456
457 ?>
458 <div class="notice notice-info wpzoom-modern-notice is-dismissible" data-notice="wpzoom-pro">
459 <div class="wpzoom-notice-header notice-info">
460 <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>
461 <div class="wpzoom-notice-content">
462 <h3 class="wpzoom-notice-title">
463 <?php esc_html_e( 'Slideshow with Video Backgrounds for Elementor now Available!', 'wpzoom-elementor-addons' ); ?>
464 <span class="wpzoom-notice-badge wpzoom-notice-badge-pro"><?php esc_html_e( 'PRO', 'wpzoom-elementor-addons' ); ?></span>
465 </h3>
466 <p class="wpzoom-notice-description">
467 <?php esc_html_e( 'Unlock the new Video Slideshow widget and get access to all premium Elementor templates.', 'wpzoom-elementor-addons' ); ?>
468 </p>
469 </div>
470 <button type="button" class="wpzoom-notice-dismiss" aria-label="<?php esc_attr_e( 'Dismiss notice', 'wpzoom-elementor-addons' ); ?>"></button>
471 </div>
472
473 <div class="wpzoom-notice-body">
474 <p>
475 <?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' ); ?>
476 </p>
477
478 <div class="wpzoom-notice-features">
479 <div class="wpzoom-notice-feature">
480 <div class="wpzoom-notice-feature-icon">🎥</div>
481 <div class="wpzoom-notice-feature-content">
482 <h4><?php esc_html_e( 'Video Slideshow Widget', 'wpzoom-elementor-addons' ); ?></h4>
483 <p><?php esc_html_e( 'Create stunning video slideshows with multiple sources and advanced controls.', 'wpzoom-elementor-addons' ); ?></p>
484 </div>
485 </div>
486 <div class="wpzoom-notice-feature">
487 <div class="wpzoom-notice-feature-icon">🎨</div>
488 <div class="wpzoom-notice-feature-content">
489 <h4><?php esc_html_e( '130+ Elementor Templates', 'wpzoom-elementor-addons' ); ?></h4>
490 <p><?php esc_html_e( 'Access to exclusive Elementor templates and professional designs.', 'wpzoom-elementor-addons' ); ?></p>
491 </div>
492 </div>
493 <div class="wpzoom-notice-feature">
494 <div class="wpzoom-notice-feature-icon">🚀</div>
495 <div class="wpzoom-notice-feature-content">
496 <h4><?php esc_html_e( 'Priority Support', 'wpzoom-elementor-addons' ); ?></h4>
497 <p><?php esc_html_e( 'Get priority support and regular updates for your Pro license.', 'wpzoom-elementor-addons' ); ?></p>
498 </div>
499 </div>
500 </div>
501
502 <div class="wpzoom-notice-actions">
503 <a href="https://www.wpzoom.com/plugins/wpzoom-elementor-addons/" target="_blank" class="wpzoom-notice-btn wpzoom-notice-btn-primary">
504 <?php esc_html_e( 'Get the Pro Version', 'wpzoom-elementor-addons' ); ?>
505 </a>
506 <a href="https://demo.wpzoom.com/inspiro-lite/video-slideshow-demo/" target="_blank" class="wpzoom-notice-btn wpzoom-notice-btn-secondary">
507 <?php esc_html_e( 'View Demo', 'wpzoom-elementor-addons' ); ?>
508 </a>
509 </div>
510 </div>
511 </div>
512 <script>
513 jQuery(document).ready(function($) {
514 // Handle both WordPress default dismiss button and custom dismiss button
515 $(document).on('click', '[data-notice="wpzoom-pro"] .notice-dismiss, [data-notice="wpzoom-pro"] .wpzoom-notice-dismiss', function() {
516 $.post(ajaxurl, {
517 action: 'wpzoom_dismiss_pro_notice',
518 nonce: '<?php echo wp_create_nonce( 'wpzoom_dismiss_pro_notice' ); ?>'
519 });
520
521 // If custom dismiss button, hide the notice
522 if ($(this).hasClass('wpzoom-notice-dismiss')) {
523 $(this).closest('.wpzoom-modern-notice').fadeOut();
524 }
525 });
526 });
527 </script>
528 <?php
529 }
530
531 /**
532 * Dismiss Pro notice
533 *
534 * AJAX handler for dismissing the Pro plugin promotion notice.
535 *
536 * @since 1.0.0
537 * @access public
538 */
539 public function dismiss_pro_notice() {
540 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpzoom_dismiss_pro_notice' ) ) {
541 wp_die( 'Security check failed' );
542 }
543
544 if ( ! current_user_can( 'manage_options' ) ) {
545 wp_die( 'Insufficient permissions' );
546 }
547
548 update_option( 'wpzoom_pro_notice_dismissed', true );
549 wp_die();
550 }
551 }
552