PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.10.30
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.10.30
4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / includes / addons-integration.php
premium-addons-for-elementor / includes Last commit date
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
1626 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 * Live Editor Enqueue.
131 *
132 * @access public
133 * @since 4.8.10
134 */
135 public function live_editor_enqueue() {
136
137 wp_enqueue_script(
138 'live-editor',
139 PREMIUM_ADDONS_URL . 'assets/editor/js/live-editor.js',
140 array( 'elementor-editor', 'jquery' ),
141 PREMIUM_ADDONS_VERSION,
142 true
143 );
144
145 $live_editor_data = array(
146 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
147 'nonce' => wp_create_nonce( 'pa-live-editor' ),
148 );
149
150 wp_localize_script( 'live-editor', 'liveEditor', $live_editor_data );
151 }
152
153 /**
154 * Update Template Title.
155 *
156 * @access public
157 * @since 4.8.10
158 */
159 public function update_template_title() {
160 check_ajax_referer( 'pa-live-editor', 'security' );
161
162 if ( ! isset( $_POST['title'] ) || ! isset( $_POST['id'] ) ) {
163 wp_send_json_error();
164 }
165
166 $res = wp_update_post(
167 array(
168 'ID' => sanitize_text_field( wp_unslash( $_POST['id'] ) ),
169 'post_title' => sanitize_text_field( wp_unslash( $_POST['title'] ) ),
170 )
171 );
172
173 wp_send_json_success( $res );
174 }
175
176 /**
177 * Check Temp Validity.
178 * Checks if the template is valid ( has content) or not,
179 * And DELETE the post if it's invalid.
180 *
181 * @access public
182 * @since 4.9.1
183 */
184 public function check_temp_validity() {
185
186 check_ajax_referer( 'pa-live-editor', 'security' );
187
188 if ( ! isset( $_POST['templateID'] ) ) {
189 wp_send_json_error( 'template ID is not set' );
190 }
191
192 $temp_id = sanitize_text_field( wp_unslash( $_POST['templateID'] ) );
193 $temp_type = sanitize_text_field( wp_unslash( $_POST['tempType'] ) );
194
195 if ( 'loop' === $temp_type ) {
196 /** @var LoopDocument $document */
197 $template_content = PluginPro::elementor()->documents->get( $temp_id );
198
199 } else {
200 $template_content = $this->template_instance->get_template_content( $temp_id, true );
201
202 }
203
204 if ( empty( $template_content ) || ! isset( $template_content ) ) {
205
206 $res = wp_delete_post( $temp_id, true );
207
208 if ( ! is_wp_error( $res ) ) {
209 $res = 'Template Deleted.';
210 }
211 } else {
212 $res = 'Template Has Content.';
213 }
214
215 wp_send_json_success( $res );
216 }
217
218 /**
219 * Handle Live Editor Modal.
220 *
221 * @access public
222 * @since 4.8.10
223 */
224 public function handle_live_editor() {
225
226 check_ajax_referer( 'pa-live-editor', 'security' );
227
228 if ( ! isset( $_POST['key'] ) ) {
229 wp_send_json_error();
230 }
231
232 $post_name = 'pa-dynamic-temp-' . sanitize_text_field( wp_unslash( $_POST['key'] ) );
233 $temp_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : false;
234 $meta_input = array(
235 '_elementor_edit_mode' => 'builder',
236 '_elementor_template_type' => 'page',
237 '_wp_page_template' => 'elementor_canvas',
238 );
239
240 if ( 'loop' === $temp_type ) {
241 $meta_input = array(
242 '_elementor_edit_mode' => 'builder',
243 '_elementor_template_type' => 'loop-item',
244 );
245 } elseif ( 'grid' === $temp_type ) {
246 $meta_input = array(
247 '_elementor_edit_mode' => 'builder',
248 '_elementor_template_type' => 'premium-grid',
249 );
250 }
251
252 $post_title = '';
253 $args = array(
254 'post_type' => 'elementor_library',
255 'name' => $post_name,
256 'post_status' => 'publish',
257 'update_post_term_cache' => false,
258 'update_post_meta_cache' => false,
259 'posts_per_page' => 1,
260 );
261
262 $post = get_posts( $args );
263
264 if ( empty( $post ) ) { // create a new one.
265
266 $key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
267 $post_title = 'PA Template | #' . substr( md5( $key ), 0, 4 );
268
269 $params = array(
270 'post_content' => '',
271 'post_type' => 'elementor_library',
272 'post_title' => $post_title,
273 'post_name' => $post_name,
274 'post_status' => 'publish',
275 'meta_input' => $meta_input,
276 );
277
278 $post_id = wp_insert_post( $params );
279
280 } else { // edit post.
281 $post_id = $post[0]->ID;
282 $post_title = $post[0]->post_title;
283 }
284
285 $edit_url = get_admin_url() . '/post.php?post=' . $post_id . '&action=elementor';
286
287 $result = array(
288 'url' => $edit_url,
289 'id' => $post_id,
290 'title' => $post_title,
291 );
292
293 wp_send_json_success( $result );
294 }
295
296 /**
297 * Load Live Editor Modal.
298 * Puts live editor popup html into the editor.
299 *
300 * @access public
301 * @since 4.8.10
302 */
303 public function load_live_editor_modal() {
304 ob_start();
305 include_once PREMIUM_ADDONS_PATH . 'includes/live-editor-modal.php';
306 $output = ob_get_contents();
307 ob_end_clean();
308 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
309 }
310
311
312 /**
313 * After Enquque Scripts
314 *
315 * Loads editor scripts for our controls.
316 *
317 * @access public
318 * @return void
319 */
320 public function after_enqueue_scripts() {
321
322 wp_enqueue_script(
323 'pa-eq-editor',
324 PREMIUM_ADDONS_URL . 'assets/editor/js/editor.js',
325 array( 'elementor-editor', 'jquery' ),
326 PREMIUM_ADDONS_VERSION,
327 true
328 );
329
330 $modules = array(
331 self::$modules['premium-blog'],
332 self::$modules['pa-display-conditions'],
333 self::$modules['premium-smart-post-listing'],
334 self::$modules['premium-post-ticker'],
335 self::$modules['premium-notifications'],
336 self::$modules['premium-tcloud'],
337 self::$modules['premium-pinterest-feed'],
338 );
339
340 $localize_settings = in_array( true, $modules, true );
341
342 if ( $localize_settings ) {
343 wp_localize_script(
344 'pa-eq-editor',
345 'PremiumSettings',
346 array(
347 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
348 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
349 )
350 );
351 }
352
353 wp_localize_script(
354 'pa-eq-editor',
355 'PremiumPanelSettings',
356 array(
357 'papro_installed' => Helper_Functions::check_papro_version(),
358 'papro_widgets' => Admin_Helper::get_pro_elements(),
359 )
360 );
361
362 $pinterest_enabled = isset( self::$modules['premium-pinterest-feed'] ) ? self::$modules['premium-pinterest-feed'] : 1;
363 $tiktok_enabled = isset( self::$modules['premium-tiktok-feed'] ) ? self::$modules['premium-tiktok-feed'] : 1;
364
365 $cf_enabled = isset( self::$modules['premium-contactform'] ) ? self::$modules['premium-contactform'] : 1;
366
367 if ( $cf_enabled || $pinterest_enabled || $tiktok_enabled ) {
368
369 $data = array(
370 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
371 'nonce' => wp_create_nonce( 'pa-editor' ),
372 );
373
374 wp_enqueue_script(
375 'pa-editor-handler',
376 PREMIUM_ADDONS_URL . 'assets/editor/js/editor-handler.js',
377 array( 'elementor-editor' ),
378 PREMIUM_ADDONS_VERSION,
379 true
380 );
381
382 wp_localize_script( 'pa-editor-handler', 'paEditorSettings', $data );
383
384 }
385 }
386
387 /**
388 * Loads plugin icons font
389 *
390 * @since 1.0.0
391 * @access public
392 * @return void
393 */
394 public function enqueue_editor_styles() {
395
396 $theme = Helper_Functions::get_elementor_ui_theme();
397
398 wp_enqueue_style(
399 'pa-editor',
400 PREMIUM_ADDONS_URL . 'assets/editor/css/style.css',
401 array(),
402 PREMIUM_ADDONS_VERSION
403 );
404
405 // Enqueue required style for Elementor dark UI Theme.
406 if ( 'dark' === $theme ) {
407
408 wp_add_inline_style(
409 'pa-editor',
410 '.elementor-panel .elementor-control-section_pa_docs .elementor-panel-heading-title.elementor-panel-heading-title,
411 .elementor-control-raw-html.editor-pa-doc a {
412 color: #e0e1e3 !important;
413 }
414 [class^="pa-"]::after,
415 [class*=" pa-"]::after {
416 color: #aaa;
417 opacity: 1 !important;
418 }
419 .premium-promotion-dialog .premium-promotion-btn {
420 background-color: #202124 !important
421 }'
422 );
423
424 }
425
426 $badge_text = Helper_Functions::get_badge();
427
428 $dynamic_css = sprintf( '#elementor-panel [class^="pa-"]::after, #elementor-panel [class*=" pa-"]::after { content: "%s"; }', $badge_text );
429
430 wp_add_inline_style( 'pa-editor', $dynamic_css );
431 }
432
433 /**
434 * Register Frontend CSS files
435 *
436 * @since 2.9.0
437 * @access public
438 */
439 public function register_frontend_styles() {
440
441 $dir = Helper_Functions::get_styles_dir();
442 $suffix = Helper_Functions::get_assets_suffix();
443
444 $is_rtl = is_rtl() ? '-rtl' : '';
445
446 wp_register_style(
447 'font-awesome-5-all',
448 ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css',
449 false,
450 PREMIUM_ADDONS_VERSION
451 );
452
453 wp_register_style(
454 'pa-flipster',
455 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/flipster' . $suffix . '.css',
456 false,
457 PREMIUM_ADDONS_VERSION
458 );
459
460 wp_register_style(
461 'pa-prettyphoto',
462 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyphoto' . $is_rtl . $suffix . '.css',
463 array(),
464 PREMIUM_ADDONS_VERSION,
465 'all'
466 );
467
468 wp_register_style(
469 'pa-slick',
470 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $is_rtl . $suffix . '.css',
471 array(),
472 PREMIUM_ADDONS_VERSION,
473 'all'
474 );
475
476 wp_register_style(
477 'pa-world-clock',
478 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-world-clock' . $suffix . '.css',
479 array(),
480 PREMIUM_ADDONS_VERSION,
481 'all'
482 );
483
484 wp_register_style(
485 'tooltipster',
486 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/tooltipster.min.css',
487 array(),
488 PREMIUM_ADDONS_VERSION,
489 'all'
490 );
491
492 wp_register_style(
493 'pa-gTooltips',
494 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-global-tooltips' . $suffix . '.css',
495 array(),
496 PREMIUM_ADDONS_VERSION,
497 'all'
498 );
499
500 wp_register_style(
501 'pa-shape-divider',
502 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-shape-divider' . $suffix . '.css',
503 array(),
504 PREMIUM_ADDONS_VERSION,
505 'all'
506 );
507
508 $assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
509
510 $type = get_post_type();
511
512 // If dynamic assets is disabled.
513 if ( ! $assets_gen_enabled || ( 'page' !== $type && 'post' !== $type ) ) {
514 $this->enqueue_old_styles( $dir, $is_rtl, $suffix );
515 } else {
516
517 $css_path = '/pa-frontend' . $is_rtl . '-' . Assets_Manager::$post_id . $suffix . '.css';
518
519 if ( Assets_Manager::$is_updated && file_exists( PREMIUM_ASSETS_PATH . $css_path ) ) {
520 wp_enqueue_style(
521 'pa-frontend',
522 PREMIUM_ASSETS_URL . $css_path,
523 array(),
524 time(),
525 'all'
526 );
527 }
528
529 $pa_elements = get_option( 'pa_elements_' . Assets_Manager::$post_id, array() );
530
531 // If the assets are not updated, or they are updated but the dynamic CSS file has not been loaded for any reason.
532 if ( ! Assets_Manager::$is_updated || ( ! empty( $pa_elements ) && ! wp_style_is( 'pa-frontend', 'enqueued' ) ) ) {
533 $this->enqueue_old_styles( $dir, $is_rtl, $suffix );
534 }
535 }
536 }
537
538 /**
539 * Register Old Styles
540 *
541 * @since 4.9.0
542 * @access public
543 *
544 * @param string $directory style directory.
545 * @param string $is_rtl page direction.
546 * @param string $suffix file suffix.
547 */
548 public function enqueue_old_styles( $directory, $is_rtl, $suffix ) {
549
550 wp_enqueue_style(
551 'premium-addons',
552 PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $is_rtl . $suffix . '.css',
553 array(),
554 PREMIUM_ADDONS_VERSION,
555 'all'
556 );
557 }
558
559 /**
560 * Registers required JS files
561 *
562 * @since 1.0.0
563 * @access public
564 */
565 public function register_frontend_scripts() {
566
567 $maps_settings = self::$maps;
568
569 $dir = Helper_Functions::get_scripts_dir();
570 $suffix = Helper_Functions::get_assets_suffix();
571
572 $locale = isset( $maps_settings['premium-map-locale'] ) ? $maps_settings['premium-map-locale'] : 'en';
573 $assets_gen_enabled = self::$modules['premium-assets-generator'] ? true : false;
574
575 $type = get_post_type();
576
577 if ( $assets_gen_enabled && ( 'page' === $type || 'post' === $type ) ) {
578
579 // If the elemens are cached and ready to generate.
580 if ( Assets_Manager::$is_updated ) {
581 Assets_Manager::generate_asset_file( 'js' );
582 Assets_Manager::generate_asset_file( 'css' );
583 }
584
585 $js_path = '/pa-frontend-' . Assets_Manager::$post_id . $suffix . '.js';
586
587 if ( file_exists( PREMIUM_ASSETS_PATH . $js_path ) ) {
588
589 wp_enqueue_script(
590 'pa-frontend',
591 PREMIUM_ASSETS_URL . $js_path,
592 array( 'jquery' ),
593 time(),
594 true
595 );
596
597 wp_localize_script(
598 'pa-frontend',
599 'PremiumSettings',
600 array(
601 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
602 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
603 )
604 );
605
606 if ( class_exists( 'woocommerce' ) ) {
607 wp_localize_script(
608 'pa-frontend',
609 'PremiumWooSettings',
610 array(
611 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
612 'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
613 'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
614 'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
615 'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
616 )
617 );
618 }
619 }
620 }
621
622 // If the assets are not ready, or file does not exist for any reson.
623 if ( ! wp_script_is( 'pa-frontend', 'enqueued' ) ) {
624 $this->register_old_scripts( $dir, $suffix );
625 }
626
627 wp_register_script( 'tiktok-embed', 'https://www.tiktok.com/embed.js', array(), false, true );
628
629 wp_register_script(
630 'prettyPhoto-js',
631 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/prettyPhoto' . $suffix . '.js',
632 array( 'jquery' ),
633 PREMIUM_ADDONS_VERSION,
634 true
635 );
636
637 wp_register_script(
638 'tooltipster-bundle',
639 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/tooltipster' . $suffix . '.js',
640 array( 'jquery' ),
641 PREMIUM_ADDONS_VERSION,
642 true
643 );
644
645 wp_register_script(
646 'pa-vticker',
647 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/vticker' . $suffix . '.js',
648 array( 'jquery' ),
649 PREMIUM_ADDONS_VERSION,
650 true
651 );
652
653 wp_register_script(
654 'pa-typed',
655 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/typed' . $suffix . '.js',
656 array( 'jquery' ),
657 PREMIUM_ADDONS_VERSION,
658 true
659 );
660
661 wp_register_script(
662 'pa-countdown',
663 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-countdown' . $suffix . '.js',
664 array( 'jquery' ),
665 PREMIUM_ADDONS_VERSION,
666 true
667 );
668
669 wp_register_script(
670 'isotope-js',
671 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/isotope' . $suffix . '.js',
672 array( 'jquery' ),
673 PREMIUM_ADDONS_VERSION,
674 true
675 );
676
677 wp_register_script(
678 'pa-modal',
679 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/modal' . $suffix . '.js',
680 array( 'jquery' ),
681 PREMIUM_ADDONS_VERSION,
682 true
683 );
684
685 wp_register_script(
686 'pa-maps',
687 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-maps' . $suffix . '.js',
688 array( 'jquery' ),
689 PREMIUM_ADDONS_VERSION,
690 true
691 );
692
693 wp_register_script(
694 'pa-vscroll',
695 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-vscroll' . $suffix . '.js',
696 array( 'jquery' ),
697 PREMIUM_ADDONS_VERSION,
698 true
699 );
700
701 wp_register_script(
702 'pa-slimscroll',
703 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-slimscroll' . $suffix . '.js',
704 array( 'jquery' ),
705 PREMIUM_ADDONS_VERSION,
706 true
707 );
708
709 wp_register_script(
710 'pa-iscroll',
711 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/iscroll' . $suffix . '.js',
712 array( 'jquery' ),
713 PREMIUM_ADDONS_VERSION,
714 true
715 );
716
717 wp_register_script(
718 'pa-tilt',
719 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/universal-tilt' . $suffix . '.js',
720 array( 'jquery' ),
721 PREMIUM_ADDONS_VERSION,
722 true
723 );
724
725 wp_register_script(
726 'lottie-js',
727 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/lottie' . $suffix . '.js',
728 array(
729 'jquery',
730 'elementor-waypoints',
731 ),
732 PREMIUM_ADDONS_VERSION,
733 true
734 );
735
736 wp_register_script(
737 'pa-tweenmax',
738 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/TweenMax' . $suffix . '.js',
739 array( 'jquery' ),
740 PREMIUM_ADDONS_VERSION,
741 true
742 );
743
744 wp_register_script(
745 'pa-headroom',
746 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/headroom' . $suffix . '.js',
747 array( 'jquery' ),
748 PREMIUM_ADDONS_VERSION
749 );
750
751 wp_register_script(
752 'pa-menu',
753 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-nav-menu' . $suffix . '.js',
754 array( 'jquery' ),
755 PREMIUM_ADDONS_VERSION,
756 true
757 );
758
759 if ( $maps_settings['premium-map-cluster'] ) {
760 wp_register_script(
761 'pa-maps-cluster',
762 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/markerclusterer' . $suffix . '.js',
763 array(),
764 '1.0.1',
765 false
766 );
767 }
768
769 if ( $maps_settings['premium-map-disable-api'] && '1' !== $maps_settings['premium-map-api'] ) {
770 $api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&callback=initMap&language=%2$s', $maps_settings['premium-map-api'], $locale );
771 wp_register_script(
772 'pa-maps-api',
773 $api,
774 array(),
775 PREMIUM_ADDONS_VERSION,
776 true
777 );
778 }
779
780 wp_register_script(
781 'pa-slick',
782 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/slick' . $suffix . '.js',
783 array( 'jquery' ),
784 PREMIUM_ADDONS_VERSION,
785 true
786 );
787
788 wp_register_script(
789 'pa-flipster',
790 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/flipster' . $suffix . '.js',
791 array( 'jquery' ),
792 PREMIUM_ADDONS_VERSION
793 );
794
795 wp_register_script(
796 'pa-anime',
797 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/anime' . $suffix . '.js',
798 array( 'jquery' ),
799 PREMIUM_ADDONS_VERSION,
800 true
801 );
802
803 wp_register_script(
804 'pa-feffects',
805 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-floating-effects' . $suffix . '.js',
806 array( 'jquery' ),
807 PREMIUM_ADDONS_VERSION,
808 true
809 );
810
811 wp_register_script(
812 'pa-gTooltips',
813 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-global-tooltips' . $suffix . '.js',
814 array( 'jquery' ),
815 PREMIUM_ADDONS_VERSION,
816 true
817 );
818
819 wp_register_script(
820 'pa-shape-divider',
821 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-shape-divider' . $suffix . '.js',
822 array( 'jquery' ),
823 PREMIUM_ADDONS_VERSION,
824 true
825 );
826
827 wp_localize_script(
828 'pa-gTooltips',
829 'PremiumSettings',
830 array(
831 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
832 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
833 )
834 );
835
836 wp_localize_script(
837 'premium-addons',
838 'PremiumSettings',
839 array(
840 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
841 'nonce' => wp_create_nonce( 'pa-blog-widget-nonce' ),
842 )
843 );
844
845 wp_register_script(
846 'pa-eq-height',
847 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-eq-height' . $suffix . '.js',
848 array( 'jquery' ),
849 PREMIUM_ADDONS_VERSION,
850 true
851 );
852
853 wp_register_script(
854 'pa-dis-conditions',
855 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-dis-conditions' . $suffix . '.js',
856 array( 'jquery' ),
857 PREMIUM_ADDONS_VERSION,
858 true
859 );
860
861 wp_register_script(
862 'pa-gsap',
863 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/pa-gsap' . $suffix . '.js',
864 array( 'jquery' ),
865 PREMIUM_ADDONS_VERSION,
866 true
867 );
868
869 wp_register_script(
870 'pa-motionpath',
871 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/motionpath' . $suffix . '.js',
872 array(
873 'elementor-waypoints',
874 'jquery',
875 ),
876 PREMIUM_ADDONS_VERSION,
877 true
878 );
879
880 wp_register_script(
881 'pa-fontawesome-all',
882 PREMIUM_ADDONS_URL . 'assets/frontend/min-js/fontawesome-all.min.js',
883 array( 'jquery' ),
884 PREMIUM_ADDONS_VERSION,
885 true
886 );
887
888 wp_register_script(
889 'pa-scrolltrigger',
890 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/scrollTrigger' . $suffix . '.js',
891 array( 'jquery' ),
892 PREMIUM_ADDONS_VERSION,
893 true
894 );
895
896 wp_register_script(
897 'pa-notifications',
898 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-notifications' . $suffix . '.js',
899 array( 'jquery' ),
900 PREMIUM_ADDONS_VERSION,
901 true
902 );
903
904 wp_register_script(
905 'pa-luxon',
906 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/luxon' . $suffix . '.js',
907 array( 'jquery' ),
908 PREMIUM_ADDONS_VERSION,
909 true
910 );
911
912 wp_register_script(
913 'mousewheel-js',
914 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/jquery-mousewheel' . $suffix . '.js',
915 array( 'jquery' ),
916 PREMIUM_ADDONS_VERSION,
917 true
918 );
919
920 wp_register_script(
921 'pa-wrapper-link',
922 PREMIUM_ADDONS_URL . 'assets/frontend/' . $dir . '/premium-wrapper-link' . $suffix . '.js',
923 array( 'jquery' ),
924 PREMIUM_ADDONS_VERSION,
925 true
926 );
927
928 // Localize jQuery with required data for Global Add-ons.
929 if ( self::$modules['premium-floating-effects'] ) {
930 wp_localize_script(
931 'pa-feffects',
932 'PremiumFESettings',
933 array(
934 'papro_installed' => Helper_Functions::check_papro_version(),
935 )
936 );
937 }
938 }
939
940 /**
941 * Register Old Scripts
942 *
943 * @since 4.9.0
944 * @access public
945 *
946 * @param string $directory script directory.
947 * @param string $suffix file suffix.
948 */
949 public function register_old_scripts( $directory, $suffix ) {
950
951 wp_register_script(
952 'premium-addons',
953 PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-addons' . $suffix . '.js',
954 array( 'jquery' ),
955 PREMIUM_ADDONS_VERSION,
956 true
957 );
958
959 // We need to make sure premium-woocommerce.js will not be loaded twice if assets are generated.
960 if ( class_exists( 'woocommerce' ) ) {
961 wp_register_script(
962 'premium-woocommerce',
963 PREMIUM_ADDONS_URL . 'assets/frontend/' . $directory . '/premium-woo-products' . $suffix . '.js',
964 array( 'jquery' ),
965 PREMIUM_ADDONS_VERSION,
966 true
967 );
968
969 wp_localize_script(
970 'premium-woocommerce',
971 'PremiumWooSettings',
972 array(
973 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
974 'products_nonce' => wp_create_nonce( 'pa-woo-products-nonce' ),
975 'qv_nonce' => wp_create_nonce( 'pa-woo-qv-nonce' ),
976 'cta_nonce' => wp_create_nonce( 'pa-woo-cta-nonce' ),
977 'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) ),
978 )
979 );
980 }
981 }
982
983 /**
984 * Enqueue Preview CSS files
985 *
986 * @since 2.9.0
987 * @access public
988 */
989 public function enqueue_preview_styles() {
990
991 $custom_css = '
992 .e-preview--show-hidden-elements[data-elementor-device-mode="mobile"] .elementor-edit-area-active .elementor-hidden-mobile.premium-addons-element {
993 display: none;
994 }
995
996 .e-preview--show-hidden-elements[data-elementor-device-mode="tablet"] .elementor-edit-area-active .elementor-hidden-tablet.premium-addons-element {
997 display: none;
998 }
999
1000 .e-preview--show-hidden-elements[data-elementor-device-mode="mobile_extra"] .elementor-edit-area-active .elementor-hidden-mobile_extra.premium-addons-element {
1001 display: none;
1002 }
1003
1004 .e-preview--show-hidden-elements[data-elementor-device-mode="tablet_extra"] .elementor-edit-area-active .elementor-hidden-tablet_extra.premium-addons-element {
1005 display: none;
1006 }
1007
1008 .e-preview--show-hidden-elements[data-elementor-device-mode="widescreen"] .elementor-edit-area-active .elementor-hidden-widescreen.premium-addons-element {
1009 display: none;
1010 }
1011
1012 .e-preview--show-hidden-elements[data-elementor-device-mode="desktop"] .elementor-edit-area-active .elementor-hidden-desktop.premium-addons-element {
1013 display: none;
1014 }';
1015
1016 wp_enqueue_style( 'pa-prettyphoto' );
1017
1018 wp_enqueue_style( 'premium-addons' );
1019
1020 wp_add_inline_style( 'premium-addons', $custom_css );
1021
1022 wp_enqueue_style( 'pa-slick' );
1023
1024 }
1025
1026 /**
1027 * Load widgets require function
1028 *
1029 * @since 1.0.0
1030 * @access public
1031 */
1032 public function widgets_area() {
1033 $this->widgets_register();
1034 }
1035
1036 /**
1037 * Requires widgets files
1038 *
1039 * @since 1.0.0
1040 * @access private
1041 */
1042 private function widgets_register() {
1043
1044 $enabled_elements = self::$modules;
1045
1046 foreach ( glob( PREMIUM_ADDONS_PATH . 'widgets/*.php' ) as $file ) {
1047
1048 $slug = basename( $file, '.php' );
1049
1050 // Fixes the conflict between Lottie widget/addon keys.
1051 if ( 'premium-lottie' === $slug ) {
1052
1053 // Check if Lottie widget switcher value was saved before.
1054 $saved_options = get_option( 'pa_save_settings' );
1055
1056 $slug = 'premium-lottie-widget';
1057
1058 }
1059
1060 $enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
1061
1062 if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
1063 $this->register_addon( $file );
1064 }
1065 }
1066 }
1067
1068 /**
1069 * Register Woocommerce Widgets.
1070 *
1071 * @since 4.0.0
1072 * @access private
1073 */
1074 private function woo_widgets_register() {
1075
1076 $enabled_elements = self::$modules;
1077
1078 foreach ( glob( PREMIUM_ADDONS_PATH . 'modules/woocommerce/widgets/*.php' ) as $file ) {
1079
1080 $slug = basename( $file, '.php' );
1081
1082 $enabled = isset( $enabled_elements[ $slug ] ) ? $enabled_elements[ $slug ] : '';
1083
1084 if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $enabled_elements ) {
1085
1086 $this->register_addon( $file );
1087 }
1088 }
1089 }
1090
1091 /**
1092 * Enqueue editor scripts
1093 *
1094 * @since 3.2.5
1095 * @access public
1096 */
1097 public function enqueue_editor_scripts() {
1098
1099 $map_enabled = isset( self::$modules['premium-maps'] ) ? self::$modules['premium-maps'] : 1;
1100
1101 if ( $map_enabled ) {
1102
1103 $premium_maps_api = self::$maps['premium-map-api'];
1104
1105 $locale = isset( self::$maps['premium-map-locale'] ) ? self::$maps['premium-map-locale'] : 'en';
1106
1107 $disable_api = self::$maps['premium-map-disable-api'];
1108
1109 if ( $disable_api && '1' !== $premium_maps_api ) {
1110
1111 $api = sprintf( 'https://maps.googleapis.com/maps/api/js?key=%1$s&language=%2$s', $premium_maps_api, $locale );
1112 wp_enqueue_script(
1113 'pa-maps-api',
1114 $api,
1115 array(),
1116 PREMIUM_ADDONS_VERSION,
1117 false
1118 );
1119
1120 }
1121
1122 wp_enqueue_script(
1123 'pa-maps-finder',
1124 PREMIUM_ADDONS_URL . 'assets/editor/js/pa-maps-finder.js',
1125 array( 'jquery' ),
1126 PREMIUM_ADDONS_VERSION,
1127 true
1128 );
1129
1130 }
1131 }
1132
1133 /**
1134 * Get Pinterest account token for Pinterest Feed widget
1135 *
1136 * @since 4.10.2
1137 * @access public
1138 *
1139 * @return void
1140 */
1141 public function get_pinterest_token() {
1142
1143 check_ajax_referer( 'pa-editor', 'security' );
1144
1145 $api_url = 'https://appfb.premiumaddons.com/wp-json/fbapp/v2/pinterest';
1146
1147 $response = wp_remote_get(
1148 $api_url,
1149 array(
1150 'timeout' => 60,
1151 'sslverify' => false,
1152 )
1153 );
1154
1155 $body = wp_remote_retrieve_body( $response );
1156 $body = json_decode( $body, true );
1157
1158 // $transient_name = 'pa_pinterest_token_' . $body;
1159
1160 // $expire_time = 29 * DAY_IN_SECONDS;
1161
1162 // set_transient( $transient_name, true, $expire_time );
1163
1164 wp_send_json_success( $body );
1165 }
1166
1167 /**
1168 * Get Pinterest account token for Pinterest Feed widget
1169 *
1170 * @since 4.10.2
1171 * @access public
1172 *
1173 * @return void
1174 */
1175 public function get_pinterest_boards() {
1176
1177 check_ajax_referer( 'pa-blog-widget-nonce', 'nonce' );
1178
1179 if ( ! isset( $_GET['token'] ) ) {
1180 wp_send_json_error();
1181 }
1182
1183 $token = sanitize_text_field( wp_unslash( $_GET['token'] ) );
1184
1185 $transient_name = 'pa_pinterest_boards_' . substr( $token, 0, 15 );
1186
1187 $body = get_transient( $transient_name );
1188
1189 if ( false === $body ) {
1190
1191 $api_url = 'https://api.pinterest.com/v5/boards?page_size=60';
1192
1193 $response = wp_remote_get(
1194 $api_url,
1195 array(
1196 'headers' => array(
1197 'Authorization' => 'Bearer ' . $token,
1198 ),
1199 )
1200 );
1201
1202 $body = wp_remote_retrieve_body( $response );
1203 $body = json_decode( $body, true );
1204
1205 set_transient( $transient_name, $body, 30 * MINUTE_IN_SECONDS );
1206
1207 }
1208
1209 $boards = array();
1210
1211 foreach ( $body['items'] as $index => $board ) {
1212 $boards[ $board['id'] ] = $board['name'];
1213 }
1214
1215 wp_send_json_success( wp_json_encode( $boards ) );
1216 }
1217
1218 /**
1219 * Get Pinterest account token for Pinterest Feed widget
1220 *
1221 * @since 4.10.2
1222 * @access public
1223 *
1224 * @return void
1225 */
1226 public function get_tiktok_token() {
1227
1228 check_ajax_referer( 'pa-editor', 'security' );
1229
1230 $api_url = 'https://appfb.premiumaddons.com/wp-json/fbapp/v2/tiktok';
1231
1232 $response = wp_remote_get(
1233 $api_url,
1234 array(
1235 'timeout' => 60,
1236 'sslverify' => false,
1237 )
1238 );
1239
1240 $body = wp_remote_retrieve_body( $response );
1241 $body = json_decode( $body, true );
1242
1243 // $transient_name = 'pa_tiktok_token_' . $body;
1244
1245 // $expire_time = 29 * DAY_IN_SECONDS;
1246
1247 // set_transient( $transient_name, true, $expire_time );
1248
1249 wp_send_json_success( $body );
1250 }
1251
1252 /**
1253 * Insert Contact Form 7 Form
1254 *
1255 * @since 4.10.2
1256 * @access public
1257 *
1258 * @return void
1259 */
1260 public function insert_cf_form() {
1261
1262 check_ajax_referer( 'pa-editor', 'security' );
1263
1264 if ( ! isset( $_GET['preset'] ) ) {
1265 wp_send_json_error();
1266 }
1267
1268 $preset = sanitize_text_field( wp_unslash( $_GET['preset'] ) );
1269
1270 $current_user = wp_get_current_user();
1271
1272 $props = array(
1273 'form' => Helper_Functions::get_cf_form_body( $preset ),
1274 'mail' => array(
1275 'active' => 1,
1276 'subject' => '[_site_title] "[your-subject]"',
1277 'sender' => '[_site_title]',
1278 'recipient' => '[_site_admin_email]',
1279 'body' => 'From: [your-name] [your-email]' . PHP_EOL .
1280 'Subject: [your-subject]' . PHP_EOL . PHP_EOL .
1281 'Message Body:' . PHP_EOL . '[your-message]' . PHP_EOL . PHP_EOL .
1282 '--' . PHP_EOL .
1283 'This e-mail was sent from a contact form on [_site_title] ([_site_url])',
1284 'additional_headers' => 'Reply-To: [your-email]',
1285 'attachments' => '',
1286 'use_html' => '',
1287 'exclude_blank' => '',
1288 ),
1289 'mail_2' => array(
1290 'active' => '',
1291 'subject' => '[_site_title] "[your-subject]"',
1292 'sender' => '[_site_title]',
1293 'recipient' => '[your-email]',
1294 'body' => 'Message Body:' . PHP_EOL . '[your-message]' . PHP_EOL . PHP_EOL .
1295 '--' . PHP_EOL .
1296 'This e-mail was sent from a contact form on [_site_title] ([_site_url])',
1297 'additional_headers' => 'Reply-To: [_site_admin_email]',
1298 'attachments' => '',
1299 'use_html' => '',
1300 'exclude_blank' => '',
1301 ),
1302 'messages' => array(
1303 'mail_sent_ok' => 'Thank you for your message. It has been sent.',
1304 'mail_sent_ng' => 'There was an error trying to send your message. Please try again later.',
1305 'validation_error' => 'One or more fields have an error. Please check and try again.',
1306 'spam' => 'There was an error trying to send your message. Please try again later.',
1307 'accept_terms' => 'You must accept the terms and conditions before sending your message.',
1308 'invalid_required' => 'Please fill out this field.',
1309 'invalid_too_long' => 'This field has a too long input.',
1310 'invalid_too_short' => 'This field has a too short input.',
1311 'upload_failed' => 'There was an unknown error uploading the file.',
1312 'upload_file_type_invalid' => 'You are not allowed to upload files of this type.',
1313 'upload_file_too_large' => 'The uploaded file is too large.',
1314 'upload_failed_php_error' => 'There was an error uploading the file.',
1315 'invalid_date' => 'Please enter a date in YYYY-MM-DD format.',
1316 'date_too_early' => 'This field has a too early date.',
1317 'date_too_late' => 'This field has a too late date.',
1318 'invalid_number' => 'Please enter a number.',
1319 'number_too_small' => 'This field has a too small number.',
1320 'number_too_large' => 'This field has a too large number.',
1321 'quiz_answer_not_correct' => 'The answer to the quiz is incorrect.',
1322 'invalid_email' => 'Please enter an email address.',
1323 'invalid_url' => 'Please enter a URL.',
1324 'invalid_tel' => 'Please enter a telephone number.',
1325 ),
1326 'additional_settings' => '',
1327 );
1328
1329 $post_content = implode( "\n", wpcf7_array_flatten( $props ) );
1330
1331 $args = array(
1332 'post_status' => 'publish',
1333 'post_type' => 'wpcf7_contact_form',
1334 'post_content' => $post_content,
1335 'post_author' => $current_user->ID,
1336 'post_title' => sprintf(
1337 __( 'Form | %s', 'premium-addons-for-elementor' ),
1338 date( 'Y-m-d H:i' )
1339 ),
1340 );
1341
1342 $post_id = wp_insert_post( $args );
1343
1344 foreach ( $props as $prop => $value ) {
1345 update_post_meta(
1346 $post_id,
1347 '_' . $prop,
1348 wpcf7_normalize_newline_deep( $value )
1349 );
1350 }
1351
1352 $form_id = wpcf7_generate_contact_form_hash( $post_id );
1353
1354 add_post_meta( $post_id, '_hash', $form_id, true );
1355
1356 wp_send_json_success( substr( $form_id, 0, 7 ) );
1357 }
1358
1359 /**
1360 * Load Cross Domain Copy Paste JS Files.
1361 *
1362 * @since 3.21.1
1363 */
1364 public function enqueue_editor_cp_scripts() {
1365
1366 wp_enqueue_script(
1367 'premium-xdlocalstorage',
1368 PREMIUM_ADDONS_URL . 'assets/editor/js/xdlocalstorage.js',
1369 null,
1370 PREMIUM_ADDONS_VERSION,
1371 true
1372 );
1373
1374 wp_enqueue_script(
1375 'premium-cross-cp',
1376 PREMIUM_ADDONS_URL . 'assets/editor/js/premium-cross-cp.js',
1377 array( 'jquery', 'elementor-editor', 'premium-xdlocalstorage' ),
1378 PREMIUM_ADDONS_VERSION,
1379 true
1380 );
1381
1382 // Check for required Compatible Elementor version.
1383 if ( ! version_compare( ELEMENTOR_VERSION, '3.1.0', '>=' ) ) {
1384 $elementor_old = true;
1385 } else {
1386 $elementor_old = false;
1387 }
1388
1389 wp_localize_script(
1390 'jquery',
1391 'premium_cross_cp',
1392 array(
1393 'ajax_url' => admin_url( 'admin-ajax.php' ),
1394 'nonce' => wp_create_nonce( 'premium_cross_cp_import' ),
1395 'elementorCompatible' => $elementor_old,
1396 )
1397 );
1398 }
1399
1400 /**
1401 * Get Template Content
1402 *
1403 * Get Elementor template HTML content.
1404 *
1405 * @since 3.2.6
1406 * @access public
1407 */
1408 public function get_template_content() {
1409
1410 $template = isset( $_GET['templateID'] ) ? sanitize_text_field( wp_unslash( $_GET['templateID'] ) ) : '';
1411
1412 if ( empty( $template ) ) {
1413 wp_send_json_error( 'Empty Template ID' );
1414 }
1415
1416 $template_content = $this->template_instance->get_template_content( $template );
1417
1418 if ( empty( $template_content ) || ! isset( $template_content ) ) {
1419 wp_send_json_error( 'Empty Content' );
1420 }
1421
1422 $data = array(
1423 'template_content' => $template_content,
1424 );
1425
1426 wp_send_json_success( $data );
1427 }
1428
1429 /**
1430 *
1431 * Register addon by file name.
1432 *
1433 * @access public
1434 *
1435 * @param string $file File name.
1436 *
1437 * @return void
1438 */
1439 public function register_addon( $file ) {
1440
1441 $widgets_manager = \Elementor\Plugin::instance()->widgets_manager;
1442
1443 $base = basename( str_replace( '.php', '', $file ) );
1444 $class = ucwords( str_replace( '-', ' ', $base ) );
1445 $class = str_replace( ' ', '_', $class );
1446 $class = sprintf( 'PremiumAddons\Widgets\%s', $class );
1447
1448 if ( 'PremiumAddons\Widgets\Premium_Contactform' !== $class ) {
1449 require $file;
1450 } elseif ( function_exists( 'wpcf7' ) ) {
1451 require $file;
1452 }
1453
1454 if ( 'PremiumAddons\Widgets\Premium_Videobox' === $class || 'PremiumAddons\Widgets\Premium_Weather' === $class ) {
1455 require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
1456 }
1457
1458 if ( 'PremiumAddons\Widgets\Premium_Weather' === $class ) {
1459 require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-weather-handler.php';
1460 }
1461
1462 if ( in_array( $class, array( 'PremiumAddons\Widgets\Premium_Pinterest_Feed', 'PremiumAddons\Widgets\Premium_Tiktok_Feed' ), true ) ) {
1463 require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/mobile-detector.php';
1464
1465 if ( 'PremiumAddons\Widgets\Premium_Pinterest_Feed' == $class ) {
1466 require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-pins-handler.php';
1467 }
1468
1469 if ( 'PremiumAddons\Widgets\Premium_Tiktok_Feed' == $class ) {
1470 require_once PREMIUM_ADDONS_PATH . 'widgets/dep/pa-tiktok-handler.php';
1471 }
1472 }
1473
1474 if ( class_exists( $class, false ) ) {
1475
1476 $widgets_manager->register( new $class() );
1477
1478 }
1479 }
1480
1481 /**
1482 * Registers Premium Addons Custom Controls.
1483 *
1484 * @since 4.2.5
1485 * @access public
1486 *
1487 * @return void
1488 */
1489 public function init_pa_controls() {
1490
1491 /**
1492 * List of Modules that need a custom control.
1493 *
1494 * @var array
1495 */
1496 $modules = array(
1497 self::$modules['premium-blog'],
1498 self::$modules['premium-equal-height'],
1499 self::$modules['pa-display-conditions'],
1500 self::$modules['premium-smart-post-listing'],
1501 self::$modules['premium-post-ticker'],
1502 self::$modules['premium-tcloud'],
1503 self::$modules['premium-notifications'],
1504 self::$modules['premium-pinterest-feed'],
1505 self::$modules['premium-contactform'],
1506 );
1507
1508 $blog_modules = array(
1509 self::$modules['premium-blog'],
1510 self::$modules['premium-smart-post-listing'],
1511 self::$modules['premium-post-ticker'],
1512 self::$modules['premium-notifications'],
1513 self::$modules['premium-search-form'],
1514 );
1515
1516 $load_controls = in_array( true, $modules, true );
1517
1518 $load_blog_controls = in_array( true, $blog_modules, true );
1519
1520 $control_manager = \Elementor\Plugin::instance();
1521
1522 if ( $load_controls ) {
1523
1524 if ( self::$modules['premium-equal-height'] || self::$modules['premium-pinterest-feed'] ) {
1525
1526 require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-select.php';
1527 $premium_select = __NAMESPACE__ . '\Controls\Premium_Select';
1528 $control_manager->controls_manager->register( new $premium_select() );
1529
1530 }
1531
1532 if ( $load_blog_controls ) {
1533
1534 require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-post-filter.php';
1535
1536 $premium_post_filter = __NAMESPACE__ . '\Controls\Premium_Post_Filter';
1537
1538 $control_manager->controls_manager->register( new $premium_post_filter() );
1539 }
1540
1541 if ( self::$modules['premium-blog'] || self::$modules['premium-smart-post-listing'] || self::$modules['premium-tcloud'] ) {
1542
1543 require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-tax-filter.php';
1544
1545 $premium_tax_filter = __NAMESPACE__ . '\Controls\Premium_Tax_Filter';
1546
1547 $control_manager->controls_manager->register( new $premium_tax_filter() );
1548 }
1549
1550 if ( self::$modules['pa-display-conditions'] ) {
1551
1552 require_once PREMIUM_ADDONS_PATH . 'includes/controls/premium-acf-selector.php';
1553 $premium_acf_selector = __NAMESPACE__ . '\Controls\Premium_Acf_Selector';
1554 $control_manager->controls_manager->register( new $premium_acf_selector() );
1555
1556 }
1557 }
1558
1559 if ( self::$modules['premium-contactform'] || self::$modules['premium-shape-divider'] ) {
1560
1561 require_once PREMIUM_ADDONS_PATH . 'includes/controls/pa-image-choose.php';
1562 $premium_image_choose = __NAMESPACE__ . '\Controls\Premium_Image_Choose';
1563 $control_manager->controls_manager->register( new $premium_image_choose() );
1564
1565 }
1566 }
1567
1568 /**
1569 * Load PA Extensions
1570 *
1571 * @since 4.7.0
1572 * @access public
1573 */
1574 public function load_pa_extensions() {
1575
1576 if ( self::$modules['premium-equal-height'] ) {
1577 Equal_Height::get_instance();
1578 }
1579
1580 if ( self::$modules['pa-display-conditions'] ) {
1581 require_once PREMIUM_ADDONS_PATH . 'widgets/dep/urlopen.php';
1582 Display_Conditions::get_instance();
1583 }
1584
1585 if ( self::$modules['premium-floating-effects'] ) {
1586 Floating_Effects::get_instance();
1587 }
1588
1589 if ( class_exists( 'woocommerce' ) && self::$modules['woo-products'] ) {
1590 Woocommerce::get_instance();
1591 }
1592
1593 if ( self::$modules['premium-global-tooltips'] ) {
1594 GlobalTooltips::get_instance();
1595 }
1596
1597 if ( self::$modules['premium-shape-divider'] ) {
1598 Shape_Divider::get_instance();
1599 }
1600
1601 if ( self::$modules['premium-wrapper-link'] ) {
1602 Wrapper_Link::get_instance();
1603 }
1604 }
1605
1606 /**
1607 *
1608 * Creates and returns an instance of the class
1609 *
1610 * @since 1.0.0
1611 * @access public
1612 *
1613 * @return object
1614 */
1615 public static function get_instance() {
1616
1617 if ( ! isset( self::$instance ) ) {
1618
1619 self::$instance = new self();
1620
1621 }
1622
1623 return self::$instance;
1624 }
1625 }
1626