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