controls
8 months ago
pa-display-conditions
8 months ago
templates
8 months ago
acf-helper.php
8 months ago
addons-cross-cp.php
8 months ago
addons-integration.php
8 months ago
assets-manager.php
8 months ago
class-pa-core.php
8 months ago
class-premium-template-tags.php
8 months ago
helper-functions.php
8 months ago
live-editor-modal.php
8 months ago
module-base.php
8 months ago
pa-nav-menu-walker.php
8 months ago
papro-promotion.php
8 months ago
addons-integration.php
1783 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Addons Integration. |
| 4 | */ |
| 5 | |
| 6 | namespace PremiumAddons\Includes; |
| 7 | |
| 8 | use PremiumAddons\Includes\Helper_Functions; |
| 9 | use PremiumAddons\Admin\Includes\Admin_Helper; |
| 10 | use PremiumAddons\Modules\Premium_Equal_Height\Module as Equal_Height; |
| 11 | use PremiumAddons\Modules\PA_Display_Conditions\Module as Display_Conditions; |
| 12 | use PremiumAddons\Modules\PremiumSectionFloatingEffects\Module as Floating_Effects; |
| 13 | use PremiumAddons\Modules\Woocommerce\Module as Woocommerce; |
| 14 | use PremiumAddons\Modules\PremiumGlobalTooltips\Module as GlobalTooltips; |
| 15 | use PremiumAddons\Modules\PremiumShapeDivider\Module as Shape_Divider; |
| 16 | use PremiumAddons\Modules\PremiumWrapperLink\Module as Wrapper_Link; |
| 17 | use PremiumAddons\Modules\PremiumGlassmorphism\Module as Glassmorphism; |
| 18 | use PremiumAddons\Includes\Assets_Manager; |
| 19 | use ElementorPro\Plugin as PluginPro; |
| 20 | |
| 21 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | exit(); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Class Addons_Integration. |
| 27 | */ |
| 28 | class Addons_Integration { |
| 29 | |
| 30 | /** |
| 31 | * Class instance |
| 32 | * |
| 33 | * @var instance |
| 34 | */ |
| 35 | private static $instance = null; |
| 36 | |
| 37 | /** |
| 38 | * CSS Content |
| 39 | * |
| 40 | * @var css_content |
| 41 | */ |
| 42 | private static $css_content = null; |
| 43 | |
| 44 | /** |
| 45 | * Modules |
| 46 | * |
| 47 | * @var modules |
| 48 | */ |
| 49 | private static $modules = null; |
| 50 | |
| 51 | /** |
| 52 | * Integrations Keys |
| 53 | * |
| 54 | * @var integrations |
| 55 | */ |
| 56 | private static $integrations = null; |
| 57 | |
| 58 | /** |
| 59 | * Cross-Site CDN URL. |
| 60 | * |
| 61 | * @since 4.0.0 |
| 62 | * @var (String) URL |
| 63 | */ |
| 64 | public $cdn_url; |
| 65 | |
| 66 | /** |
| 67 | * Initialize integration hooks |
| 68 | * |
| 69 | * @return void |
| 70 | */ |
| 71 | public function __construct() { |
| 72 | |
| 73 | Premium_Template_Tags::getInstance(); |
| 74 | |
| 75 | self::$modules = Admin_Helper::get_enabled_elements(); |
| 76 | |
| 77 | self::$integrations = Admin_Helper::get_integrations_settings(); |
| 78 | |
| 79 | add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_preview_styles' ) ); |
| 80 | add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'enqueue_editor_styles' ) ); |
| 81 | add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'load_live_editor_modal' ) ); |
| 82 | |
| 83 | add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'before_enqueue_scripts' ) ); |
| 84 | add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'after_enqueue_scripts' ) ); |
| 85 | |
| 86 | add_action( 'wp_ajax_handle_live_editor', array( $this, 'handle_live_editor' ) ); |
| 87 | add_action( 'wp_ajax_check_temp_validity', array( $this, 'check_temp_validity' ) ); |
| 88 | add_action( 'wp_ajax_update_template_title', array( $this, 'update_template_title' ) ); |
| 89 | add_action( 'wp_ajax_get_elementor_template_content', array( $this, 'get_template_content' ) ); |
| 90 | |
| 91 | add_action( 'wp_ajax_insert_cf_form', array( $this, 'insert_cf_form' ) ); |
| 92 | |
| 93 | add_action( 'wp_ajax_get_pinterest_token', array( $this, 'get_pinterest_token' ) ); |
| 94 | add_action( 'wp_ajax_get_pinterest_boards', array( $this, 'get_pinterest_boards' ) ); |
| 95 | add_action( 'wp_ajax_get_tiktok_token', array( $this, 'get_tiktok_token' ) ); |
| 96 | |
| 97 | |
| 98 | add_action( 'elementor/frontend/after_register_styles', array( $this, 'register_frontend_styles' ) ); |
| 99 | add_action( 'elementor/frontend/after_register_scripts', array( $this, 'register_frontend_scripts' ) ); |
| 100 | |
| 101 | add_action( 'elementor/controls/register', array( $this, 'init_pa_controls' ) ); |
| 102 | add_action( 'elementor/widgets/register', array( $this, 'widgets_area' ) ); |
| 103 | |
| 104 | if ( defined( 'ELEMENTOR_VERSION' ) ) { |
| 105 | |
| 106 | $this->load_pa_extensions(); |
| 107 | |
| 108 | } |
| 109 | |
| 110 | add_action( 'elementor/elements/categories_registered', array( $this, 'register_widgets_category' ), 9 ); |
| 111 | |
| 112 | $cross_enabled = isset( self::$modules['premium-cross-domain'] ) ? self::$modules['premium-cross-domain'] : 1; |
| 113 | |
| 114 | if ( $cross_enabled ) { |
| 115 | |
| 116 | add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_cp_scripts' ), 99 ); |
| 117 | |
| 118 | $this->load_cp_module(); |
| 119 | |
| 120 | } |
| 121 | |
| 122 | // Exclude our dynamic assets from being minified with WP Optimize. |
| 123 | if ( self::$integrations['premium-wp-optimize-exclude'] ) { |
| 124 | add_filter( 'wp-optimize-minify-default-exclusions', array( $this, 'exclude_pa_assets_from_wp_optimize' ) ); |
| 125 | } |
| 126 | |
| 127 | // Promote PAPRO Elements. |
| 128 | add_filter( 'elementor/editor/localize_settings', array( $this, 'add_papro_elements' ) ); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Update Template Title. |
| 133 | * |
| 134 | * @access public |
| 135 | * @since 4.8.10 |
| 136 | */ |
| 137 | public function update_template_title() { |
| 138 | |
| 139 | check_ajax_referer( 'pa-live-editor', 'security' ); |
| 140 | |
| 141 | if ( ! isset( $_POST['title'] ) || ! isset( $_POST['id'] ) ) { |
| 142 | wp_send_json_error( 'Post has no title.' ); |
| 143 | } |
| 144 | |
| 145 | if ( ! current_user_can( 'manage_options' ) ) { |
| 146 | wp_send_json_error( 'Insufficient user permission' ); |
| 147 | } |
| 148 | |
| 149 | $res = wp_update_post( |
| 150 | array( |
| 151 | 'ID' => sanitize_text_field( wp_unslash( $_POST['id'] ) ), |
| 152 | 'post_title' => sanitize_text_field( wp_unslash( $_POST['title'] ) ), |
| 153 | ) |
| 154 | ); |
| 155 | |
| 156 | wp_send_json_success( $res ); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Check Temp Validity. |
| 161 | * |
| 162 | * Checks if the template is valid ( has content) or not, |
| 163 | * And DELETE the post if it's invalid. |
| 164 | * |
| 165 | * @access public |
| 166 | * @since 4.9.1 |
| 167 | */ |
| 168 | public function check_temp_validity() { |
| 169 | |
| 170 | check_ajax_referer( 'pa-live-editor', 'security' ); |
| 171 | |
| 172 | if ( ! isset( $_POST['templateID'] ) ) { |
| 173 | wp_send_json_error( 'template ID is not set' ); |
| 174 | } |
| 175 | |
| 176 | if ( ! current_user_can( 'manage_options' ) ) { |
| 177 | wp_send_json_error( 'Insufficient user permission' ); |
| 178 | } |
| 179 | |
| 180 | $temp_id = isset( $_POST['templateID'] ) ? sanitize_text_field( wp_unslash( $_POST['templateID'] ) ) : ''; |
| 181 | $temp_type = isset( $_POST['tempType'] ) ? sanitize_text_field( wp_unslash( $_POST['tempType'] ) ) : ''; |
| 182 | |
| 183 | if ( 'loop' === $temp_type ) { |
| 184 | /** @var LoopDocument $document */ |
| 185 | $template_content = PluginPro::elementor()->documents->get( $temp_id ); |
| 186 | |
| 187 | } else { |
| 188 | $template_content = Helper_Functions::render_elementor_template( $temp_id, true ); |
| 189 | |
| 190 | } |
| 191 | |
| 192 | if ( empty( $template_content ) || ! isset( $template_content ) ) { |
| 193 | |
| 194 | $res = wp_delete_post( $temp_id, true ); |
| 195 | |
| 196 | if ( ! is_wp_error( $res ) ) { |
| 197 | $res = 'Template Deleted.'; |
| 198 | } |
| 199 | } else { |
| 200 | $res = 'Template Has Content.'; |
| 201 | } |
| 202 | |
| 203 | wp_send_json_success( $res ); |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Handle Live Editor Modal. |
| 208 | * |
| 209 | * @access public |
| 210 | * @since 4.8.10 |
| 211 | */ |
| 212 | public function handle_live_editor() { |
| 213 | |
| 214 | check_ajax_referer( 'pa-live-editor', 'security' ); |
| 215 | |
| 216 | if ( ! isset( $_POST['key'] ) ) { |
| 217 | wp_send_json_error(); |
| 218 | } |
| 219 | |
| 220 | $post_name = 'pa-dynamic-temp-' . sanitize_text_field( wp_unslash( $_POST['key'] ) ); |
| 221 | $temp_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : false; |
| 222 | $meta_input = array( |
| 223 | '_elementor_edit_mode' => 'builder', |
| 224 | '_elementor_template_type' => 'page', |
| 225 | '_wp_page_template' => 'elementor_canvas', |
| 226 | ); |
| 227 | |
| 228 | if ( 'loop' === $temp_type ) { |
| 229 | $meta_input = array( |
| 230 | '_elementor_edit_mode' => 'builder', |
| 231 | '_elementor_template_type' => 'loop-item', |
| 232 | ); |
| 233 | } elseif ( 'grid' === $temp_type ) { |
| 234 | $meta_input = array( |
| 235 | '_elementor_edit_mode' => 'builder', |
| 236 | '_elementor_template_type' => 'premium-grid', |
| 237 | ); |
| 238 | } |
| 239 | |
| 240 | $post_title = ''; |
| 241 | $args = array( |
| 242 | 'post_type' => 'elementor_library', |
| 243 | 'name' => $post_name, |
| 244 | 'post_status' => 'publish', |
| 245 | 'update_post_term_cache' => false, |
| 246 | 'update_post_meta_cache' => false, |
| 247 | 'posts_per_page' => 1, |
| 248 | ); |
| 249 | |
| 250 | $post = get_posts( $args ); |
| 251 | |
| 252 | if ( empty( $post ) ) { // create a new one. |
| 253 | |
| 254 | $key = sanitize_text_field( wp_unslash( $_POST['key'] ) ); |
| 255 | $post_title = 'PA Template | #' . substr( md5( $key ), 0, 4 ); |
| 256 | |
| 257 | $params = array( |
| 258 | 'post_content' => '', |
| 259 | 'post_type' => 'elementor_library', |
| 260 | 'post_title' => $post_title, |
| 261 | 'post_name' => $post_name, |
| 262 | 'post_status' => 'publish', |
| 263 | 'meta_input' => $meta_input, |
| 264 | ); |
| 265 | |
| 266 | $post_id = wp_insert_post( $params ); |
| 267 | |
| 268 | } else { // edit post. |
| 269 | $post_id = $post[0]->ID; |
| 270 | $post_title = $post[0]->post_title; |
| 271 | } |
| 272 | |
| 273 | $edit_url = get_admin_url() . '/post.php?post=' . $post_id . '&action=elementor'; |
| 274 | |
| 275 | $result = array( |
| 276 | 'url' => $edit_url, |
| 277 | 'id' => $post_id, |
| 278 | 'title' => $post_title, |
| 279 | ); |
| 280 | |
| 281 | wp_send_json_success( $result ); |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Load Live Editor Modal. |
| 286 | * Puts live editor popup html into the editor. |
| 287 | * |
| 288 | * @access public |
| 289 | * @since 4.8.10 |
| 290 | */ |
| 291 | public function load_live_editor_modal() { |
| 292 | ob_start(); |
| 293 | include_once PREMIUM_ADDONS_PATH . 'includes/live-editor-modal.php'; |
| 294 | $output = ob_get_contents(); |
| 295 | ob_end_clean(); |
| 296 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 297 | } |
| 298 | |
| 299 | |
| 300 | /** |
| 301 | * After Enqueue Scripts |
| 302 | * |
| 303 | * Loads editor scripts for our controls. |
| 304 | * |
| 305 | * @access public |
| 306 | * @return void |
| 307 | */ |
| 308 | public function after_enqueue_scripts() { |
| 309 | |
| 310 | wp_enqueue_script( |
| 311 | 'live-editor', |
| 312 | PREMIUM_ADDONS_URL . 'assets/editor/js/live-editor.js', |
| 313 | array( 'elementor-editor', 'jquery' ), |
| 314 | PREMIUM_ADDONS_VERSION, |
| 315 | true |
| 316 | ); |
| 317 | |
| 318 | $live_editor_data = array( |
| 319 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 320 | 'nonce' => wp_create_nonce( 'pa-live-editor' ), |
| 321 | ); |
| 322 | |
| 323 | wp_localize_script( 'live-editor', 'liveEditor', $live_editor_data ); |
| 324 | |
| 325 | wp_enqueue_script( |
| 326 | 'pa-controls-handlers', |
| 327 | PREMIUM_ADDONS_URL . 'assets/editor/js/controls-handlers.js', |
| 328 | array( 'elementor-editor', 'jquery' ), |
| 329 | PREMIUM_ADDONS_VERSION, |
| 330 | true |
| 331 | ); |
| 332 | |
| 333 | wp_localize_script( |
| 334 | 'pa-controls-handlers', |
| 335 | 'PremiumSettings', |
| 336 | array( |
| 337 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 338 | 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ), |
| 339 | 'unused_nonce' => wp_create_nonce( 'pa-disable-unused' ), |
| 340 | ) |
| 341 | ); |
| 342 | |
| 343 | $time_limit = ini_get( 'max_execution_time' ); |
| 344 | |
| 345 | wp_localize_script( |
| 346 | 'pa-controls-handlers', |
| 347 | 'PremiumPanelSettings', |
| 348 | array( |
| 349 | 'papro_installed' => Helper_Functions::check_papro_version(), |
| 350 | ) |
| 351 | ); |
| 352 | |
| 353 | $pinterest_enabled = isset( self::$modules['premium-pinterest-feed'] ) ? self::$modules['premium-pinterest-feed'] : 1; |
| 354 | $tiktok_enabled = isset( self::$modules['premium-tiktok-feed'] ) ? self::$modules['premium-tiktok-feed'] : 1; |
| 355 | |
| 356 | $cf_enabled = isset( self::$modules['premium-contactform'] ) ? self::$modules['premium-contactform'] : 1; |
| 357 | |
| 358 | if ( $cf_enabled || $pinterest_enabled || $tiktok_enabled ) { |
| 359 | |
| 360 | $data = array( |
| 361 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 362 | 'nonce' => wp_create_nonce( 'pa-editor' ), |
| 363 | ); |
| 364 | |
| 365 | wp_enqueue_script( |
| 366 | 'pa-editor-handler', |
| 367 | PREMIUM_ADDONS_URL . 'assets/editor/js/editor-handler.js', |
| 368 | array( 'elementor-editor' ), |
| 369 | PREMIUM_ADDONS_VERSION, |
| 370 | true |
| 371 | ); |
| 372 | |
| 373 | wp_localize_script( 'pa-editor-handler', 'paEditorSettings', $data ); |
| 374 | |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Loads plugin icons font |
| 380 | * |
| 381 | * @since 1.0.0 |
| 382 | * @access public |
| 383 | * @return void |
| 384 | */ |
| 385 | public function enqueue_editor_styles() { |
| 386 | |
| 387 | $theme = Helper_Functions::get_elementor_ui_theme(); |
| 388 | |
| 389 | wp_enqueue_style( |
| 390 | 'pa-editor', |
| 391 | PREMIUM_ADDONS_URL . 'assets/editor/css/style.css', |
| 392 | array(), |
| 393 | PREMIUM_ADDONS_VERSION |
| 394 | ); |
| 395 | |
| 396 | // Enqueue required style for Elementor dark UI Theme. |
| 397 | if ( 'dark' === $theme ) { |
| 398 | |
| 399 | wp_add_inline_style( |
| 400 | 'pa-editor', |
| 401 | '.elementor-panel .elementor-control-section_pa_docs .elementor-panel-heading-title.elementor-panel-heading-title, |
| 402 | .elementor-control-raw-html.editor-pa-doc a { |
| 403 | color: #e0e1e3 !important; |
| 404 | } |
| 405 | [class^="pa-"]::after, |
| 406 | [class*=" pa-"]::after { |
| 407 | color: #aaa; |
| 408 | opacity: 1 !important; |
| 409 | } |
| 410 | .premium-promotion-dialog .premium-promotion-btn { |
| 411 | background-color: #202124 !important |
| 412 | }' |
| 413 | ); |
| 414 | |
| 415 | } |
| 416 | |
| 417 | $badge_text = Helper_Functions::get_badge(); |
| 418 | |
| 419 | $dynamic_css = sprintf( '.elementor-element-wrapper:not(.elementor-element--promotion) [class^="pa-"]::after, .elementor-element-wrapper:not(.elementor-element--promotion) [class*=" pa-"]::after { content: "%s"; }', $badge_text ); |
| 420 | |
| 421 | wp_add_inline_style( 'pa-editor', $dynamic_css ); |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Register Frontend CSS files |
| 426 | * |
| 427 | * @since 2.9.0 |
| 428 | * @access public |
| 429 | */ |
| 430 | public function register_frontend_styles() { |
| 431 | |
| 432 | $dir = Helper_Functions::get_styles_dir(); |
| 433 | $suffix = Helper_Functions::get_assets_suffix(); |
| 434 | |
| 435 | wp_register_style( |
| 436 | 'font-awesome-5-all', |
| 437 | ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css', |
| 438 | false, |
| 439 | PREMIUM_ADDONS_VERSION |
| 440 | ); |
| 441 | |
| 442 | wp_register_style( |
| 443 | 'pa-flipster', |
| 444 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/flipster' . $suffix . '.css', |
| 445 | false, |
| 446 | PREMIUM_ADDONS_VERSION |
| 447 | ); |
| 448 | |
| 449 | wp_register_style( |
| 450 | 'pa-prettyphoto', |
| 451 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyphoto' . $suffix . '.css', |
| 452 | array(), |
| 453 | PREMIUM_ADDONS_VERSION, |
| 454 | 'all' |
| 455 | ); |
| 456 | |
| 457 | wp_register_style( |
| 458 | 'pa-btn', |
| 459 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/button-line' . $suffix . '.css', |
| 460 | array(), |
| 461 | PREMIUM_ADDONS_VERSION, |
| 462 | 'all' |
| 463 | ); |
| 464 | |
| 465 | wp_register_style( |
| 466 | 'pa-load-animations', |
| 467 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/load-animations' . $suffix . '.css', |
| 468 | array(), |
| 469 | PREMIUM_ADDONS_VERSION, |
| 470 | 'all' |
| 471 | ); |
| 472 | |
| 473 | wp_register_style( |
| 474 | 'pa-share-btn', |
| 475 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/share-button' . $suffix . '.css', |
| 476 | array(), |
| 477 | PREMIUM_ADDONS_VERSION, |
| 478 | 'all' |
| 479 | ); |
| 480 | |
| 481 | wp_register_style( |
| 482 | 'pa-image-effects', |
| 483 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/image-effects' . $suffix . '.css', |
| 484 | array(), |
| 485 | PREMIUM_ADDONS_VERSION, |
| 486 | 'all' |
| 487 | ); |
| 488 | |
| 489 | wp_register_style( |
| 490 | 'pa-slick', |
| 491 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $suffix . '.css', |
| 492 | array(), |
| 493 | PREMIUM_ADDONS_VERSION, |
| 494 | 'all' |
| 495 | ); |
| 496 | |
| 497 | wp_register_style( |
| 498 | 'pa-world-clock', |
| 499 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-world-clock' . $suffix . '.css', |
| 500 | array(), |
| 501 | PREMIUM_ADDONS_VERSION, |
| 502 | 'all' |
| 503 | ); |
| 504 | |
| 505 | wp_register_style( |
| 506 | 'tooltipster', |
| 507 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/tooltipster.min.css', |
| 508 | array(), |
| 509 | PREMIUM_ADDONS_VERSION, |
| 510 | 'all' |
| 511 | ); |
| 512 | |
| 513 | wp_register_style( |
| 514 | 'pa-gTooltips', |
| 515 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-global-tooltips' . $suffix . '.css', |
| 516 | array(), |
| 517 | PREMIUM_ADDONS_VERSION, |
| 518 | 'all' |
| 519 | ); |
| 520 | |
| 521 | wp_register_style( |
| 522 | 'pa-shape-divider', |
| 523 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-shape-divider' . $suffix . '.css', |
| 524 | array(), |
| 525 | PREMIUM_ADDONS_VERSION, |
| 526 | 'all' |
| 527 | ); |
| 528 | |
| 529 | wp_register_style( |
| 530 | 'pa-odometer', |
| 531 | PREMIUM_ADDONS_URL . 'assets/frontend/min-css/odometer.min.css', |
| 532 | array(), |
| 533 | PREMIUM_ADDONS_VERSION, |
| 534 | 'all' |
| 535 | ); |
| 536 | |
| 537 | wp_register_style( |
| 538 | 'pa-glass', |
| 539 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/liquid-glass' . $suffix . '.css', |
| 540 | array(), |
| 541 | PREMIUM_ADDONS_VERSION, |
| 542 | 'all' |
| 543 | ); |
| 544 | |
| 545 | $assets_gen_enabled = isset( self::$modules['premium-assets-generator'] ) && self::$modules['premium-assets-generator'] ? true : false; |
| 546 | |
| 547 | $type = get_post_type(); |
| 548 | |
| 549 | // If dynamic assets is disabled. |
| 550 | if ( ! $assets_gen_enabled || ( 'page' !== $type && 'post' !== $type ) ) { |
| 551 | $this->enqueue_old_styles( $dir, $suffix ); |
| 552 | } else { |
| 553 | |
| 554 | // If the assets are generated correctly due to server errors. |
| 555 | if ( 'empty' === self::$css_content ) { |
| 556 | $this->enqueue_old_styles( $dir, $suffix ); |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | $css_path = '/pa-frontend' . '-' . Assets_Manager::$post_id . $suffix . '.css'; |
| 561 | |
| 562 | if ( Assets_Manager::$is_updated && file_exists( PREMIUM_ASSETS_PATH . $css_path ) ) { |
| 563 | |
| 564 | wp_enqueue_style( |
| 565 | 'pa-frontend', |
| 566 | PREMIUM_ASSETS_URL . $css_path, |
| 567 | array(), |
| 568 | time(), |
| 569 | 'all' |
| 570 | ); |
| 571 | } |
| 572 | |
| 573 | $pa_elements = get_option( 'pa_elements_' . Assets_Manager::$post_id, array() ); |
| 574 | |
| 575 | // If the assets are not updated, or they are updated but the dynamic CSS file has not been loaded for any reason. |
| 576 | if ( ! Assets_Manager::$is_updated || ( ! empty( $pa_elements ) && ! wp_style_is( 'pa-frontend', 'enqueued' ) ) ) { |
| 577 | $this->enqueue_old_styles( $dir, $suffix ); |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Register Old Styles |
| 584 | * |
| 585 | * @since 4.9.0 |
| 586 | * @access public |
| 587 | * |
| 588 | * @param string $directory style directory. |
| 589 | * @param string $suffix file suffix. |
| 590 | */ |
| 591 | public function enqueue_old_styles( $directory, $suffix ) { |
| 592 | |
| 593 | wp_enqueue_style( |
| 594 | 'premium-addons', |
| 595 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $suffix . '.css', |
| 596 | array(), |
| 597 | PREMIUM_ADDONS_VERSION, |
| 598 | 'all' |
| 599 | ); |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * Registers required JS files |
| 604 | * |
| 605 | * @since 1.0.0 |
| 606 | * @access public |
| 607 | */ |
| 608 | public function register_frontend_scripts() { |
| 609 | |
| 610 | $maps_settings = self::$integrations; |
| 611 | |
| 612 | $dir = Helper_Functions::get_scripts_dir(); |
| 613 | $suffix = Helper_Functions::get_assets_suffix(); |
| 614 | |
| 615 | $locale = isset( $maps_settings['premium-map-locale'] ) ? $maps_settings['premium-map-locale'] : 'en'; |
| 616 | $assets_gen_enabled = isset( self::$modules['premium-assets-generator'] ) && self::$modules['premium-assets-generator'] ? true : false; |
| 617 | |
| 618 | $type = get_post_type(); |
| 619 | |
| 620 | if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) { |
| 621 | |
| 622 | // If the elements are cached and ready to generate. |
| 623 | if ( Assets_Manager::$is_updated ) { |
| 624 | Assets_Manager::generate_asset_file( 'js' ); |
| 625 | self::$css_content = Assets_Manager::generate_asset_file( 'css' ); |
| 626 | } |
| 627 | |
| 628 | $js_path = '/pa-frontend-' . Assets_Manager::$post_id . $suffix . '.js'; |
| 629 | |
| 630 | if ( file_exists( PREMIUM_ASSETS_PATH . $js_path ) ) { |
| 631 | |
| 632 | wp_enqueue_script( |
| 633 | 'pa-frontend', |
| 634 | PREMIUM_ASSETS_URL . $js_path, |
| 635 | array( 'jquery' ), |
| 636 | time(), |
| 637 | true |
| 638 | ); |
| 639 | |
| 640 | wp_localize_script( |
| 641 | 'pa-frontend', |
| 642 | 'PremiumSettings', |
| 643 | array( |
| 644 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 645 | 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ), |
| 646 | |
| 647 | ) |
| 648 | ); |
| 649 | |
| 650 | } |
| 651 | |
| 652 | if ( ! wp_script_is( 'pa-frontend', 'enqueued' ) || 'empty' === self::$css_content ) { |
| 653 | // If the assets are not ready, or file does not exist for any reason. |
| 654 | $this->register_old_scripts( $dir, $suffix ); |
| 655 | } |
| 656 | } else { |
| 657 | $this->register_old_scripts( $dir, $suffix ); |
| 658 | } |
| 659 | |
| 660 | // wp_register_script( 'tiktok-embed', 'https://www.tiktok.com/embed.js', array(), false, true ); |
| 661 | |
| 662 | wp_register_script( |
| 663 | 'pa-scrolldir', |
| 664 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/pa-scrolldir' . $suffix . '.js', |
| 665 | array( 'jquery' ), |
| 666 | PREMIUM_ADDONS_VERSION, |
| 667 | true |
| 668 | ); |
| 669 | |
| 670 | wp_register_script( |
| 671 | 'prettyPhoto-js', |
| 672 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyPhoto' . $suffix . '.js', |
| 673 | array( 'jquery' ), |
| 674 | PREMIUM_ADDONS_VERSION, |
| 675 | true |
| 676 | ); |
| 677 | |
| 678 | wp_register_script( |
| 679 | 'tooltipster-bundle', |
| 680 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/tooltipster' . $suffix . '.js', |
| 681 | array( 'jquery' ), |
| 682 | PREMIUM_ADDONS_VERSION, |
| 683 | true |
| 684 | ); |
| 685 | |
| 686 | wp_register_script( |
| 687 | 'pa-vticker', |
| 688 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/vticker' . $suffix . '.js', |
| 689 | array( 'jquery' ), |
| 690 | PREMIUM_ADDONS_VERSION, |
| 691 | true |
| 692 | ); |
| 693 | |
| 694 | wp_register_script( |
| 695 | 'pa-typed', |
| 696 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/typed' . $suffix . '.js', |
| 697 | array( 'jquery' ), |
| 698 | PREMIUM_ADDONS_VERSION, |
| 699 | true |
| 700 | ); |
| 701 | |
| 702 | wp_register_script( |
| 703 | 'countdown-translator', |
| 704 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/countdown-translator' . $suffix . '.js', |
| 705 | array( 'jquery' ), |
| 706 | PREMIUM_ADDONS_VERSION, |
| 707 | true |
| 708 | ); |
| 709 | |
| 710 | wp_register_script( |
| 711 | 'pa-countdown', |
| 712 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-countdown' . $suffix . '.js', |
| 713 | array( 'jquery' ), |
| 714 | PREMIUM_ADDONS_VERSION, |
| 715 | true |
| 716 | ); |
| 717 | |
| 718 | wp_register_script( |
| 719 | 'isotope-js', |
| 720 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/isotope' . $suffix . '.js', |
| 721 | array( 'jquery' ), |
| 722 | PREMIUM_ADDONS_VERSION, |
| 723 | true |
| 724 | ); |
| 725 | |
| 726 | wp_register_script( |
| 727 | 'pa-modal', |
| 728 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/modal' . $suffix . '.js', |
| 729 | array( 'jquery' ), |
| 730 | PREMIUM_ADDONS_VERSION, |
| 731 | true |
| 732 | ); |
| 733 | |
| 734 | wp_register_script( |
| 735 | 'pa-maps', |
| 736 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-maps' . $suffix . '.js', |
| 737 | array( 'jquery' ), |
| 738 | PREMIUM_ADDONS_VERSION, |
| 739 | true |
| 740 | ); |
| 741 | |
| 742 | wp_register_script( |
| 743 | 'pa-vscroll', |
| 744 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-vscroll' . $suffix . '.js', |
| 745 | array( 'jquery' ), |
| 746 | PREMIUM_ADDONS_VERSION, |
| 747 | true |
| 748 | ); |
| 749 | |
| 750 | wp_register_script( |
| 751 | 'pa-slimscroll', |
| 752 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-slimscroll' . $suffix . '.js', |
| 753 | array( 'jquery' ), |
| 754 | PREMIUM_ADDONS_VERSION, |
| 755 | true |
| 756 | ); |
| 757 | |
| 758 | wp_register_script( |
| 759 | 'pa-iscroll', |
| 760 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/iscroll' . $suffix . '.js', |
| 761 | array( 'jquery' ), |
| 762 | PREMIUM_ADDONS_VERSION, |
| 763 | true |
| 764 | ); |
| 765 | |
| 766 | wp_register_script( |
| 767 | 'pa-tilt', |
| 768 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/universal-tilt' . $suffix . '.js', |
| 769 | array( 'jquery' ), |
| 770 | PREMIUM_ADDONS_VERSION, |
| 771 | true |
| 772 | ); |
| 773 | |
| 774 | wp_register_script( |
| 775 | 'lottie-js', |
| 776 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/lottie' . $suffix . '.js', |
| 777 | array( 'jquery' ), |
| 778 | PREMIUM_ADDONS_VERSION, |
| 779 | true |
| 780 | ); |
| 781 | |
| 782 | wp_register_script( |
| 783 | 'pa-odometer', |
| 784 | PREMIUM_ADDONS_URL . 'assets/frontend/min-js/odometer.min.js', |
| 785 | array( 'jquery' ), |
| 786 | PREMIUM_ADDONS_VERSION, |
| 787 | true |
| 788 | ); |
| 789 | |
| 790 | wp_register_script( |
| 791 | 'pa-tweenmax', |
| 792 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/TweenMax' . $suffix . '.js', |
| 793 | array( 'jquery' ), |
| 794 | PREMIUM_ADDONS_VERSION, |
| 795 | true |
| 796 | ); |
| 797 | |
| 798 | wp_register_script( |
| 799 | 'pa-headroom', |
| 800 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/headroom' . $suffix . '.js', |
| 801 | array( 'jquery' ), |
| 802 | PREMIUM_ADDONS_VERSION |
| 803 | ); |
| 804 | |
| 805 | wp_register_script( |
| 806 | 'pa-menu', |
| 807 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-nav-menu' . $suffix . '.js', |
| 808 | array( 'jquery' ), |
| 809 | PREMIUM_ADDONS_VERSION, |
| 810 | true |
| 811 | ); |
| 812 | |
| 813 | if ( $maps_settings['premium-map-cluster'] ) { |
| 814 | wp_register_script( |
| 815 | 'pa-maps-cluster', |
| 816 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/markerclusterer.min.js', |
| 817 | array(), |
| 818 | '1.0.1', |
| 819 | true |
| 820 | ); |
| 821 | } |
| 822 | |
| 823 | if ( $maps_settings['premium-map-disable-api'] && '1' !== $maps_settings['premium-map-api'] ) { |
| 824 | $api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&libraries=marker&callback=initMap&language=%2$s&loading=async', $maps_settings['premium-map-api'], $locale ); |
| 825 | wp_register_script( |
| 826 | 'pa-maps-api', |
| 827 | $api, |
| 828 | array(), |
| 829 | PREMIUM_ADDONS_VERSION, |
| 830 | true |
| 831 | ); |
| 832 | } |
| 833 | |
| 834 | wp_register_script( |
| 835 | 'pa-slick', |
| 836 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $suffix . '.js', |
| 837 | array( 'jquery' ), |
| 838 | PREMIUM_ADDONS_VERSION, |
| 839 | true |
| 840 | ); |
| 841 | |
| 842 | wp_register_script( |
| 843 | 'pa-flipster', |
| 844 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/flipster' . $suffix . '.js', |
| 845 | array( 'jquery' ), |
| 846 | PREMIUM_ADDONS_VERSION |
| 847 | ); |
| 848 | |
| 849 | wp_register_script( |
| 850 | 'pa-anime', |
| 851 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/anime' . $suffix . '.js', |
| 852 | array( 'jquery' ), |
| 853 | PREMIUM_ADDONS_VERSION, |
| 854 | true |
| 855 | ); |
| 856 | |
| 857 | wp_register_script( |
| 858 | 'pa-feffects', |
| 859 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-floating-effects' . $suffix . '.js', |
| 860 | array( 'jquery' ), |
| 861 | PREMIUM_ADDONS_VERSION, |
| 862 | true |
| 863 | ); |
| 864 | |
| 865 | wp_register_script( |
| 866 | 'pa-gTooltips', |
| 867 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-global-tooltips' . $suffix . '.js', |
| 868 | array( 'jquery' ), |
| 869 | PREMIUM_ADDONS_VERSION, |
| 870 | true |
| 871 | ); |
| 872 | |
| 873 | wp_register_script( |
| 874 | 'pa-shape-divider', |
| 875 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-shape-divider' . $suffix . '.js', |
| 876 | array( 'jquery' ), |
| 877 | PREMIUM_ADDONS_VERSION, |
| 878 | true |
| 879 | ); |
| 880 | |
| 881 | wp_localize_script( |
| 882 | 'pa-shape-divider', |
| 883 | 'PaShapeDividerSettings', |
| 884 | array( |
| 885 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 886 | 'nonce' => wp_create_nonce( 'pa-shape-nonce' ), |
| 887 | ) |
| 888 | ); |
| 889 | |
| 890 | wp_localize_script( |
| 891 | 'pa-gTooltips', |
| 892 | 'PremiumSettings', |
| 893 | array( |
| 894 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 895 | 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ), |
| 896 | ) |
| 897 | ); |
| 898 | |
| 899 | wp_localize_script( |
| 900 | 'premium-addons', |
| 901 | 'PremiumSettings', |
| 902 | array( |
| 903 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 904 | 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ), |
| 905 | ) |
| 906 | ); |
| 907 | |
| 908 | wp_register_script( |
| 909 | 'pa-eq-height', |
| 910 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-eq-height' . $suffix . '.js', |
| 911 | array( 'jquery' ), |
| 912 | PREMIUM_ADDONS_VERSION, |
| 913 | true |
| 914 | ); |
| 915 | |
| 916 | wp_register_script( |
| 917 | 'pa-dis-conditions', |
| 918 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-dis-conditions' . $suffix . '.js', |
| 919 | array( 'jquery' ), |
| 920 | PREMIUM_ADDONS_VERSION, |
| 921 | true |
| 922 | ); |
| 923 | |
| 924 | wp_register_script( |
| 925 | 'pa-gsap', |
| 926 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/pa-gsap' . $suffix . '.js', |
| 927 | array( 'jquery' ), |
| 928 | PREMIUM_ADDONS_VERSION, |
| 929 | true |
| 930 | ); |
| 931 | |
| 932 | wp_register_script( |
| 933 | 'pa-motionpath', |
| 934 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/motionpath' . $suffix . '.js', |
| 935 | array( |
| 936 | 'jquery', |
| 937 | ), |
| 938 | PREMIUM_ADDONS_VERSION, |
| 939 | true |
| 940 | ); |
| 941 | |
| 942 | wp_register_script( |
| 943 | 'pa-scrolltrigger', |
| 944 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/scrollTrigger' . $suffix . '.js', |
| 945 | array( 'jquery' ), |
| 946 | PREMIUM_ADDONS_VERSION, |
| 947 | true |
| 948 | ); |
| 949 | |
| 950 | wp_register_script( |
| 951 | 'pa-notifications', |
| 952 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-notifications' . $suffix . '.js', |
| 953 | array( 'jquery' ), |
| 954 | PREMIUM_ADDONS_VERSION, |
| 955 | true |
| 956 | ); |
| 957 | |
| 958 | wp_register_script( |
| 959 | 'pa-luxon', |
| 960 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/luxon' . $suffix . '.js', |
| 961 | array( 'jquery' ), |
| 962 | PREMIUM_ADDONS_VERSION, |
| 963 | true |
| 964 | ); |
| 965 | |
| 966 | wp_register_script( |
| 967 | 'mousewheel-js', |
| 968 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-mousewheel' . $suffix . '.js', |
| 969 | array( 'jquery' ), |
| 970 | PREMIUM_ADDONS_VERSION, |
| 971 | true |
| 972 | ); |
| 973 | |
| 974 | wp_register_script( |
| 975 | 'pa-wrapper-link', |
| 976 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-wrapper-link' . $suffix . '.js', |
| 977 | array( 'jquery' ), |
| 978 | PREMIUM_ADDONS_VERSION, |
| 979 | true |
| 980 | ); |
| 981 | |
| 982 | // We need to make sure premium-woocommerce.js will not be loaded twice if assets are generated. |
| 983 | if ( class_exists( 'woocommerce' ) ) { |
| 984 | |
| 985 | wp_register_script( |
| 986 | 'premium-woo-cats', |
| 987 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-woo-categories' . $suffix . '.js', |
| 988 | array( 'jquery' ), |
| 989 | PREMIUM_ADDONS_VERSION, |
| 990 | true |
| 991 | ); |
| 992 | |
| 993 | wp_register_script( |
| 994 | 'premium-mini-cart', |
| 995 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-mini-cart' . $suffix . '.js', |
| 996 | array( 'jquery' ), |
| 997 | PREMIUM_ADDONS_VERSION, |
| 998 | true |
| 999 | ); |
| 1000 | |
| 1001 | wp_register_script( |
| 1002 | 'premium-woo-cart', |
| 1003 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-woo-cart' . $suffix . '.js', |
| 1004 | array( 'jquery' ), |
| 1005 | PREMIUM_ADDONS_VERSION, |
| 1006 | true |
| 1007 | ); |
| 1008 | |
| 1009 | wp_register_script( |
| 1010 | 'premium-woo-cta', |
| 1011 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-woo-cta' . $suffix . '.js', |
| 1012 | array( 'jquery' ), |
| 1013 | PREMIUM_ADDONS_VERSION, |
| 1014 | true |
| 1015 | ); |
| 1016 | |
| 1017 | wp_register_script( |
| 1018 | 'premium-woocommerce', |
| 1019 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-woo-products' . $suffix . '.js', |
| 1020 | array( 'jquery' ), |
| 1021 | PREMIUM_ADDONS_VERSION, |
| 1022 | true |
| 1023 | ); |
| 1024 | |
| 1025 | wp_localize_script( |
| 1026 | 'premium-woo-cta', |
| 1027 | 'PAWooCTASettings', |
| 1028 | array( |
| 1029 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 1030 | 'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ), |
| 1031 | 'view_cart' => __( 'View cart', 'woocommerce' ), |
| 1032 | 'mini_cart_nonce' => wp_create_nonce( 'pa-mini-cart-nonce' ), |
| 1033 | 'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ), |
| 1034 | ) |
| 1035 | ); |
| 1036 | |
| 1037 | wp_localize_script( |
| 1038 | 'premium-mini-cart', |
| 1039 | 'PAWooMCartSettings', |
| 1040 | array( |
| 1041 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 1042 | 'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ), |
| 1043 | 'view_cart' => __( 'View cart', 'woocommerce' ), |
| 1044 | 'mini_cart_nonce' => wp_create_nonce( 'pa-mini-cart-nonce' ), |
| 1045 | 'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ), |
| 1046 | 'stock_msg' => __( '*The current stock is only ', 'premium-addons-for-elementor' ), |
| 1047 | ) |
| 1048 | ); |
| 1049 | |
| 1050 | wp_localize_script( |
| 1051 | 'premium-woocommerce', |
| 1052 | 'PAWooProductsSettings', |
| 1053 | array( |
| 1054 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 1055 | 'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ), |
| 1056 | 'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ), |
| 1057 | 'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ), |
| 1058 | 'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ), |
| 1059 | 'view_cart' => __( 'View cart', 'woocommerce' ), |
| 1060 | 'mini_cart_nonce' => wp_create_nonce( 'pa-mini-cart-nonce' ), |
| 1061 | ) |
| 1062 | ); |
| 1063 | |
| 1064 | } |
| 1065 | |
| 1066 | // Localize jQuery with required data for Global Add-ons. |
| 1067 | if ( self::$modules['premium-floating-effects'] ) { |
| 1068 | wp_localize_script( |
| 1069 | 'pa-feffects', |
| 1070 | 'PremiumFESettings', |
| 1071 | array( |
| 1072 | 'papro_installed' => Helper_Functions::check_papro_version(), |
| 1073 | ) |
| 1074 | ); |
| 1075 | } |
| 1076 | |
| 1077 | // Localize jQuery with required data for Global Add-ons. |
| 1078 | if ( self::$modules['premium-countdown'] ) { |
| 1079 | |
| 1080 | wp_localize_script( |
| 1081 | 'pa-countdown', |
| 1082 | 'premiumCountDownStrings', |
| 1083 | array( |
| 1084 | 'single' => array( |
| 1085 | __( 'Year', 'premium-addons-for-elementor' ), |
| 1086 | __( 'Month', 'premium-addons-for-elementor' ), |
| 1087 | __( 'Week', 'premium-addons-for-elementor' ), |
| 1088 | __( 'Day', 'premium-addons-for-elementor' ), |
| 1089 | __( 'Hour', 'premium-addons-for-elementor' ), |
| 1090 | __( 'Minute', 'premium-addons-for-elementor' ), |
| 1091 | __( 'Second', 'premium-addons-for-elementor' ), |
| 1092 | ), |
| 1093 | 'plural' => array( |
| 1094 | __( 'Years', 'premium-addons-for-elementor' ), |
| 1095 | __( 'Months', 'premium-addons-for-elementor' ), |
| 1096 | __( 'Weeks', 'premium-addons-for-elementor' ), |
| 1097 | __( 'Days', 'premium-addons-for-elementor' ), |
| 1098 | __( 'Hours', 'premium-addons-for-elementor' ), |
| 1099 | __( 'Minutes', 'premium-addons-for-elementor' ), |
| 1100 | __( 'Seconds', 'premium-addons-for-elementor' ), |
| 1101 | ), |
| 1102 | ) |
| 1103 | ); |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | /** |
| 1108 | * Register Old Scripts |
| 1109 | * |
| 1110 | * @since 4.9.0 |
| 1111 | * @access public |
| 1112 | * |
| 1113 | * @param string $directory script directory. |
| 1114 | * @param string $suffix file suffix. |
| 1115 | */ |
| 1116 | public function register_old_scripts( $directory, $suffix ) { |
| 1117 | |
| 1118 | wp_register_script( |
| 1119 | 'premium-addons', |
| 1120 | PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $suffix . '.js', |
| 1121 | array( 'jquery' ), |
| 1122 | PREMIUM_ADDONS_VERSION, |
| 1123 | true |
| 1124 | ); |
| 1125 | } |
| 1126 | |
| 1127 | /** |
| 1128 | * Enqueue Preview CSS files |
| 1129 | * |
| 1130 | * @since 2.9.0 |
| 1131 | * @access public |
| 1132 | */ |
| 1133 | public function enqueue_preview_styles() { |
| 1134 | |
| 1135 | wp_enqueue_style( |
| 1136 | 'pa-preview', |
| 1137 | PREMIUM_ADDONS_URL . 'assets/editor/templates/css/preview.css', |
| 1138 | array(), |
| 1139 | PREMIUM_ADDONS_VERSION, |
| 1140 | 'all' |
| 1141 | ); |
| 1142 | |
| 1143 | wp_enqueue_style( 'pa-prettyphoto' ); |
| 1144 | |
| 1145 | wp_enqueue_style( 'premium-addons' ); |
| 1146 | |
| 1147 | wp_enqueue_style( 'pa-slick' ); |
| 1148 | } |
| 1149 | |
| 1150 | /** |
| 1151 | * Load widgets require function |
| 1152 | * |
| 1153 | * @since 1.0.0 |
| 1154 | * @access public |
| 1155 | */ |
| 1156 | public function widgets_area( $widgets_manager ) { |
| 1157 | |
| 1158 | $enabled_elements = self::$modules; |
| 1159 | |
| 1160 | $widgets_dir = glob( PREMIUM_ADDONS_PATH . 'widgets/*.php' ); |
| 1161 | |
| 1162 | foreach ( $widgets_dir as $file ) { |
| 1163 | |
| 1164 | $slug = basename( $file, '.php' ); |
| 1165 | |
| 1166 | // Fixes the conflict between Lottie widget/addon keys. |
| 1167 | if ( 'premium-lottie' === $slug ) { |
| 1168 | |
| 1169 | // Check if Lottie widget switcher value was saved before. |
| 1170 | // $saved_options = get_option( 'pa_save_settings' ); |
| 1171 | |
| 1172 | $slug = 'premium-lottie-widget'; |
| 1173 | |
| 1174 | } |
| 1175 | |
| 1176 | $enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : ''; |
| 1177 | |
| 1178 | if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) { |
| 1179 | |
| 1180 | $base = basename( str_replace( '.php', '', $file ) ); |
| 1181 | $class = ucwords( str_replace( '-', ' ', $base ) ); |
| 1182 | $class = str_replace( ' ', '_', $class ); |
| 1183 | $class = sprintf( 'PremiumAddons\Widgets\%s', $class ); |
| 1184 | |
| 1185 | $this->load_widget_files( $file, $class ); |
| 1186 | |
| 1187 | if ( class_exists( $class, false ) ) { |
| 1188 | |
| 1189 | $widgets_manager->register( new $class() ); |
| 1190 | |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | /** |
| 1197 | * Register Widgets Category |
| 1198 | * |
| 1199 | * Register a new category for Premium Addons widgets |
| 1200 | * |
| 1201 | * @since 4.0.0 |
| 1202 | * @access public |
| 1203 | * |
| 1204 | * @param object $elements_manager elements manager. |
| 1205 | */ |
| 1206 | public function register_widgets_category( $elements_manager ) { |
| 1207 | |
| 1208 | $elements_manager->add_category( |
| 1209 | 'premium-elements', |
| 1210 | array( |
| 1211 | 'title' => Helper_Functions::get_category(), |
| 1212 | ), |
| 1213 | 1 |
| 1214 | ); |
| 1215 | } |
| 1216 | |
| 1217 | public function load_widget_files( $file, $class ) { |
| 1218 | |
| 1219 | if ( 'PremiumAddons\Widgets\Premium_Contactform' !== $class ) { |
| 1220 | require $file; |
| 1221 | } elseif ( function_exists( 'wpcf7' ) ) { |
| 1222 | require $file; |
| 1223 | } |
| 1224 | |
| 1225 | if ( 'PremiumAddons\Widgets\Premium_Videobox' === $class || 'PremiumAddons\Widgets\Premium_Weather' === $class ) { |
| 1226 | require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php'; |
| 1227 | } |
| 1228 | |
| 1229 | if ( 'PremiumAddons\Widgets\Premium_Weather' === $class ) { |
| 1230 | require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-weather-handler.php'; |
| 1231 | } |
| 1232 | |
| 1233 | if ( in_array( $class, array( 'PremiumAddons\Widgets\Premium_Pinterest_Feed', 'PremiumAddons\Widgets\Premium_Tiktok_Feed' ), true ) ) { |
| 1234 | require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/mobile-detector.php'; |
| 1235 | |
| 1236 | if ( 'PremiumAddons\Widgets\Premium_Pinterest_Feed' == $class ) { |
| 1237 | require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-pins-handler.php'; |
| 1238 | } |
| 1239 | |
| 1240 | if ( 'PremiumAddons\Widgets\Premium_Tiktok_Feed' == $class ) { |
| 1241 | require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-tiktok-handler.php'; |
| 1242 | } |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | /** |
| 1247 | * Enqueue editor scripts |
| 1248 | * |
| 1249 | * @since 3.2.5 |
| 1250 | * @access public |
| 1251 | */ |
| 1252 | public function before_enqueue_scripts() { |
| 1253 | |
| 1254 | wp_enqueue_script( |
| 1255 | 'pa-editor-behavior', |
| 1256 | PREMIUM_ADDONS_URL . 'assets/editor/js/pa-editor-behavior.min.js', |
| 1257 | array( 'elementor-editor', 'jquery' ), |
| 1258 | PREMIUM_ADDONS_VERSION, |
| 1259 | true |
| 1260 | ); |
| 1261 | |
| 1262 | $map_enabled = isset( self::$modules['premium-maps'] ) ? self::$modules['premium-maps'] : 1; |
| 1263 | |
| 1264 | if ( $map_enabled ) { |
| 1265 | |
| 1266 | $premium_maps_api = self::$integrations['premium-map-api']; |
| 1267 | |
| 1268 | $locale = isset( self::$integrations['premium-map-locale'] ) ? self::$integrations['premium-map-locale'] : 'en'; |
| 1269 | |
| 1270 | $disable_api = self::$integrations['premium-map-disable-api']; |
| 1271 | |
| 1272 | if ( $disable_api && '1' !== $premium_maps_api ) { |
| 1273 | |
| 1274 | $api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&libraries=marker&language=%2$s&loading=async', $premium_maps_api, $locale ); |
| 1275 | wp_enqueue_script( |
| 1276 | 'pa-maps-api', |
| 1277 | $api, |
| 1278 | array(), |
| 1279 | PREMIUM_ADDONS_VERSION, |
| 1280 | false |
| 1281 | ); |
| 1282 | |
| 1283 | } |
| 1284 | |
| 1285 | wp_enqueue_script( |
| 1286 | 'pa-maps-finder', |
| 1287 | PREMIUM_ADDONS_URL . 'assets/editor/js/pa-maps-finder.js', |
| 1288 | array( 'jquery' ), |
| 1289 | PREMIUM_ADDONS_VERSION, |
| 1290 | true |
| 1291 | ); |
| 1292 | |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | /** |
| 1297 | * Get Pinterest account token for Pinterest Feed widget |
| 1298 | * |
| 1299 | * @since 4.10.2 |
| 1300 | * @access public |
| 1301 | * |
| 1302 | * @return void |
| 1303 | */ |
| 1304 | public function get_pinterest_token() { |
| 1305 | |
| 1306 | check_ajax_referer( 'pa-editor', 'security' ); |
| 1307 | |
| 1308 | $api_url = 'https://appfb.premiumaddons.com/wp-json/fbapp/v2/pinterest'; |
| 1309 | |
| 1310 | $response = wp_remote_get( |
| 1311 | $api_url, |
| 1312 | array( |
| 1313 | 'timeout' => 15, |
| 1314 | 'sslverify' => false, |
| 1315 | ) |
| 1316 | ); |
| 1317 | |
| 1318 | $body = wp_remote_retrieve_body( $response ); |
| 1319 | $body = json_decode( $body, true ); |
| 1320 | |
| 1321 | // $transient_name = 'pa_pinterest_token_' . $body; |
| 1322 | |
| 1323 | // $expire_time = 29 * DAY_IN_SECONDS; |
| 1324 | |
| 1325 | // set_transient( $transient_name, true, $expire_time ); |
| 1326 | |
| 1327 | wp_send_json_success( $body ); |
| 1328 | } |
| 1329 | |
| 1330 | /** |
| 1331 | * Get Pinterest account token for Pinterest Feed widget |
| 1332 | * |
| 1333 | * @since 4.10.2 |
| 1334 | * @access public |
| 1335 | * |
| 1336 | * @return void |
| 1337 | */ |
| 1338 | public function get_pinterest_boards() { |
| 1339 | |
| 1340 | check_ajax_referer( 'pa-blog-widget-nonce', 'nonce' ); |
| 1341 | |
| 1342 | if ( ! isset( $_GET['token'] ) ) { |
| 1343 | wp_send_json_error(); |
| 1344 | } |
| 1345 | |
| 1346 | $token = sanitize_text_field( wp_unslash( $_GET['token'] ) ); |
| 1347 | |
| 1348 | $transient_name = 'pa_pinterest_boards_' . substr( $token, 0, 15 ); |
| 1349 | |
| 1350 | $body = get_transient( $transient_name ); |
| 1351 | |
| 1352 | if ( false === $body ) { |
| 1353 | |
| 1354 | $api_url = 'https://api.pinterest.com/v5/boards?page_size=60'; |
| 1355 | |
| 1356 | $response = wp_remote_get( |
| 1357 | $api_url, |
| 1358 | array( |
| 1359 | 'headers' => array( |
| 1360 | 'Authorization' => 'Bearer ' . $token, |
| 1361 | ), |
| 1362 | ) |
| 1363 | ); |
| 1364 | |
| 1365 | $body = wp_remote_retrieve_body( $response ); |
| 1366 | $body = json_decode( $body, true ); |
| 1367 | |
| 1368 | set_transient( $transient_name, $body, 30 * MINUTE_IN_SECONDS ); |
| 1369 | |
| 1370 | } |
| 1371 | |
| 1372 | $boards = array(); |
| 1373 | |
| 1374 | foreach ( $body['items'] as $index => $board ) { |
| 1375 | $boards[ $board['id'] ] = $board['name']; |
| 1376 | } |
| 1377 | |
| 1378 | wp_send_json_success( wp_json_encode( $boards ) ); |
| 1379 | } |
| 1380 | |
| 1381 | /** |
| 1382 | * Get Pinterest account token for Pinterest Feed widget |
| 1383 | * |
| 1384 | * @since 4.10.2 |
| 1385 | * @access public |
| 1386 | * |
| 1387 | * @return void |
| 1388 | */ |
| 1389 | public function get_tiktok_token() { |
| 1390 | |
| 1391 | check_ajax_referer( 'pa-editor', 'security' ); |
| 1392 | |
| 1393 | $api_url = 'https://appfb.premiumaddons.com/wp-json/fbapp/v2/tiktok'; |
| 1394 | |
| 1395 | $response = wp_remote_get( |
| 1396 | $api_url, |
| 1397 | array( |
| 1398 | 'timeout' => 15, |
| 1399 | 'sslverify' => false, |
| 1400 | ) |
| 1401 | ); |
| 1402 | |
| 1403 | $body = wp_remote_retrieve_body( $response ); |
| 1404 | $body = json_decode( $body, true ); |
| 1405 | |
| 1406 | // $transient_name = 'pa_tiktok_token_' . $body; |
| 1407 | |
| 1408 | // $expire_time = 29 * DAY_IN_SECONDS; |
| 1409 | |
| 1410 | // set_transient( $transient_name, true, $expire_time ); |
| 1411 | |
| 1412 | wp_send_json_success( $body ); |
| 1413 | } |
| 1414 | |
| 1415 | /** |
| 1416 | * Insert Contact Form 7 Form |
| 1417 | * |
| 1418 | * @since 4.10.2 |
| 1419 | * @access public |
| 1420 | * |
| 1421 | * @return void |
| 1422 | */ |
| 1423 | public function insert_cf_form() { |
| 1424 | |
| 1425 | check_ajax_referer( 'pa-editor', 'security' ); |
| 1426 | |
| 1427 | if ( ! isset( $_GET['preset'] ) ) { |
| 1428 | wp_send_json_error(); |
| 1429 | } |
| 1430 | |
| 1431 | $preset = sanitize_text_field( wp_unslash( $_GET['preset'] ) ); |
| 1432 | |
| 1433 | $current_user = wp_get_current_user(); |
| 1434 | |
| 1435 | $props = array( |
| 1436 | 'form' => Helper_Functions::get_cf_form_body( $preset ), |
| 1437 | 'mail' => array( |
| 1438 | 'active' => 1, |
| 1439 | 'subject' => '[_site_title] "[your-subject]"', |
| 1440 | 'sender' => '[_site_title]', |
| 1441 | 'recipient' => '[_site_admin_email]', |
| 1442 | 'body' => 'From: [your-name] [your-email]' . PHP_EOL . |
| 1443 | 'Subject: [your-subject]' . PHP_EOL . PHP_EOL . |
| 1444 | 'Message Body:' . PHP_EOL . '[your-message]' . PHP_EOL . PHP_EOL . |
| 1445 | '--' . PHP_EOL . |
| 1446 | 'This e-mail was sent from a contact form on [_site_title] ([_site_url])', |
| 1447 | 'additional_headers' => 'Reply-To: [your-email]', |
| 1448 | 'attachments' => '', |
| 1449 | 'use_html' => '', |
| 1450 | 'exclude_blank' => '', |
| 1451 | ), |
| 1452 | 'mail_2' => array( |
| 1453 | 'active' => '', |
| 1454 | 'subject' => '[_site_title] "[your-subject]"', |
| 1455 | 'sender' => '[_site_title]', |
| 1456 | 'recipient' => '[your-email]', |
| 1457 | 'body' => 'Message Body:' . PHP_EOL . '[your-message]' . PHP_EOL . PHP_EOL . |
| 1458 | '--' . PHP_EOL . |
| 1459 | 'This e-mail was sent from a contact form on [_site_title] ([_site_url])', |
| 1460 | 'additional_headers' => 'Reply-To: [_site_admin_email]', |
| 1461 | 'attachments' => '', |
| 1462 | 'use_html' => '', |
| 1463 | 'exclude_blank' => '', |
| 1464 | ), |
| 1465 | 'messages' => array( |
| 1466 | 'mail_sent_ok' => 'Thank you for your message. It has been sent.', |
| 1467 | 'mail_sent_ng' => 'There was an error trying to send your message. Please try again later.', |
| 1468 | 'validation_error' => 'One or more fields have an error. Please check and try again.', |
| 1469 | 'spam' => 'There was an error trying to send your message. Please try again later.', |
| 1470 | 'accept_terms' => 'You must accept the terms and conditions before sending your message.', |
| 1471 | 'invalid_required' => 'Please fill out this field.', |
| 1472 | 'invalid_too_long' => 'This field has a too long input.', |
| 1473 | 'invalid_too_short' => 'This field has a too short input.', |
| 1474 | 'upload_failed' => 'There was an unknown error uploading the file.', |
| 1475 | 'upload_file_type_invalid' => 'You are not allowed to upload files of this type.', |
| 1476 | 'upload_file_too_large' => 'The uploaded file is too large.', |
| 1477 | 'upload_failed_php_error' => 'There was an error uploading the file.', |
| 1478 | 'invalid_date' => 'Please enter a date in YYYY-MM-DD format.', |
| 1479 | 'date_too_early' => 'This field has a too early date.', |
| 1480 | 'date_too_late' => 'This field has a too late date.', |
| 1481 | 'invalid_number' => 'Please enter a number.', |
| 1482 | 'number_too_small' => 'This field has a too small number.', |
| 1483 | 'number_too_large' => 'This field has a too large number.', |
| 1484 | 'quiz_answer_not_correct' => 'The answer to the quiz is incorrect.', |
| 1485 | 'invalid_email' => 'Please enter an email address.', |
| 1486 | 'invalid_url' => 'Please enter a URL.', |
| 1487 | 'invalid_tel' => 'Please enter a telephone number.', |
| 1488 | ), |
| 1489 | 'additional_settings' => '', |
| 1490 | ); |
| 1491 | |
| 1492 | $post_content = implode( "\n", wpcf7_array_flatten( $props ) ); |
| 1493 | |
| 1494 | $args = array( |
| 1495 | 'post_status' => 'publish', |
| 1496 | 'post_type' => 'wpcf7_contact_form', |
| 1497 | 'post_content' => $post_content, |
| 1498 | 'post_author' => $current_user->ID, |
| 1499 | 'post_title' => sprintf( |
| 1500 | __( 'Form | %s', 'premium-addons-for-elementor' ), |
| 1501 | gmdate( 'Y-m-d H:i' ) |
| 1502 | ), |
| 1503 | ); |
| 1504 | |
| 1505 | $post_id = wp_insert_post( $args ); |
| 1506 | |
| 1507 | foreach ( $props as $prop => $value ) { |
| 1508 | update_post_meta( |
| 1509 | $post_id, |
| 1510 | '_' . $prop, |
| 1511 | wpcf7_normalize_newline_deep( $value ) |
| 1512 | ); |
| 1513 | } |
| 1514 | |
| 1515 | $form_id = wpcf7_generate_contact_form_hash( $post_id ); |
| 1516 | |
| 1517 | add_post_meta( $post_id, '_hash', $form_id, true ); |
| 1518 | |
| 1519 | wp_send_json_success( substr( $form_id, 0, 7 ) ); |
| 1520 | } |
| 1521 | |
| 1522 | /** |
| 1523 | * Load Cross Domain Copy Paste JS Files. |
| 1524 | * |
| 1525 | * @since 3.21.1 |
| 1526 | */ |
| 1527 | public function enqueue_editor_cp_scripts() { |
| 1528 | |
| 1529 | wp_enqueue_script( |
| 1530 | 'premium-xdlocalstorage', |
| 1531 | PREMIUM_ADDONS_URL . 'assets/editor/js/xdlocalstorage.js', |
| 1532 | null, |
| 1533 | PREMIUM_ADDONS_VERSION, |
| 1534 | true |
| 1535 | ); |
| 1536 | |
| 1537 | wp_enqueue_script( |
| 1538 | 'premium-cross-cp', |
| 1539 | PREMIUM_ADDONS_URL . 'assets/editor/js/premium-cross-cp.js', |
| 1540 | array( 'jquery', 'elementor-editor', 'premium-xdlocalstorage' ), |
| 1541 | PREMIUM_ADDONS_VERSION, |
| 1542 | true |
| 1543 | ); |
| 1544 | |
| 1545 | // Check for required Compatible Elementor version. |
| 1546 | if ( ! version_compare( ELEMENTOR_VERSION, '3.1.0', '>=' ) ) { |
| 1547 | $elementor_old = true; |
| 1548 | } else { |
| 1549 | $elementor_old = false; |
| 1550 | } |
| 1551 | |
| 1552 | wp_localize_script( |
| 1553 | 'jquery', |
| 1554 | 'premium_cross_cp', |
| 1555 | array( |
| 1556 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 1557 | 'nonce' => wp_create_nonce( 'premium_cross_cp_import' ), |
| 1558 | 'elementorCompatible' => $elementor_old, |
| 1559 | ) |
| 1560 | ); |
| 1561 | } |
| 1562 | |
| 1563 | /** |
| 1564 | * Get Template Content |
| 1565 | * |
| 1566 | * Get Elementor template HTML content. |
| 1567 | * |
| 1568 | * @since 3.2.6 |
| 1569 | * @access public |
| 1570 | */ |
| 1571 | public function get_template_content() { |
| 1572 | |
| 1573 | $template = isset( $_GET['templateID'] ) ? sanitize_text_field( wp_unslash( $_GET['templateID'] ) ) : ''; |
| 1574 | |
| 1575 | if ( empty( $template ) ) { |
| 1576 | wp_send_json_error( 'Empty Template ID' ); |
| 1577 | } |
| 1578 | |
| 1579 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 1580 | wp_send_json_error( 'Insufficient user permission' ); |
| 1581 | } |
| 1582 | |
| 1583 | $template_content = Helper_Functions::render_elementor_template( $template ); |
| 1584 | |
| 1585 | if ( empty( $template_content ) || ! isset( $template_content ) ) { |
| 1586 | wp_send_json_error( 'Empty Content' ); |
| 1587 | } |
| 1588 | |
| 1589 | $data = array( |
| 1590 | 'template_content' => $template_content, |
| 1591 | ); |
| 1592 | |
| 1593 | wp_send_json_success( $data ); |
| 1594 | } |
| 1595 | |
| 1596 | /** |
| 1597 | * Registers Premium Addons Custom Controls. |
| 1598 | * |
| 1599 | * @since 4.2.5 |
| 1600 | * @access public |
| 1601 | * |
| 1602 | * @return void |
| 1603 | */ |
| 1604 | public function init_pa_controls() { |
| 1605 | |
| 1606 | $control_manager = \Elementor\Plugin::instance(); |
| 1607 | |
| 1608 | if ( self::$modules['premium-equal-height'] || self::$modules['premium-pinterest-feed'] ) { |
| 1609 | |
| 1610 | require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php'; |
| 1611 | $premium_select = __NAMESPACE__ . '\Controls\Premium_Select'; |
| 1612 | $control_manager->controls_manager->register( new $premium_select() ); |
| 1613 | |
| 1614 | } |
| 1615 | |
| 1616 | require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php'; |
| 1617 | |
| 1618 | $premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter'; |
| 1619 | |
| 1620 | $control_manager->controls_manager->register( new $premium_post_filter() ); |
| 1621 | |
| 1622 | if ( self::$modules['premium-blog'] || self::$modules['premium-smart-post-listing'] || self::$modules['premium-tcloud'] ) { |
| 1623 | |
| 1624 | require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php'; |
| 1625 | |
| 1626 | $premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter'; |
| 1627 | |
| 1628 | $control_manager->controls_manager->register( new $premium_tax_filter() ); |
| 1629 | } |
| 1630 | |
| 1631 | if ( self::$modules['pa-display-conditions'] ) { |
| 1632 | |
| 1633 | require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php'; |
| 1634 | $premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector'; |
| 1635 | $control_manager->controls_manager->register( new $premium_acf_selector() ); |
| 1636 | |
| 1637 | } |
| 1638 | |
| 1639 | if ( self::$modules['premium-shape-divider'] ) { |
| 1640 | |
| 1641 | require_once PREMIUM_ADDONS_PATH . 'includes/controls/pa-image-choose.php'; |
| 1642 | $premium_image_choose = __NAMESPACE__ . '\Controls\Premium_Image_Choose'; |
| 1643 | $control_manager->controls_manager->register( new $premium_image_choose() ); |
| 1644 | |
| 1645 | } |
| 1646 | |
| 1647 | $premium_background = __NAMESPACE__ . '\Controls\Premium_Background'; |
| 1648 | |
| 1649 | $control_manager->controls_manager->add_group_control( 'pa-background', new $premium_background() ); |
| 1650 | } |
| 1651 | |
| 1652 | /** |
| 1653 | * Load PA Extensions |
| 1654 | * |
| 1655 | * @since 4.7.0 |
| 1656 | * @access public |
| 1657 | */ |
| 1658 | public function load_pa_extensions() { |
| 1659 | |
| 1660 | if ( self::$modules['premium-equal-height'] ) { |
| 1661 | Equal_Height::get_instance(); |
| 1662 | } |
| 1663 | |
| 1664 | if ( self::$modules['premium-glassmorphism'] ) { |
| 1665 | Glassmorphism::get_instance(); |
| 1666 | } |
| 1667 | |
| 1668 | if ( self::$modules['pa-display-conditions'] ) { |
| 1669 | require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php'; |
| 1670 | Display_Conditions::get_instance(); |
| 1671 | } |
| 1672 | |
| 1673 | if ( self::$modules['premium-floating-effects'] ) { |
| 1674 | Floating_Effects::get_instance(); |
| 1675 | } |
| 1676 | |
| 1677 | if ( class_exists( 'woocommerce' ) && ( self::$modules['woo-products'] || self::$modules['woo-categories'] || self::$modules['mini-cart'] || self::$modules['woo-cta'] ) ) { |
| 1678 | Woocommerce::get_instance(); |
| 1679 | } |
| 1680 | |
| 1681 | if ( self::$modules['premium-global-tooltips'] ) { |
| 1682 | GlobalTooltips::get_instance(); |
| 1683 | } |
| 1684 | |
| 1685 | if ( self::$modules['premium-shape-divider'] ) { |
| 1686 | Shape_Divider::get_instance(); |
| 1687 | } |
| 1688 | |
| 1689 | if ( self::$modules['premium-wrapper-link'] ) { |
| 1690 | Wrapper_Link::get_instance(); |
| 1691 | } |
| 1692 | |
| 1693 | if ( ! Helper_Functions::check_papro_version() ) { |
| 1694 | PAPRO_Promotion::get_instance(); |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | |
| 1699 | /** |
| 1700 | * Load Copy Paste Module |
| 1701 | * |
| 1702 | * @since 4.10.57 |
| 1703 | * @access public |
| 1704 | */ |
| 1705 | public function load_cp_module() { |
| 1706 | |
| 1707 | Addons_Cross_CP::get_instance(); |
| 1708 | } |
| 1709 | |
| 1710 | /** |
| 1711 | * Exclude PA assets from WP Optimize |
| 1712 | * |
| 1713 | * @since 4.10.73 |
| 1714 | * @access public |
| 1715 | */ |
| 1716 | function exclude_pa_assets_from_wp_optimize( $excluded_handles ) { |
| 1717 | |
| 1718 | $excluded_handles[] = 'pa-frontend'; |
| 1719 | |
| 1720 | return $excluded_handles; |
| 1721 | } |
| 1722 | |
| 1723 | /** |
| 1724 | * Add PAPRO Elements |
| 1725 | * |
| 1726 | * @since 4.10.90 |
| 1727 | * @access public |
| 1728 | * |
| 1729 | * @param array $config Elementor Config |
| 1730 | */ |
| 1731 | public function add_papro_elements( $config ) { |
| 1732 | |
| 1733 | $is_papro_active = apply_filters( 'papro_activated', false ); |
| 1734 | |
| 1735 | if ( $is_papro_active ) { |
| 1736 | return $config; |
| 1737 | } |
| 1738 | |
| 1739 | $promotion_widgets = array(); |
| 1740 | |
| 1741 | if ( isset( $config['promotionWidgets'] ) ) { |
| 1742 | $promotion_widgets = $config['promotionWidgets']; |
| 1743 | } |
| 1744 | |
| 1745 | $pro_elements = Admin_Helper::get_pro_elements(); |
| 1746 | |
| 1747 | $pro_elements = array_merge( $promotion_widgets, $pro_elements ); |
| 1748 | |
| 1749 | $config['promotionWidgets'] = $pro_elements; |
| 1750 | |
| 1751 | // Fix promotion box not showing when Elementor Pro is active. |
| 1752 | if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) { |
| 1753 | $config['promotion']['elements']['action_button'] = array( |
| 1754 | 'text' => 'Connect & Activate', |
| 1755 | 'url' => 'https://go.elementor.com/' |
| 1756 | ); |
| 1757 | } |
| 1758 | |
| 1759 | return $config; |
| 1760 | } |
| 1761 | |
| 1762 | |
| 1763 | /** |
| 1764 | * |
| 1765 | * Creates and returns an instance of the class |
| 1766 | * |
| 1767 | * @since 1.0.0 |
| 1768 | * @access public |
| 1769 | * |
| 1770 | * @return object |
| 1771 | */ |
| 1772 | public static function get_instance() { |
| 1773 | |
| 1774 | if ( ! isset( self::$instance ) ) { |
| 1775 | |
| 1776 | self::$instance = new self(); |
| 1777 | |
| 1778 | } |
| 1779 | |
| 1780 | return self::$instance; |
| 1781 | } |
| 1782 | } |
| 1783 |