PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.11.84
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.11.84
4.11.84 4.11.83 4.11.82 4.11.80 4.11.81 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 / addons / display-conditions.php
premium-addons-for-elementor / addons Last commit date
display-conditions.php 2 weeks ago equal-height.php 2 weeks ago floating-effects.php 2 weeks ago liquid-glass.php 2 weeks ago shape-divider.php 2 weeks ago shapes.php 2 weeks ago tooltips.php 2 days ago wrapper-link.php 2 weeks ago
display-conditions.php
382 lines
1 <?php
2 /**
3 * Class: Display_Conditions
4 * Name : Display Conditions
5 * Slug : display-conditions
6 */
7
8 namespace PremiumAddons\Addons;
9
10 // PremiumAddons Classes.
11 use PremiumAddons\Includes\Helper_Functions;
12 use PremiumAddons\Includes\PA_Controls_Handler;
13
14 // Elementor Classes.
15 use Elementor\Repeater;
16 use Elementor\Controls_Manager;
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Class Display_Conditions
24 *
25 * @since 4.11.58
26 * @access public
27 * @package PremiumAddons\Addons
28 */
29 class Display_Conditions {
30
31 /**
32 * Load Script
33 *
34 * @var bool|null
35 */
36 private static $load_script = null;
37
38 /**
39 * Class object
40 *
41 * @var self|null
42 */
43 private static $instance = null;
44
45 /**
46 * Constructor
47 */
48 public function __construct() {
49
50 // Enqueue the required JS file.
51 add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_scripts' ) );
52
53 add_action( 'elementor/element/section/section_advanced/after_section_end', array( $this, 'register_controls' ), 10 );
54 add_action( 'elementor/element/column/section_advanced/after_section_end', array( $this, 'register_controls' ), 10 );
55 add_action( 'elementor/element/common/_section_style/after_section_end', array( $this, 'register_controls' ), 10 );
56
57 add_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) );
58
59 add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'register_controls' ), 10 );
60 }
61
62 /**
63 * Enqueue scripts.
64 *
65 * Registers required dependencies for the extension and enqueues them.
66 *
67 * @since 4.9.21
68 * @access public
69 */
70 public function enqueue_scripts() {
71
72 if ( ! wp_script_is( 'pa-dis-conditions', 'enqueued' ) ) {
73 wp_enqueue_script( 'pa-dis-conditions' );
74 }
75 }
76
77 /**
78 * Register PA Display Conditions controls.
79 *
80 * @access public
81 * @param object $element for current element.
82 */
83 public function register_controls( $element ) {
84
85 $element->start_controls_section(
86 'section_pa_display_conditions',
87 array(
88 'label' => sprintf( '<i class="pa-extension-icon pa-dash-icon"></i> %s', __( 'Display Conditions', 'premium-addons-for-elementor' ) ),
89 'tab' => Controls_Manager::TAB_ADVANCED,
90 )
91 );
92
93 $element->add_control(
94 'pa_dc_cache_notice',
95 array(
96 'type' => Controls_Manager::RAW_HTML,
97 'raw' => __( 'Please note that you need to <b>deactivate</b> the <a href="https://elementor.com/help/element-caching-help/" style="color: var(--e-a-color-warning);" target="_blank">Element Caching</a> feature to avoid any conflicts', 'premium-addons-for-elementor' ),
98 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
99 'condition' => array(
100 'pa_display_conditions_switcher' => 'yes',
101 ),
102 )
103 );
104
105 $controls_obj = new PA_Controls_Handler();
106
107 $options = PA_Controls_Handler::$conditions;
108
109 $options['acf'] = array(
110 'label' => __( 'ACF (PRO)', 'premium-addons-for-elementor' ),
111 'options' => array(
112 'acf_choice' => __( 'Choice', 'premium-addons-for-elementor' ),
113 'acf_text' => __( 'Text', 'premium-addons-for-elementor' ),
114 'acf_boolean' => __( 'True/False', 'premium-addons-for-elementor' ),
115 ),
116 );
117
118 $options['woocommerce'] = array(
119 'label' => __( 'WooCommerce (PRO)', 'premium-addons-for-elementor' ),
120 'options' => array(
121 'woo_cat_page' => __( 'Current Category Page', 'premium-addons-for-elementor' ),
122 'woo_product_cat' => __( 'Current Product Category', 'premium-addons-for-elementor' ),
123 'woo_product_price' => __( 'Current Product Price', 'premium-addons-for-elementor' ),
124 'woo_product_stock' => __( 'Current Product Stock', 'premium-addons-for-elementor' ),
125 'woo_orders' => __( 'Purchased/In Cart Orders', 'premium-addons-for-elementor' ),
126 'woo_category' => __( 'Purchased/In Cart Categories', 'premium-addons-for-elementor' ),
127 'woo_last_purchase' => __( 'Last Purchase In Cart', 'premium-addons-for-elementor' ),
128 'woo_total_price' => __( 'Amount In Cart', 'premium-addons-for-elementor' ),
129 'woo_cart_products' => __( 'Products In Cart', 'premium-addons-for-elementor' ),
130 'woo_purchase_products' => __( 'Purchased Products', 'premium-addons-for-elementor' ),
131 ),
132 );
133
134 $options = apply_filters( 'pa_display_conditions', $options );
135
136 $element->add_control(
137 'pa_display_conditions_switcher',
138 array(
139 'label' => __( 'Enable Display Conditions', 'premium-addons-for-elementor' ),
140 'type' => Controls_Manager::SWITCHER,
141 'return_value' => 'yes',
142 'render_type' => 'template',
143 'prefix_class' => 'pa-display-conditions-',
144 'frontend_available' => true,
145 )
146 );
147
148 $element->add_control(
149 'pa_display_action',
150 array(
151 'label' => __( 'Action', 'premium-addons-for-elementor' ),
152 'type' => Controls_Manager::SELECT,
153 'default' => 'show',
154 'options' => array(
155 'show' => __( 'Show Element', 'premium-addons-for-elementor' ),
156 'hide' => __( 'Hide Element', 'premium-addons-for-elementor' ),
157 ),
158 'condition' => array(
159 'pa_display_conditions_switcher' => 'yes',
160 ),
161 )
162 );
163
164 $element->add_control(
165 'pa_display_when',
166 array(
167 'label' => __( 'Display When', 'premium-addons-for-elementor' ),
168 'type' => Controls_Manager::SELECT,
169 'default' => 'any',
170 'options' => array(
171 'any' => __( 'Any Condition is Met', 'premium-addons-for-elementor' ),
172 'all' => __( 'All Conditions Are Met', 'premium-addons-for-elementor' ),
173 ),
174 'condition' => array(
175 'pa_display_conditions_switcher' => 'yes',
176 ),
177 )
178 );
179
180 $repeater = new Repeater();
181
182 $repeater->add_control(
183 'pa_condition_key',
184 array(
185 'label' => __( 'Type', 'premium-addons-for-elementor' ),
186 'type' => Controls_Manager::SELECT,
187 'groups' => $options,
188 'default' => 'browser',
189 'label_block' => true,
190 )
191 );
192
193 $options_conditions = apply_filters(
194 'pa_pro_display_conditions',
195 array(
196 'url_string',
197 'url_referer',
198 'shortcode',
199 'woo_orders',
200 'woo_cat_page',
201 'woo_category',
202 'woo_product_price',
203 'woo_product_stock',
204 'woo_product_cat',
205 'woo_last_purchase',
206 'woo_total_price',
207 'woo_purchase_products',
208 'woo_cart_products',
209 'acf_choice',
210 'acf_text',
211 'acf_boolean',
212 )
213 );
214
215 $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'conditions-addon', 'wp-editor', 'get-pro' );
216
217 $repeater->add_control(
218 'display_conditions_notice',
219 array(
220 'type' => Controls_Manager::RAW_HTML,
221 'raw' => __( 'This option is available in Premium Addons Pro. ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>',
222 'content_classes' => 'papro-upgrade-notice',
223 'condition' => array(
224 'pa_condition_key' => $options_conditions,
225 ),
226 )
227 );
228
229 $controls_obj->add_repeater_source_controls( $repeater );
230
231 $repeater->add_control(
232 'pa_condition_operator',
233 array(
234 'type' => Controls_Manager::SELECT,
235 'default' => 'is',
236 'label_block' => true,
237 'options' => array(
238 'is' => __( 'Is', 'premium-addons-for-elementor' ),
239 'not' => __( 'Is Not', 'premium-addons-for-elementor' ),
240 ),
241 'condition' => array(
242 'pa_condition_key!' => $options_conditions,
243 ),
244 )
245 );
246
247 $controls_obj->add_repeater_compare_controls( $repeater );
248
249 $repeater->add_control(
250 'pa_condition_timezone',
251 array(
252 'label' => 'Timezone',
253 'type' => Controls_Manager::SELECT,
254 'default' => 'server',
255 'label_block' => true,
256 'options' => array(
257 'local' => __( 'Local Time', 'premium-addons-for-elementor' ),
258 'server' => __( 'Server Timezone', 'premium-addons-for-elementor' ),
259 ),
260 'condition' => array(
261 'pa_condition_key' => array( 'date_range', 'time_range', 'date', 'day' ),
262 ),
263 )
264 );
265
266 $values = $repeater->get_controls();
267
268 $element->add_control(
269 'pa_condition_repeater',
270 array(
271 'label' => __( 'Conditions', 'premium-addons-for-elementor' ),
272 'type' => Controls_Manager::REPEATER,
273 'label_block' => true,
274 'fields' => $values,
275 'title_field' => '<# print( pa_condition_key.replace(/_/g, " ").split(" ").map((s) => s.charAt(0).toUpperCase() + s.substring(1)).join(" ")) #>',
276 'prevent_empty' => false,
277 'condition' => array(
278 'pa_display_conditions_switcher' => 'yes',
279 ),
280 )
281 );
282
283 $this->add_helpful_information( $element );
284
285 $element->end_controls_section();
286 }
287
288 /**
289 * Add Help & Docs
290 *
291 * @since 4.9.39
292 * @access private
293 * @param object $element for current element.
294 *
295 * @return void
296 */
297 private function add_helpful_information( $element ) {
298
299 $element->add_control(
300 'pa_condition_info',
301 array(
302 'label' => __( 'Help & Docs', 'premium-addons-for-elementor' ),
303 'separator' => 'before',
304 'type' => Controls_Manager::HEADING,
305 'condition' => array(
306 'pa_display_conditions_switcher' => 'yes',
307 ),
308 )
309 );
310
311 $docs = array(
312 'https://premiumaddons.com/docs/elementor-display-conditions-tutorial/' => __( 'Getting started »', 'premium-addons-for-elementor' ),
313 'https://www.youtube.com/watch?v=ydv343MTf4w/' => __( 'Check the video tutorial »', 'premium-addons-for-elementor' ),
314 'https://premiumaddons.com/docs/elementor-editor-not-loading-with-display-conditions/' => __( 'Fix editor not loading with Display Conditions enabled »', 'premium-addons-for-elementor' ),
315 'https://premiumaddons.com/docs/how-to-show-hide-element-based-on-browser-elementor-display-conditions/' => __( 'Show/Hide Element Based on Browser »', 'premium-addons-for-elementor' ),
316 'https://premiumaddons.com/docs/how-to-show-hide-element-on-specific-time-range-elementor-display-conditions/' => __( 'Show/Hide Element Based on Time Range »', 'premium-addons-for-elementor' ),
317 'https://premiumaddons.com/docs/how-to-show-hide-element-with-location-elementor-display-conditions/' => __( 'Show/Hide Element Based on Location »', 'premium-addons-for-elementor' ),
318 );
319
320 $doc_index = 1;
321 foreach ( $docs as $url => $title ) {
322
323 $doc_url = Helper_Functions::get_campaign_link( $url, 'conditions-addon', 'wp-editor', 'get-support' );
324
325 $element->add_control(
326 'pa_condition_doc_' . $doc_index,
327 array(
328 'type' => Controls_Manager::RAW_HTML,
329 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $doc_url ), esc_html( $title ) ),
330 'content_classes' => 'editor-pa-doc',
331 'condition' => array(
332 'pa_display_conditions_switcher' => 'yes',
333 ),
334 )
335 );
336
337 ++$doc_index;
338
339 }
340 }
341
342 /**
343 * Check Script Enqueue
344 *
345 * Check if the script files should be loaded.
346 *
347 * @since 4.9.21
348 * @access public
349 *
350 * @param object $element for current element.
351 */
352 public function check_script_enqueue( $element ) {
353
354 if ( self::$load_script ) {
355 return;
356 }
357
358 $settings = $element->get_active_settings();
359
360 if ( ! empty( $settings['pa_display_conditions_switcher'] ) ) {
361
362 $this->enqueue_scripts();
363
364 self::$load_script = true;
365 }
366 }
367
368 /**
369 * Returns an instance of this class.
370 *
371 * @access public
372 */
373 public static function get_instance() {
374
375 if ( ! isset( self::$instance ) ) {
376 self::$instance = new self();
377 }
378
379 return self::$instance;
380 }
381 }
382