PluginProbe ʕ •ᴥ•ʔ
Essential Addons for Elementor – Popular Elementor Templates & Widgets / 6.6.9
Essential Addons for Elementor – Popular Elementor Templates & Widgets v6.6.9
6.6.9 6.6.8 6.6.7 6.6.6 6.6.5 6.6.4 6.6.3 5.7.3 5.7.4 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.15 5.8.16 5.8.18 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.10 5.9.11 5.9.12 5.9.13 5.9.14 5.9.15 5.9.16 5.9.17 5.9.18 5.9.19 5.9.2 5.9.20 5.9.21 5.9.22 5.9.23 5.9.24 5.9.25 5.9.26 5.9.27 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.14 6.0.15 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.0 6.1.1 6.1.10 6.1.11 trunk 6.1.12 1.0.0 6.1.13 1.0.1 6.1.14 1.1.0 6.1.15 2.0 6.1.17 2.1 6.1.18 2.10.0 6.1.19 2.10.1 6.1.2 2.10.2 6.1.20 2.10.3 6.1.3 2.10.4 6.1.4 2.10.5 6.1.5 2.2.0 6.1.6 2.2.1 6.1.7 2.2.2 6.1.8 2.2.3 6.1.9 2.2.4 6.2.0 2.2.5 6.2.1 2.3.0 6.2.2 2.3.1 6.2.3 2.4.0 6.2.4 2.4.1 6.3.0 2.4.2 6.3.1 2.4.3 6.3.2 2.5.0 6.3.3 2.6.0 6.4.0 2.7.0 6.5.0 2.7.1 6.5.1 2.7.10 6.5.10 2.7.11 6.5.11 2.7.2 6.5.12 2.7.3 6.5.13 2.7.4 6.5.2 2.7.5 6.5.3 2.7.6 6.5.4 2.7.7 6.5.5 2.7.8 6.5.6 2.7.9 6.5.7 2.8.0 6.5.8 2.8.1 6.5.9 2.8.2 6.6.0 2.8.3 6.6.1 2.8.4 6.6.2 2.8.5 2.8.6 2.8.7 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.4.1 3.1.5 3.2.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 5.0.0 5.0.1 5.0.10 5.0.11 5.0.12 5.0.13 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.4.6 5.5.5 5.6.5 5.7.2
essential-addons-for-elementor-lite / includes / Traits / Helper.php
essential-addons-for-elementor-lite / includes / Traits Last commit date
Admin.php 6 days ago Ajax_Handler.php 1 month ago Controls.php 3 months ago Core.php 2 months ago Elements.php 6 days ago Enqueue.php 6 months ago Facebook_Feed.php 4 months ago Helper.php 3 months ago Library.php 5 months ago Login_Registration.php 6 days ago Shared.php 5 years ago Template_Query.php 3 months ago Twitter_Feed.php 5 months ago Woo_Product_Comparable.php 2 months ago index.php 3 years ago
Helper.php
814 lines
1 <?php
2
3 namespace Essential_Addons_Elementor\Traits;
4
5 if ( !defined( 'ABSPATH' ) ) {
6 exit;
7 } // Exit if accessed directly
8
9 use Elementor\Plugin;
10 use \Elementor\Controls_Manager;
11 use \Elementor\Group_Control_Border;
12 use \Elementor\Group_Control_Box_Shadow;
13 use \Essential_Addons_Elementor\Classes\Helper as HelperClass;
14
15 trait Helper
16 {
17 use Template_Query;
18
19 /**
20 * Woo Checkout
21 */
22
23
24 /** Filter to add plugins to the TOC list.
25 *
26 * @param array TOC plugins.
27 *
28 * @return mixed
29 * @since 3.9.3
30 */
31 public function toc_rank_math_support( $toc_plugins ) {
32 $toc_plugins[ 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ] = __( 'Essential Addons for Elementor', 'essential-addons-for-elementor-lite' );
33 return $toc_plugins;
34 }
35
36 /**
37 * Save typeform access token
38 *
39 * @since 4.0.2
40 */
41 public function typeform_auth_handle() {
42 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
43 if ( !empty($_GET[ 'page' ]) && 'eael-settings' === sanitize_text_field( wp_unslash( $_GET[ 'page' ] ) ) ) {
44 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
45 if ( !empty( $_GET[ 'typeform_tk' ] ) && !empty( $_GET[ 'pr_code' ] ) ) {
46 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
47 if ( wp_hash( 'eael_typeform' ) === sanitize_text_field( wp_unslash( $_GET[ 'pr_code' ] ) ) ) {
48 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
49 update_option( 'eael_save_typeform_personal_token', sanitize_text_field( wp_unslash( $_GET[ 'typeform_tk' ] ) ), false );
50 }
51 }
52 }
53 }
54
55 /*****************************
56 *
57 * Compatibility for Pro
58 *
59 * @since 4.2.4
60 */
61 public function eael_get_page_templates( $type = null ) {
62 return HelperClass::get_elementor_templates( $type );
63 }
64
65 public function eael_query_controls() {
66 return do_action( 'eael/controls/query', $this );
67 }
68
69 public function eael_layout_controls() {
70 return do_action( 'eael/controls/layout', $this );
71 }
72
73 public function eael_load_more_button_style() {
74 return do_action( 'eael/controls/load_more_button_style', $this );
75 }
76
77 public function eael_read_more_button_style() {
78 return do_action( 'eael/controls/read_more_button_style', $this );
79 }
80
81 public function eael_controls_custom_positioning( $_1, $_2, $_3, $_4 ) {
82 return do_action( 'eael/controls/custom_positioning', $this, $_1, $_2, $_3, $_4 );
83 }
84
85 public function eael_get_all_types_post() {
86 return HelperClass::get_post_types();
87 }
88
89 public function eael_get_pages() {
90 return HelperClass::get_post_list( 'page' );
91 }
92
93 public function eael_woocommerce_product_categories_by_id() {
94 return HelperClass::get_terms_list( 'product_cat' );
95 }
96
97 public function fix_old_query( $settings ) {
98 return HelperClass::fix_old_query( $settings );
99 }
100
101 public function eael_get_query_args( $settings ) {
102 return HelperClass::get_query_args( $settings );
103 }
104
105 public function eael_get_tags( $args ) {
106 return HelperClass::get_tags_list( $args );
107 }
108
109 public function eael_get_taxonomies_by_post( $args ) {
110 return HelperClass::get_taxonomies_by_post( $args );
111 }
112
113 /**
114 * It returns the widget settings provided the page id and widget id
115 * @param int $page_id Page ID where the widget is used
116 * @param string $widget_id the id of the widget whose settings we want to fetch
117 *
118 * @return array
119 */
120 public function eael_get_widget_settings( $page_id, $widget_id ) {
121 $document = Plugin::$instance->documents->get( $page_id );
122 $settings = [];
123 if ( $document ) {
124 $elements = Plugin::instance()->documents->get( $page_id )->get_elements_data();
125 $widget_data = $this->find_element_recursive( $elements, $widget_id );
126 if(!empty($widget_data)) {
127 $widget = Plugin::instance()->elements_manager->create_element_instance( $widget_data );
128 if ( $widget ) {
129 $settings = $widget->get_settings_for_display();
130 }
131 }
132 }
133 return $settings;
134 }
135 /**
136 * It store data temporarily for 5 mins by default
137 *
138 * @param $name
139 * @param $data
140 * @param int $time time in seconds. Default is 300s = 5 minutes
141 *
142 * @return bool it returns true if the data saved, otherwise, false returned.
143 */
144 public function eael_set_transient( $name, $data, $time = 300 ) {
145 $time = !empty( $time ) ? (int) $time : ( 5 * MINUTE_IN_SECONDS );
146 return set_transient( $name, $data, $time );
147 }
148 public function print_load_more_button($settings, $args, $plugin_type = 'free')
149 {
150 //@TODO; not all widget's settings contain posts_per_page name exactly, so adjust the settings before passing here or run a migration and make all settings key generalize for load more feature.
151 if (!isset($this->page_id)) {
152 if ( Plugin::$instance->documents->get_current() ) {
153 $this->page_id = Plugin::$instance->documents->get_current()->get_main_id();
154 }else{
155 $this->page_id = null;
156 }
157 }
158
159 $max_page = empty( $args['max_page'] ) ? false : $args['max_page'];
160 unset( $args['max_page'] );
161
162 if ( isset( $args['found_posts'] ) && $args['found_posts'] <= $args['posts_per_page'] ){
163 $this->add_render_attribute( 'load-more', [ 'class' => 'hide-load-more' ] );
164 unset( $args['found_posts'] );
165 }
166
167 $this->add_render_attribute( 'load-more', [
168 'class' => "eael-load-more-button",
169 'id' => "eael-load-more-btn-" . $this->get_id(),
170 'data-widget-id' => $this->get_id(),
171 'data-widget' => $this->get_id(),
172 'data-page-id' => $this->page_id,
173 'data-template' => json_encode( [
174 'dir' => $plugin_type,
175 'file_name' => $settings['loadable_file_name'],
176 'name' => $this->process_directory_name()
177 ],
178 1 ),
179 'data-class' => get_class( $this ),
180 'data-layout' => isset( $settings['layout_mode'] ) ? $settings['layout_mode'] : "",
181 'data-page' => 1,
182 'data-args' => http_build_query( $args ),
183 ]);
184
185 if ( $max_page ) {
186 $this->add_render_attribute( 'load-more', [ 'data-max-page' => $max_page ] );
187 }
188
189 if ( isset( $args['posts_per_page'] ) && $args['posts_per_page'] != '-1' ) {
190 $this->add_render_attribute( 'load-more-wrap', 'class', 'eael-load-more-button-wrap' );
191
192 if ( "eael-dynamic-filterable-gallery" == $this->get_name() ){
193 $this->add_render_attribute( 'load-more-wrap', 'class', 'dynamic-filter-gallery-loadmore' );
194 }
195
196 if ( 'infinity' === $settings['show_load_more'] ) {
197 $this->add_render_attribute( 'load-more-wrap', 'class', 'eael-infinity-scroll' );
198 $this->add_render_attribute( 'load-more-wrap', 'data-offset', esc_attr( $settings['load_more_infinityscroll_offset'] ) );
199 } else if ( ! ( 'true' == $settings['show_load_more'] || 1 == $settings['show_load_more'] || 'yes' == $settings['show_load_more'] ) ){
200 $this->add_render_attribute( 'load-more-wrap', 'class', 'eael-force-hide' );
201 }
202
203 do_action( 'eael/global/before-load-more-button', $settings, $args, $plugin_type );
204 ?>
205 <div <?php $this->print_render_attribute_string( 'load-more-wrap' ); ?>>
206 <button <?php $this->print_render_attribute_string( 'load-more' ); ?>>
207 <span class="eael-btn-loader button__loader"></span>
208 <span class="eael_load_more_text"><?php echo esc_html($settings['show_load_more_text']) ?></span>
209 </button>
210 </div>
211 <?php
212 do_action( 'eael/global/after-load-more-button', $settings, $args, $plugin_type );
213 }
214 }
215
216 public function eael_product_grid_script(){
217 if ( version_compare( WC()->version, '3.0.0', '>=' ) ) {
218 if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
219 wp_enqueue_script( 'zoom' );
220 }
221 if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
222 wp_enqueue_script( 'flexslider' );
223 }
224 if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
225 wp_enqueue_script( 'photoswipe-ui-default' );
226 wp_enqueue_style( 'photoswipe-default-skin' );
227 if ( has_action( 'wp_footer', 'woocommerce_photoswipe' ) === false ) {
228 add_action( 'wp_footer', 'woocommerce_photoswipe', 15 );
229 }
230 }
231 wp_enqueue_script( 'wc-add-to-cart-variation' );
232 wp_enqueue_script( 'wc-single-product' );
233 }
234 }
235
236 /**
237 * Rating Markup
238 */
239 public function eael_rating_markup( $html, $rating, $count ) {
240
241 if ( 0 == $rating ) {
242 $html = '<div class="eael-star-rating star-rating">';
243 $html .= wc_get_star_rating_html( $rating, $count );
244 $html .= '</div>';
245 }
246 return $html;
247 }
248
249 public function eael_product_wrapper_class( $classes, $product_id, $widget_name ) {
250
251 if ( ! is_plugin_active( 'woo-variation-swatches-pro/woo-variation-swatches-pro.php' ) ) {
252 return $classes;
253 }
254
255 $product = wc_get_product( $product_id );
256
257 if ( ! $product ) {
258 return $classes;
259 }
260
261 if ( $product->is_type( 'variable' ) ) {
262 $classes[] = 'wvs-archive-product-wrapper';
263 }
264
265 return $classes;
266 }
267
268 public function eael_woo_cart_empty_action() {
269 if ( ! function_exists( 'WC' ) ) {
270 return;
271 }
272
273 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
274 if ( !empty( $_GET['empty_cart'] ) && 'yes' === sanitize_text_field( wp_unslash( $_GET['empty_cart'] ) ) ) {
275 WC()->cart->empty_cart();
276 }
277 }
278
279 /**
280 * Customize checkout fields.
281 */
282 public function eael_customize_woo_checkout_fields( $fields ) {
283 global $post;
284
285 if ( ! is_object( $post ) || is_null( $post ) ) {
286 return $fields;
287 }
288
289 $widgets = get_post_meta( $post->ID, '_elementor_controls_usage', true );
290 $widget_key = 'eael-woo-checkout';
291 if ( ! $widgets ) {
292 $widget_key = 'woo-checkout';
293 $widgets = get_post_meta( $post->ID, '_eael_widget_elements', true );
294 }
295
296 $eael_fields = get_post_meta( $post->ID, '_eael_checkout_fields_settings', true );
297
298 if ( ! isset( $widgets[ $widget_key ] ) || empty( $eael_fields ) ) {
299 return $fields;
300 }
301
302 $eael_fields = get_post_meta( $post->ID, '_eael_checkout_fields_settings', true );
303
304 foreach ( $fields as $type => $field_sets ) {
305 foreach ( $field_sets as $key => $field_set ) {
306 if ( isset( $eael_fields[ $type ][ $key ]['label'] ) ) {
307 $fields[ $type ][ $key ]['label'] = $eael_fields[ $type ][ $key ]['label'];
308 }
309 if ( isset( $eael_fields[ $type ][ $key ]['placeholder'] ) ) {
310 $fields[ $type ][ $key ]['placeholder'] = $eael_fields[ $type ][ $key ]['placeholder'];
311 }
312 }
313 }
314
315 return $fields;
316 }
317
318 /**
319 * Update Checkout Cart Quantity via ajax call.
320 */
321 public function eael_checkout_cart_qty_update() {
322 if ( empty( $_POST['nonce'] ) || ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'essential-addons-elementor' ) ) ) {
323 die( esc_html__( 'Permission Denied!', 'essential-addons-for-elementor-lite' ) );
324 }
325
326 $cart_item_key = !empty( $_POST['cart_item_key'] ) ? sanitize_text_field( wp_unslash( $_POST['cart_item_key'] ) ) : '';
327 $cart_item = WC()->cart->get_cart_item( $cart_item_key );
328 $cart_item_quantity = !empty( $_POST['quantity']) ? absint( wp_unslash( $_POST['quantity'] ) ) :0;
329 $cart_item_quantity = apply_filters( 'woocommerce_stock_amount_cart_item',
330 apply_filters( 'woocommerce_stock_amount',
331 preg_replace(
332 "/[^0-9\.]/",
333 '',
334 filter_var($cart_item_quantity, FILTER_SANITIZE_NUMBER_INT)
335 )
336 ), $cart_item_key );
337
338 $passed_validation = apply_filters( 'woocommerce_update_cart_validation', true, $cart_item_key, $cart_item, $cart_item_quantity );
339 if ( $passed_validation ) {
340 WC()->cart->set_quantity( $cart_item_key, $cart_item_quantity, true );
341 wp_send_json_success(
342 array(
343 'message' => __( 'Quantity updated successfully.', 'essential-addons-for-elementor-lite' ),
344 // 'cart_item_key' => $cart_item_key,
345 'cart_item_quantity' => $cart_item_quantity,
346 'cart_item_subtotal' => WC()->cart->get_product_subtotal( $cart_item['data'], $cart_item_quantity ),
347 'cart_subtotal' => WC()->cart->get_cart_subtotal(),
348 'cart_total' => WC()->cart->get_cart_total()
349 )
350 );
351 } else {
352 wp_send_json_error(
353 array(
354 'message' => __( 'Quantity update failed.', 'essential-addons-for-elementor-lite' ),
355 )
356 );
357 }
358
359 die();
360 }
361
362 public function change_add_woo_checkout_update_order_reviewto_cart_text( $add_to_cart_text ) {
363 add_filter( 'woocommerce_product_add_to_cart_text', function ( $default ) use ( $add_to_cart_text ) {
364 global $product;
365 switch ( $product->get_type() ) {
366 case 'external':
367 return $add_to_cart_text[ 'add_to_cart_external_product_button_text' ];
368 break;
369 case 'grouped':
370 return $add_to_cart_text[ 'add_to_cart_grouped_product_button_text' ];
371 break;
372 case 'simple':
373 return $add_to_cart_text[ 'add_to_cart_simple_product_button_text' ];
374 break;
375 case 'variable':
376 return $add_to_cart_text[ 'add_to_cart_variable_product_button_text' ];
377 break;
378 default:
379 return $default;
380 }
381 } );
382 }
383
384 public function print_template_views(){
385 $button_test = ( HelperClass::get_local_plugin_data( 'templately/templately.php' ) === false )?'Install Templately':'Activate Templately ';
386 ?>
387 <div id="eael-promo-temp-wrap" class="eael-promo-temp-wrap" style="display: none">
388 <div class="eael-promo-temp-wrapper">
389 <div class="eael-promo-temp">
390 <a href="#" class="eael-promo-temp__times">
391 <i class="eicon-close" aria-hidden="true" title="Close"></i>
392 </a>
393 <div class="eael-promo-temp--left">
394 <div class="eael-promo-temp__logo">
395 <img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/templately/logo.svg' ); ?>" alt="">
396 </div>
397 <ul class="eael-promo-temp__feature__list">
398 <li><?php esc_html_e('6500+ Ready Templates','essential-addons-for-elementor-lite'); ?></li>
399 <li><?php esc_html_e('Supports Elementor & Gutenberg','essential-addons-for-elementor-lite'); ?></li>
400 <li><?php esc_html_e('Powering up 4,00,000+ Websites','essential-addons-for-elementor-lite'); ?></li>
401 <li><?php esc_html_e('Cloud Collaboration with Team','essential-addons-for-elementor-lite'); ?></li>
402 <li><?php esc_html_e('1-Click Full Site Import','essential-addons-for-elementor-lite'); ?></li>
403 </ul>
404 <form class="eael-promo-temp__form">
405 <label>
406 <input type="radio" value="install" class="eael-temp-promo-confirmation" name='eael-promo-temp__radio' checked>
407 <span><?php echo esc_html( $button_test ); ?></span>
408 </label>
409 <label>
410 <input type="radio" value="dnd" class="eael-temp-promo-confirmation" name='eael-promo-temp__radio'>
411 <span><?php esc_html_e('Don’t Show This Again','essential-addons-for-elementor-lite'); ?></span>
412 </label>
413 </form>
414
415 <?php if ( HelperClass::get_local_plugin_data( 'templately/templately.php' ) === false ) { ?>
416 <button class="wpdeveloper-plugin-installer" data-action="install"
417 data-slug="<?php echo 'templately'; ?>"><?php esc_html_e( 'Install Templately', 'essential-addons-for-elementor-lite' ); ?></button>
418 <?php } else { ?>
419 <?php if ( is_plugin_active( 'templately/templately.php' ) ) { ?>
420 <button class="wpdeveloper-plugin-installer"><?php esc_html_e( 'Activated Templately', 'essential-addons-for-elementor-lite' ); ?></button>
421 <?php } else { ?>
422 <button class="wpdeveloper-plugin-installer" data-action="activate"
423 data-basename="<?php echo 'templately/templately.php'; ?>"><?php esc_html_e( 'Activate Templately', 'essential-addons-for-elementor-lite' ); ?></button>
424 <?php } ?>
425 <?php } ?>
426 <button class="eael-prmo-status-submit" style="display: none"><?php esc_html_e('Submit','essential-addons-for-elementor-lite') ?></button>
427 </div>
428 <div class="eael-promo-temp--right">
429 <img src="<?php echo esc_url( EAEL_PLUGIN_URL . 'assets/admin/images/templately/templates-edit.jpg' ); ?>" alt="">
430 </div>
431 </div>
432 </div>
433 </div>
434 <?php
435 }
436
437 public function templately_promo_status() {
438 check_ajax_referer( 'essential-addons-elementor', 'security' );
439
440 if(!current_user_can('manage_options')){
441 wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
442 }
443
444 $status = update_option( 'eael_templately_promo_hide', true );
445 if ( $status ) {
446 wp_send_json_success();
447 } else {
448 wp_send_json_error();
449 }
450 }
451
452 /**
453 * Retrieve product quick view data
454 *
455 * @return string
456 */
457
458
459 /**
460 * return file path which are store in theme Template directory
461 * @param $file
462 */
463 public function retrive_theme_path() {
464 $current_theme = wp_get_theme();
465 return sprintf(
466 '%s/%s',
467 $current_theme->theme_root,
468 $current_theme->stylesheet
469 );
470 }
471
472 /**
473 * @param string $tag
474 * @param string $function_to_remove
475 * @param int|string $priority
476 */
477 public function eael_forcefully_remove_action( $tag, $function_to_remove, $priority ) {
478 global $wp_filter;
479 if ( isset( $wp_filter[ $tag ][ $priority ] ) && is_array( $wp_filter[ $tag ][ $priority ] ) ) {
480 foreach ( $wp_filter[ $tag ][ $priority ] as $callback_function => $registration ) {
481 if ( strlen( $callback_function ) > 32 && strpos( $callback_function, $function_to_remove, 32 ) !== false || $callback_function === $function_to_remove ) {
482 remove_action( $tag, $callback_function, $priority );
483 break;
484 }
485 }
486 }
487 }
488
489 /**
490 * eael_wpml_template_translation
491 * @param $id
492 * @return mixed|void
493 */
494 public function eael_wpml_template_translation($id){
495 $postType = get_post_type( $id );
496 if ( 'elementor_library' === $postType ) {
497 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
498 return apply_filters( 'wpml_object_id', $id, $postType, true );
499 }
500 return $id;
501 }
502
503 /**
504 * eael_sanitize_template_param
505 * Removes special characters that are illegal in filenames
506 *
507 * @param array $template_info
508 *
509 * @access public
510 * @return array
511 * @since 5.0.4
512 */
513 public function eael_sanitize_template_param( $template_info ){
514 $template_info = array_map( 'sanitize_text_field', $template_info );
515 return array_map( 'sanitize_file_name', $template_info );
516 }
517
518 /**
519 * sanitize_taxonomy_data
520 * Sanitize all value for tax query
521 *
522 * @param array $tax_list taxonomy param list
523 *
524 * @access protected
525 * @return array|array[]|string[]
526 * @since 5.0.4
527 */
528 public function sanitize_taxonomy_data( $tax_list ){
529 return array_map( function ( $param ) {
530 return is_array( $param ) ? array_map( 'sanitize_text_field', $param ) : sanitize_text_field( $param );
531 }, $tax_list );
532 }
533
534 /**
535 * eael_clear_widget_cache_data
536 * Remove cache from transient which contains widget data
537 *
538 * @access public
539 * @return array
540 * @since 5.0.7
541 */
542 public function eael_clear_widget_cache_data() {
543 global $wpdb;
544
545 check_ajax_referer( 'essential-addons-elementor', 'security' );
546
547 $ac_name = ! empty( $_POST['ac_name'] ) ? sanitize_text_field( wp_unslash( $_POST['ac_name'] ) ) : '';
548 $hastag = ! empty( $_POST['hastag'] ) ? sanitize_text_field( wp_unslash( $_POST['hastag'] ) ) : '';
549 $c_key = ! empty( $_POST['c_key'] ) ? sanitize_text_field( wp_unslash( $_POST['c_key'] ) ) : '';
550 $c_secret = ! empty( $_POST['c_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['c_secret'] ) ) : '';
551 $widget_id = ! empty( $_POST['widget_id'] ) ? sanitize_text_field( wp_unslash( $_POST['widget_id'] ) ) : '';
552 $permalink = ! empty( $_POST['page_permalink'] ) ? sanitize_text_field( wp_unslash( $_POST['page_permalink'] ) ) : '';
553 $page_id = url_to_postid($permalink);
554
555 $settings = $this->eael_get_widget_settings($page_id, $widget_id);
556 $twitter_v2 = ! empty( $settings['eael_twitter_api_v2'] ) && 'yes' === $settings['eael_twitter_api_v2'] ? true : false;
557
558 $key_pattern = '_transient_' . $ac_name . '%' . md5( $hastag . $c_key . $c_secret ) . '_tf_cache';
559
560 if( $twitter_v2 ){
561 $bearer_token = $settings['eael_twitter_feed_bearer_token'];
562 $key_pattern = '_transient_' . $ac_name . '%' . md5( $hastag . $c_key . $c_secret . $bearer_token ) . '_tf_cache';
563 }
564
565 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
566 $results = $wpdb->get_results( $wpdb->prepare(
567 "SELECT `option_name` AS `name`
568 FROM {$wpdb->options}
569 WHERE `option_name` LIKE %s
570 ORDER BY `option_name`",
571 $key_pattern
572 ) );
573
574 foreach ( $results as $transient ) {
575 $cache_key = substr( $transient->name, 11 );
576 delete_transient( $cache_key );
577 }
578
579 wp_send_json_success();
580 }
581
582 /**
583 * remove_admin_notice
584 *
585 *
586 * @return void
587 */
588 public function remove_admin_notice() {
589 $current_screen = get_current_screen();
590 if ( $current_screen->id == 'toplevel_page_eael-settings' ) {
591
592 remove_all_actions( 'user_admin_notices' );
593 remove_all_actions( 'admin_notices' );
594 remove_all_actions( 'all_admin_notices' );
595 remove_all_actions( 'network_admin_notices' );
596
597 // To showing notice in EA settings page we have to use 'eael_admin_notices' action hook
598 add_action( 'admin_notices', function () {
599 do_action( 'eael_admin_notices' );
600 } );
601 }
602 }
603
604 /**
605 * eael_show_admin_menu_notice
606 *
607 * Update flag if user visit Essential Addons setting page only first time
608 * @return void
609 * @since 5.1.0
610 */
611 public function eael_show_admin_menu_notice() {
612 if ( get_option( 'eael_admin_menu_notice' ) < self::EAEL_ADMIN_MENU_FLAG ) {
613 update_option( 'eael_admin_menu_notice',self::EAEL_ADMIN_MENU_FLAG,'no' );
614 }
615 }
616
617 /**
618 * Checking that is actually elementor activated and works
619 *
620 * @return bool
621 */
622 public function is_activate_elementor() {
623 return defined( 'ELEMENTOR_VERSION' ) && class_exists( 'Elementor\Plugin' );
624 }
625
626 public function eael_post_view_count() {
627 $post_types = HelperClass::get_post_types();
628 unset( $post_types['give_forms'] );
629
630 $post_types = apply_filters( 'eael_post_view_count_post_types', $post_types, HelperClass::get_post_types() );
631
632 if ( ! empty( $post_types ) && is_singular( array_keys( $post_types ) ) ) {
633 $post_id = get_the_ID();
634 $view_count = absint( get_post_meta( $post_id, '_eael_post_view_count', true ) );
635 update_post_meta( $post_id, '_eael_post_view_count', ++ $view_count );
636 }
637 }
638
639 // Add background control for Liquid Glass Effects.
640 public function eael_wd_liquid_glass_effect_bg_color_effect( $obj, $effect, $default_bg_color, $selector ) {
641 $obj->add_control(
642 'eael_wd_liquid_glass_effect_bg_color_' . $effect,
643 [
644 'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite' ),
645 'type' => Controls_Manager::COLOR,
646 'default' => $default_bg_color,
647 'selectors' => [
648 '{{WRAPPER}}.eael_wd_liquid_glass-'.$effect .' ' . $selector => 'background-color: {{VALUE}}',
649 ],
650 'condition' => [
651 'eael_wd_liquid_glass_effect_switch' => 'yes',
652 'eael_wd_liquid_glass_effect' => $effect,
653 ],
654 ]
655 );
656 }
657
658 //Add backdrop filter control for liquid glass effect.
659 public function eael_wd_liquid_glass_effect_backdrop_filter_effect( $obj, $effect, $default_size, $selector ) {
660 $selectors = in_array($effect, ['effect4','effect5','effect6'], true)
661 ? [ "{{WRAPPER}}.eael_wd_liquid_glass-{$effect} {$selector}::before" => 'backdrop-filter: blur({{SIZE}}px)' ]
662 : [ "{{WRAPPER}}.eael_wd_liquid_glass-{$effect} {$selector}" => 'backdrop-filter: blur({{SIZE}}px)' ];
663
664 $obj->add_control(
665 'eael_wd_liquid_glass_effect_backdrop_filter_' . $effect,
666 [
667 'label' => esc_html__( 'Backdrop Filter', 'essential-addons-for-elementor-lite' ),
668 'type' => Controls_Manager::SLIDER,
669 'range' => [
670 'px' => [
671 'min' => 0,
672 'max' => 50,
673 'step' => 1,
674 ],
675 ],
676 'default' => [
677 'size' => $default_size,
678 ],
679 'selectors' => $selectors,
680 'condition' => [
681 'eael_wd_liquid_glass_effect_switch' => 'yes',
682 'eael_wd_liquid_glass_effect' => $effect,
683 ],
684 ]
685 );
686 }
687
688 // Add background color control for liquid glass effect flip box rear.
689 public function eael_wd_liquid_glass_effect_bg_color_effect_rear( $obj, $effect, $default_bg_color, $selector ) {
690 $obj->add_control(
691 'eael_wd_liquid_glass_effect_bg_color_rear_' . $effect,
692 [
693 'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite' ),
694 'type' => Controls_Manager::COLOR,
695 'default' => $default_bg_color,
696 'selectors' => [
697 '{{WRAPPER}}.eael_wd_liquid_glass_rear-'.$effect .' ' . $selector => 'background-color: {{VALUE}}',
698 ],
699 'condition' => [
700 'eael_wd_liquid_glass_effect_switch_rear' => 'yes',
701 'eael_wd_liquid_glass_effect_rear' => $effect,
702 ],
703 ]
704 );
705 }
706
707 // Add backdrop filter control for liquid glass effect flip box rear.
708 public function eael_wd_liquid_glass_effect_backdrop_filter_effect_rear( $obj, $effect, $default_size, $selector ) {
709 $selectors = in_array($effect, ['effect4','effect5','effect6'], true)
710 ? [ "{{WRAPPER}}.eael_wd_liquid_glass_rear-{$effect} {$selector}::before" => 'backdrop-filter: blur({{SIZE}}px)' ]
711 : [ "{{WRAPPER}}.eael_wd_liquid_glass_rear-{$effect} {$selector}" => 'backdrop-filter: blur({{SIZE}}px)' ];
712 $obj->add_control(
713 'eael_wd_liquid_glass_effect_backdrop_filter_rear_' . $effect,
714 [
715 'label' => esc_html__( 'Backdrop Filter', 'essential-addons-for-elementor-lite' ),
716 'type' => Controls_Manager::SLIDER,
717 'range' => [
718 'px' => [
719 'min' => 0,
720 'max' => 50,
721 'step' => 1,
722 ],
723 ],
724 'default' => [
725 'size' => $default_size,
726 ],
727 'selectors' => $selectors,
728 'condition' => [
729 'eael_wd_liquid_glass_effect_switch_rear' => 'yes',
730 'eael_wd_liquid_glass_effect_rear' => $effect,
731 ],
732 ]
733 );
734 }
735
736 //Add border effect for Liquid Glass Effects
737 public function eael_wd_liquid_glass_border_effect( $obj, $effect, $default_color, $selector, $condition ) {
738 $obj->add_group_control(
739 Group_Control_Border::get_type(),
740 [
741 'name' => 'eael_wd_liquid_glass_border_'.$effect,
742 'fields_options' => [
743 'border' => [
744 'default' => 'solid',
745 ],
746 'width' => [
747 'default' => [
748 'top' => '1',
749 'right' => '1',
750 'bottom' => '1',
751 'left' => '1',
752 'isLinked' => false,
753 ],
754 ],
755 'color' => [
756 'default' => $default_color,
757 ],
758 ],
759 'selector' => '{{WRAPPER}}.eael_wd_liquid_glass_shadow-'.$effect .' '.$selector,
760 'condition' => [
761 'eael_wd_liquid_glass_effect_switch' => 'yes',
762 'eael_wd_liquid_glass_shadow_effect' => $effect,
763 'eael_wd_liquid_glass_effect' => $condition,
764 ],
765 ]
766 );
767 }
768
769 // Add border radius effect for Liquid Glass Effects
770 public function eael_wd_liquid_glass_border_radius_effect( $obj, $effect, $selector, $default_radius, $condition ) {
771 $obj->add_control(
772 'eael_wd_liquid_glass_border_radius_'.$effect,
773 [
774 'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite' ),
775 'type' => Controls_Manager::DIMENSIONS,
776 'size_units' => [ 'px', '%', 'rem', 'custom' ],
777 'default' => $default_radius,
778 'selectors' => [
779 '{{WRAPPER}}.eael_wd_liquid_glass_shadow-'.$effect.' '.$selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
780 ],
781 'condition' => [
782 'eael_wd_liquid_glass_effect_switch' => 'yes',
783 'eael_wd_liquid_glass_shadow_effect' => $effect,
784 'eael_wd_liquid_glass_effect' => $condition,
785 ],
786 ]
787 );
788 }
789
790 // Add shadow effect for Liquid Glass Effects
791 public function eael_wd_liquid_glass_shadow_effect( $obj, $effect, $selector, $default_shadow, $condition ) {
792 $obj->add_group_control(
793 Group_Control_Box_Shadow::get_type(),
794 [
795 'name' => 'eael_wd_liquid_glass_shadow_' . $effect,
796 'fields_options' => [
797 'box_shadow_type' => [ 'default' => 'yes' ],
798 'box_shadow' => [
799 'default' => $default_shadow,
800 ],
801 ],
802 'selector' => '{{WRAPPER}}.eael_wd_liquid_glass_shadow-'.$effect.' ' . $selector,
803 'condition' => [
804 'eael_wd_liquid_glass_effect_switch' => 'yes',
805 'eael_wd_liquid_glass_shadow_effect' => $effect,
806 'eael_wd_liquid_glass_effect' => $condition,
807 ],
808 ]
809 );
810 }
811
812 }
813
814