Version Description
- Add option to hide wrappers and other elements by selector (javascript only)
- Add new compare type "in_array_contains"
- Fix error when elementor is disabled
- Styling dynamic-tag field
- Prevent shortcode-execution on hidden elements
- Make condition value dynamic
Download this release
Release Info
Developer | rtowebsites |
Plugin | Dynamic Conditions |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.6 to 1.5.0
- Admin/DynamicConditionsAdmin.php +113 -5
- Admin/css/dynamic-conditions-admin.css +19 -0
- Lib/DynamicConditions.php +3 -3
- Public/DynamicConditionsPublic.php +34 -1
- Public/js/dynamic-conditions-public.js +51 -52
- README.txt +20 -2
- dynamic-conditions.php +2 -2
- languages/dynamicconditions-de_DE.mo +0 -0
- languages/dynamicconditions-de_DE.po +20 -2
Admin/DynamicConditionsAdmin.php
CHANGED
@@ -104,8 +104,30 @@ class DynamicConditionsAdmin {
|
|
104 |
* @param $args
|
105 |
*/
|
106 |
public function addConditionFields( $element, $section_id = null, $args = null ) {
|
107 |
-
$valueCondition = [
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
$type = 'element';
|
110 |
$renderType = 'ui';
|
111 |
if ( !empty( $element ) && is_object( $element ) && method_exists( $element, 'get_type' ) ) {
|
@@ -122,6 +144,13 @@ class DynamicConditionsAdmin {
|
|
122 |
Module::POST_META_CATEGORY,
|
123 |
];
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
if ( defined( Module::class . '::COLOR_CATEGORY' ) ) {
|
126 |
$categories[] = Module::COLOR_CATEGORY;
|
127 |
}
|
@@ -137,14 +166,14 @@ class DynamicConditionsAdmin {
|
|
137 |
$element->add_control(
|
138 |
'dynamicconditions_dynamic',
|
139 |
[
|
140 |
-
'label' => __( 'Dynamic Tag', '
|
141 |
'type' => Controls_Manager::MEDIA,
|
142 |
'dynamic' => [
|
143 |
'active' => true,
|
144 |
'categories' => $categories,
|
145 |
],
|
146 |
'render_type' => $renderType,
|
147 |
-
'placeholder' => __( 'Select condition field', '
|
148 |
]
|
149 |
);
|
150 |
|
@@ -181,6 +210,7 @@ class DynamicConditionsAdmin {
|
|
181 |
'less' => __( 'Less than', 'dynamicconditions' ),
|
182 |
'greater' => __( 'Greater than', 'dynamicconditions' ),
|
183 |
'in_array' => __( 'In array', 'dynamicconditions' ),
|
|
|
184 |
],
|
185 |
'description' => __( 'Select your condition for this widget visibility.', 'dynamicconditions' ),
|
186 |
|
@@ -220,6 +250,10 @@ class DynamicConditionsAdmin {
|
|
220 |
'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
|
221 |
'render_type' => $renderType,
|
222 |
|
|
|
|
|
|
|
|
|
223 |
'condition' => [
|
224 |
'dynamicconditions_condition' => $valueCondition,
|
225 |
'dynamicconditions_type' => [ 'default', 'strtotime' ],
|
@@ -234,6 +268,10 @@ class DynamicConditionsAdmin {
|
|
234 |
'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
|
235 |
'description' => __( 'Add a second condition value, if between is selected', 'dynamicconditions' ),
|
236 |
'render_type' => $renderType,
|
|
|
|
|
|
|
|
|
237 |
|
238 |
'condition' => [
|
239 |
'dynamicconditions_condition' => [ 'between' ],
|
@@ -378,6 +416,20 @@ class DynamicConditionsAdmin {
|
|
378 |
]
|
379 |
);
|
380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
$languageArray = explode( '_', get_locale() );
|
382 |
$language = array_shift( $languageArray );
|
383 |
$element->add_control(
|
@@ -466,6 +518,7 @@ class DynamicConditionsAdmin {
|
|
466 |
]
|
467 |
);
|
468 |
|
|
|
469 |
$element->add_control(
|
470 |
'dynamicconditions_hr3',
|
471 |
[
|
@@ -474,6 +527,60 @@ class DynamicConditionsAdmin {
|
|
474 |
]
|
475 |
);
|
476 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
$element->add_control(
|
478 |
'dynamicconditions_debug',
|
479 |
[
|
@@ -482,6 +589,7 @@ class DynamicConditionsAdmin {
|
|
482 |
'render_type' => $renderType,
|
483 |
]
|
484 |
);
|
|
|
485 |
$element->end_controls_section();
|
486 |
}
|
487 |
-
}
|
104 |
* @param $args
|
105 |
*/
|
106 |
public function addConditionFields( $element, $section_id = null, $args = null ) {
|
107 |
+
$valueCondition = [
|
108 |
+
'equal',
|
109 |
+
'not_equal',
|
110 |
+
'contains',
|
111 |
+
'not_contains',
|
112 |
+
'less',
|
113 |
+
'greater',
|
114 |
+
'between',
|
115 |
+
'in_array',
|
116 |
+
'in_array_contains'
|
117 |
+
];
|
118 |
+
|
119 |
+
$allCondition = [
|
120 |
+
'equal',
|
121 |
+
'not_equal',
|
122 |
+
'contains',
|
123 |
+
'not_contains',
|
124 |
+
'less',
|
125 |
+
'greater',
|
126 |
+
'between',
|
127 |
+
'empty',
|
128 |
+
'not_empty'
|
129 |
+
];
|
130 |
+
|
131 |
$type = 'element';
|
132 |
$renderType = 'ui';
|
133 |
if ( !empty( $element ) && is_object( $element ) && method_exists( $element, 'get_type' ) ) {
|
144 |
Module::POST_META_CATEGORY,
|
145 |
];
|
146 |
|
147 |
+
$categoriesTextOnly = [
|
148 |
+
Module::BASE_GROUP,
|
149 |
+
Module::TEXT_CATEGORY,
|
150 |
+
Module::URL_CATEGORY,
|
151 |
+
Module::POST_META_CATEGORY,
|
152 |
+
];
|
153 |
+
|
154 |
if ( defined( Module::class . '::COLOR_CATEGORY' ) ) {
|
155 |
$categories[] = Module::COLOR_CATEGORY;
|
156 |
}
|
166 |
$element->add_control(
|
167 |
'dynamicconditions_dynamic',
|
168 |
[
|
169 |
+
'label' => __( 'Dynamic Tag', 'dynamicconditions' ),
|
170 |
'type' => Controls_Manager::MEDIA,
|
171 |
'dynamic' => [
|
172 |
'active' => true,
|
173 |
'categories' => $categories,
|
174 |
],
|
175 |
'render_type' => $renderType,
|
176 |
+
'placeholder' => __( 'Select condition field', 'dynamicconditions' ),
|
177 |
]
|
178 |
);
|
179 |
|
210 |
'less' => __( 'Less than', 'dynamicconditions' ),
|
211 |
'greater' => __( 'Greater than', 'dynamicconditions' ),
|
212 |
'in_array' => __( 'In array', 'dynamicconditions' ),
|
213 |
+
'in_array_contains' => __( 'In array contains', 'dynamicconditions' ),
|
214 |
],
|
215 |
'description' => __( 'Select your condition for this widget visibility.', 'dynamicconditions' ),
|
216 |
|
250 |
'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
|
251 |
'render_type' => $renderType,
|
252 |
|
253 |
+
'dynamic' => [
|
254 |
+
'active' => true,
|
255 |
+
'categories' => $categoriesTextOnly,
|
256 |
+
],
|
257 |
'condition' => [
|
258 |
'dynamicconditions_condition' => $valueCondition,
|
259 |
'dynamicconditions_type' => [ 'default', 'strtotime' ],
|
268 |
'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
|
269 |
'description' => __( 'Add a second condition value, if between is selected', 'dynamicconditions' ),
|
270 |
'render_type' => $renderType,
|
271 |
+
'dynamic' => [
|
272 |
+
'active' => true,
|
273 |
+
'categories' => $categoriesTextOnly,
|
274 |
+
],
|
275 |
|
276 |
'condition' => [
|
277 |
'dynamicconditions_condition' => [ 'between' ],
|
416 |
]
|
417 |
);
|
418 |
|
419 |
+
$element->add_control(
|
420 |
+
'dynamicconditions_in_array_contains_description',
|
421 |
+
[
|
422 |
+
'type' => Controls_Manager::RAW_HTML,
|
423 |
+
'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
|
424 |
+
'render_type' => $renderType,
|
425 |
+
'condition' => [
|
426 |
+
'dynamicconditions_condition' => [ 'in_array_contains' ],
|
427 |
+
],
|
428 |
+
'show_label' => false,
|
429 |
+
'raw' => __( 'Use comma-separated values, to check if dynamic-value contains one of each item.', 'dynamicconditions' ),
|
430 |
+
]
|
431 |
+
);
|
432 |
+
|
433 |
$languageArray = explode( '_', get_locale() );
|
434 |
$language = array_shift( $languageArray );
|
435 |
$element->add_control(
|
518 |
]
|
519 |
);
|
520 |
|
521 |
+
|
522 |
$element->add_control(
|
523 |
'dynamicconditions_hr3',
|
524 |
[
|
527 |
]
|
528 |
);
|
529 |
|
530 |
+
|
531 |
+
$element->add_control(
|
532 |
+
'dynamicconditions_hideWrapper',
|
533 |
+
[
|
534 |
+
'type' => Controls_Manager::TEXT,
|
535 |
+
'label' => __( 'Hide wrapper', 'dynamicconditions' ),
|
536 |
+
'description' => __( 'Will hide a parent matching the selector.', 'dynamicconditions' ),
|
537 |
+
'placeholder' => 'selector',
|
538 |
+
'render_type' => $renderType,
|
539 |
+
]
|
540 |
+
);
|
541 |
+
|
542 |
+
$element->add_control(
|
543 |
+
'dynamicconditions_hideOthers',
|
544 |
+
[
|
545 |
+
'type' => Controls_Manager::TEXT,
|
546 |
+
'label' => __( 'Hide other elements', 'dynamicconditions' ),
|
547 |
+
'description' => __( 'Will hide all other elements matching the selector.', 'dynamicconditions' ),
|
548 |
+
'placeholder' => 'selector',
|
549 |
+
'render_type' => $renderType,
|
550 |
+
]
|
551 |
+
);
|
552 |
+
|
553 |
+
$element->add_control(
|
554 |
+
'dynamicconditions_hr4',
|
555 |
+
[
|
556 |
+
'type' => Controls_Manager::DIVIDER,
|
557 |
+
'style' => 'thick',
|
558 |
+
]
|
559 |
+
);
|
560 |
+
|
561 |
+
$element->add_control(
|
562 |
+
'dynamicconditions_widget_id',
|
563 |
+
[
|
564 |
+
'type' => Controls_Manager::TEXT,
|
565 |
+
'label' => __( 'Widget-ID', 'dynamicconditions' ),
|
566 |
+
'render_type' => $renderType,
|
567 |
+
'description' => '<script>
|
568 |
+
let $dcWidgetIdInput = jQuery(\'.elementor-control-dynamicconditions_widget_id input\');
|
569 |
+
$dcWidgetIdInput.val(elementor.getCurrentElement().model.id);
|
570 |
+
$dcWidgetIdInput.attr(\'readonly\', true);
|
571 |
+
$dcWidgetIdInput.on(\'focus click\', function() { this.select();document.execCommand(\'copy\'); });
|
572 |
+
</script>',
|
573 |
+
]
|
574 |
+
);
|
575 |
+
|
576 |
+
$element->add_control(
|
577 |
+
'dynamicconditions_hr5',
|
578 |
+
[
|
579 |
+
'type' => Controls_Manager::DIVIDER,
|
580 |
+
'style' => 'thick',
|
581 |
+
]
|
582 |
+
);
|
583 |
+
|
584 |
$element->add_control(
|
585 |
'dynamicconditions_debug',
|
586 |
[
|
589 |
'render_type' => $renderType,
|
590 |
]
|
591 |
);
|
592 |
+
|
593 |
$element->end_controls_section();
|
594 |
}
|
595 |
+
}
|
Admin/css/dynamic-conditions-admin.css
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
.elementor-control-dynamicconditions_dynamic .elementor-control-media__tools {
|
4 |
+
bottom: 0 !important;
|
5 |
+
}
|
6 |
+
|
7 |
+
.elementor-control-dynamicconditions_dynamic .elementor-control-media__tool,
|
8 |
+
.elementor-control-dynamicconditions_dynamic .elementor-control-media-upload-button {
|
9 |
+
display: none;
|
10 |
+
}
|
11 |
+
|
12 |
+
.elementor-control-dynamicconditions_dynamic .elementor-control-media__content {
|
13 |
+
height: 27px;
|
14 |
+
padding-bottom: 0 !important;
|
15 |
+
}
|
16 |
+
|
17 |
+
.elementor-control-dynamicconditions_dynamic .elementor-control-dynamic-switcher {
|
18 |
+
width: 100%;
|
19 |
+
}
|
Lib/DynamicConditions.php
CHANGED
@@ -148,8 +148,8 @@ class DynamicConditions {
|
|
148 |
$this->loader->addAction( 'elementor/element/popup/section_advanced/after_section_end', $pluginAdmin, 'addConditionFields', 10, 3 );
|
149 |
|
150 |
$this->loader->addAction( 'admin_notices', $pluginAdmin, 'addAdminNotices', 10, 3 );
|
151 |
-
|
152 |
-
|
153 |
}
|
154 |
|
155 |
/**
|
@@ -208,7 +208,7 @@ class DynamicConditions {
|
|
208 |
* @since 1.3.0
|
209 |
*/
|
210 |
public function setFooterStyleForPreview() {
|
211 |
-
if ( !Plugin::$instance->preview->is_preview_mode() ) {
|
212 |
return;
|
213 |
}
|
214 |
?>
|
148 |
$this->loader->addAction( 'elementor/element/popup/section_advanced/after_section_end', $pluginAdmin, 'addConditionFields', 10, 3 );
|
149 |
|
150 |
$this->loader->addAction( 'admin_notices', $pluginAdmin, 'addAdminNotices', 10, 3 );
|
151 |
+
$this->loader->addAction( 'admin_enqueue_scripts', $pluginAdmin, 'enqueueStyles' );
|
152 |
+
$this->loader->addAction( 'elementor/editor/before_enqueue_styles', $pluginAdmin, 'enqueueStyles' );
|
153 |
}
|
154 |
|
155 |
/**
|
208 |
* @since 1.3.0
|
209 |
*/
|
210 |
public function setFooterStyleForPreview() {
|
211 |
+
if ( !class_exists('Elementor\Plugin') || !Plugin::$instance->preview->is_preview_mode() ) {
|
212 |
return;
|
213 |
}
|
214 |
?>
|
Public/DynamicConditionsPublic.php
CHANGED
@@ -62,6 +62,8 @@ class DynamicConditionsPublic {
|
|
62 |
|
63 |
private static $debugCssRendered = false;
|
64 |
|
|
|
|
|
65 |
/**
|
66 |
* Initialize the class and set its properties.
|
67 |
*
|
@@ -106,6 +108,8 @@ class DynamicConditionsPublic {
|
|
106 |
dynamicconditions_value2
|
107 |
dynamicconditions_parse_shortcodes
|
108 |
dynamicconditions_debug
|
|
|
|
|
109 |
_column_size
|
110 |
_inline_size';
|
111 |
|
@@ -314,6 +318,10 @@ class DynamicConditionsPublic {
|
|
314 |
$section->dynamicConditionIsHidden = true;
|
315 |
$section->dynamicConditionSettings = $settings;
|
316 |
|
|
|
|
|
|
|
|
|
317 |
ob_start();
|
318 |
}
|
319 |
|
@@ -331,15 +339,26 @@ class DynamicConditionsPublic {
|
|
331 |
|
332 |
$type = $section->get_type();
|
333 |
$settings = $section->dynamicConditionSettings;
|
|
|
|
|
334 |
|
335 |
if ( !empty( $settings['dynamicconditions_hideContentOnly'] ) ) {
|
336 |
// render wrapper
|
337 |
$section->before_render();
|
338 |
$section->after_render();
|
339 |
} else if ( $type == 'column' && $settings['dynamicconditions_resizeOtherColumns'] ) {
|
340 |
-
echo '<div class="dc-
|
|
|
|
|
|
|
|
|
341 |
}
|
342 |
|
|
|
|
|
|
|
|
|
|
|
343 |
echo "<!-- hidden $type -->";
|
344 |
}
|
345 |
|
@@ -522,6 +541,16 @@ class DynamicConditionsPublic {
|
|
522 |
$condition = in_array( $dynamicTagValue, explode( ',', $checkValue ) ) !== false;
|
523 |
$break = true;
|
524 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
526 |
|
527 |
return [
|
@@ -723,6 +752,10 @@ class DynamicConditionsPublic {
|
|
723 |
* @return string
|
724 |
*/
|
725 |
private function getMode() {
|
|
|
|
|
|
|
|
|
726 |
if ( !empty( Plugin::$instance->editor ) && Plugin::$instance->editor->is_edit_mode() ) {
|
727 |
return 'edit';
|
728 |
}
|
62 |
|
63 |
private static $debugCssRendered = false;
|
64 |
|
65 |
+
private $shortcodeTags;
|
66 |
+
|
67 |
/**
|
68 |
* Initialize the class and set its properties.
|
69 |
*
|
108 |
dynamicconditions_value2
|
109 |
dynamicconditions_parse_shortcodes
|
110 |
dynamicconditions_debug
|
111 |
+
dynamicconditions_hideOthers
|
112 |
+
dynamicconditions_hideWrapper
|
113 |
_column_size
|
114 |
_inline_size';
|
115 |
|
318 |
$section->dynamicConditionIsHidden = true;
|
319 |
$section->dynamicConditionSettings = $settings;
|
320 |
|
321 |
+
//prevent shortcodes from execution
|
322 |
+
$this->shortcodeTags = $GLOBALS['shortcode_tags'];
|
323 |
+
$GLOBALS['shortcode_tags'] = [];
|
324 |
+
|
325 |
ob_start();
|
326 |
}
|
327 |
|
339 |
|
340 |
$type = $section->get_type();
|
341 |
$settings = $section->dynamicConditionSettings;
|
342 |
+
// reset shortcode tags
|
343 |
+
$GLOBALS['shortcode_tags'] = $this->shortcodeTags;
|
344 |
|
345 |
if ( !empty( $settings['dynamicconditions_hideContentOnly'] ) ) {
|
346 |
// render wrapper
|
347 |
$section->before_render();
|
348 |
$section->after_render();
|
349 |
} else if ( $type == 'column' && $settings['dynamicconditions_resizeOtherColumns'] ) {
|
350 |
+
echo '<div class="dc-hidden-column" data-size="' . $settings['_column_size'] . '"></div>';
|
351 |
+
}
|
352 |
+
|
353 |
+
if ( !empty( $settings['dynamicconditions_hideWrapper'] ) ) {
|
354 |
+
echo '<div class="dc-hide-wrapper" data-selector="' . $settings['dynamicconditions_hideWrapper'] . '"></div>';
|
355 |
}
|
356 |
|
357 |
+
if ( !empty( $settings['dynamicconditions_hideOthers'] ) ) {
|
358 |
+
echo '<div class="dc-hide-others" data-selector="' . $settings['dynamicconditions_hideOthers'] . '"></div>';
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
echo "<!-- hidden $type -->";
|
363 |
}
|
364 |
|
541 |
$condition = in_array( $dynamicTagValue, explode( ',', $checkValue ) ) !== false;
|
542 |
$break = true;
|
543 |
break;
|
544 |
+
|
545 |
+
case 'in_array_contains':
|
546 |
+
foreach ( explode( ',', $checkValue ) as $toCheck ) {
|
547 |
+
$condition = strpos( $dynamicTagValue, $toCheck ) !== false;
|
548 |
+
if ( $condition ) {
|
549 |
+
break;
|
550 |
+
}
|
551 |
+
}
|
552 |
+
$break = true;
|
553 |
+
break;
|
554 |
}
|
555 |
|
556 |
return [
|
752 |
* @return string
|
753 |
*/
|
754 |
private function getMode() {
|
755 |
+
if ( !class_exists('Elementor\Plugin') ) {
|
756 |
+
return;
|
757 |
+
}
|
758 |
+
|
759 |
if ( !empty( Plugin::$instance->editor ) && Plugin::$instance->editor->is_edit_mode() ) {
|
760 |
return 'edit';
|
761 |
}
|
Public/js/dynamic-conditions-public.js
CHANGED
@@ -1,87 +1,86 @@
|
|
1 |
-
(function
|
2 |
'use strict';
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
* function.
|
11 |
-
*
|
12 |
-
* From here, you're able to define handlers for when the DOM is
|
13 |
-
* ready:
|
14 |
-
*
|
15 |
-
* $(function() {
|
16 |
-
*
|
17 |
-
* });
|
18 |
-
*
|
19 |
-
* Or when the window is loaded:
|
20 |
-
*
|
21 |
-
* $( window ).load(function() {
|
22 |
-
*
|
23 |
-
* });
|
24 |
-
*
|
25 |
-
* ...and so on.
|
26 |
-
*
|
27 |
-
* Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
|
28 |
-
* for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
|
29 |
-
* be doing this, we should try to minimize doing that in our own work.
|
30 |
-
*/
|
31 |
|
32 |
function resizeColumns() {
|
33 |
-
|
34 |
-
columns.each(function
|
35 |
-
column = $(column)
|
36 |
-
|
37 |
-
row = column.closest(
|
38 |
-
children = row.find(
|
39 |
-
rowSize = 0;
|
40 |
|
41 |
-
if (children.length === 0) {
|
42 |
return;
|
43 |
}
|
44 |
|
45 |
// get percent-width of row
|
46 |
-
children.
|
47 |
-
child
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
children.each(function
|
52 |
// resize columns
|
53 |
-
child = $(child)
|
54 |
-
|
55 |
newSize = childSize + (hiddenSize * (childSize / rowSize));
|
56 |
|
57 |
if (childSize < 100) {
|
58 |
-
child.css({width: newSize + '%'});
|
59 |
}
|
60 |
});
|
61 |
|
62 |
});
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
65 |
function resetColumns() {
|
66 |
-
|
67 |
-
columns.each(function
|
68 |
-
|
69 |
-
let row = column.closest('.elementor-row'),
|
70 |
-
children = row.find('> .elementor-column');
|
71 |
|
72 |
// reset width for recalc
|
73 |
-
children.css({width: ''});
|
74 |
});
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
$(window).on('resize', function
|
79 |
resetColumns();
|
80 |
resizeColumns();
|
81 |
});
|
82 |
|
83 |
-
$(window).on('elementor/frontend/init', function
|
84 |
resetColumns();
|
85 |
resizeColumns();
|
|
|
|
|
86 |
});
|
87 |
})(jQuery);
|
1 |
+
(function($) {
|
2 |
'use strict';
|
3 |
|
4 |
+
const dcHiddenSelector = '.dc-hidden-column',
|
5 |
+
dcHideWrapperSelector = '.dc-hide-wrapper',
|
6 |
+
dcHideOthersSelector = '.dc-hide-others',
|
7 |
+
dcRowSelector = '.elementor-row,.elementor-container',
|
8 |
+
dcColumnSelector = '> .elementor-column';
|
9 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
function resizeColumns() {
|
12 |
+
const $columns = $(dcHiddenSelector);
|
13 |
+
$columns.each(function(index, column) {
|
14 |
+
const $column = $(column),
|
15 |
+
hiddenSize = parseFloat($column.data('size')),
|
16 |
+
$row = $column.closest(dcRowSelector),
|
17 |
+
$children = $row.find(dcColumnSelector);
|
|
|
18 |
|
19 |
+
if ($children.length === 0) {
|
20 |
return;
|
21 |
}
|
22 |
|
23 |
// get percent-width of row
|
24 |
+
const rowSize = $children.toArray().reduce(
|
25 |
+
(acc, child) => acc + calcRowWidth($(child), $row),
|
26 |
+
0
|
27 |
+
);
|
28 |
|
29 |
+
$children.each(function(cIndex, child) {
|
30 |
// resize columns
|
31 |
+
const $child = $(child),
|
32 |
+
childSize = calcRowWidth($child, $row),
|
33 |
newSize = childSize + (hiddenSize * (childSize / rowSize));
|
34 |
|
35 |
if (childSize < 100) {
|
36 |
+
$child.css({width: newSize + '%'});
|
37 |
}
|
38 |
});
|
39 |
|
40 |
});
|
41 |
}
|
42 |
|
43 |
+
function calcRowWidth($child, $row) {
|
44 |
+
return parseFloat($child.width() / $row.width() * 100);
|
45 |
+
}
|
46 |
+
|
47 |
function resetColumns() {
|
48 |
+
const $columns = $(dcHiddenSelector);
|
49 |
+
$columns.each(function(index, column) {
|
50 |
+
const $children = $(column).closest(dcRowSelector).find(dcColumnSelector);
|
|
|
|
|
51 |
|
52 |
// reset width for recalc
|
53 |
+
$children.css({width: ''});
|
54 |
});
|
55 |
}
|
56 |
|
57 |
+
function hideWrappers() {
|
58 |
+
const $elements = $(dcHideWrapperSelector);
|
59 |
+
$elements.each(function(index, element) {
|
60 |
+
const $element = $(element),
|
61 |
+
$wrapper = $element.closest($element.data('selector'));
|
62 |
+
$wrapper.css({display: 'none'});
|
63 |
+
});
|
64 |
+
}
|
65 |
+
|
66 |
+
function hideOthers() {
|
67 |
+
const $elements = $(dcHideOthersSelector);
|
68 |
+
$elements.each(function(index, element) {
|
69 |
+
const $element = $(element),
|
70 |
+
$toHide = $($element.data('selector'));
|
71 |
+
$toHide.css({display: 'none'});
|
72 |
+
});
|
73 |
+
}
|
74 |
|
75 |
+
$(window).on('resize', function() {
|
76 |
resetColumns();
|
77 |
resizeColumns();
|
78 |
});
|
79 |
|
80 |
+
$(window).on('elementor/frontend/init', function() {
|
81 |
resetColumns();
|
82 |
resizeColumns();
|
83 |
+
hideWrappers();
|
84 |
+
hideOthers();
|
85 |
});
|
86 |
})(jQuery);
|
README.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.rto.de
|
|
4 |
Tags: elementor, conditions, dynamic, fields, rto
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 7.0
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -50,11 +50,29 @@ Yes, the plugin supports date based conditions, for example current-date or post
|
|
50 |
= Can I show/hide elements for logged-in or logged-out users? =
|
51 |
Yes, you can set display conditions for logged in or logged out users. Selecting the "user information" dynamic-tag, and set it to "user ID". Now check if it is empty or not.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
== Screenshots ==
|
54 |
|
55 |
1. Widget options for conditions
|
56 |
|
57 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= 1.4.5 =
|
59 |
* Fix some issues with date-parsing
|
60 |
* Add option to disable date-parsing
|
4 |
Tags: elementor, conditions, dynamic, fields, rto
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 7.0
|
7 |
+
Tested up to: 5.7
|
8 |
+
Stable tag: 1.5.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
50 |
= Can I show/hide elements for logged-in or logged-out users? =
|
51 |
Yes, you can set display conditions for logged in or logged out users. Selecting the "user information" dynamic-tag, and set it to "user ID". Now check if it is empty or not.
|
52 |
|
53 |
+
= Are my elements only hidden or fully removed =
|
54 |
+
The elements will be fully removed from source code, like they are not existing.
|
55 |
+
Only if you use the experts options to hide also wrappers or other elements, they will only be hidden with css.
|
56 |
+
|
57 |
+
= I´m missing some dynamic tags
|
58 |
+
We have developed an other plugin which provides some useful tags.
|
59 |
+
You can find it here:
|
60 |
+
https://wordpress.org/plugins/dynamictags/
|
61 |
+
|
62 |
+
|
63 |
== Screenshots ==
|
64 |
|
65 |
1. Widget options for conditions
|
66 |
|
67 |
== Changelog ==
|
68 |
+
= 1.5.0 =
|
69 |
+
* Add option to hide wrappers and other elements by selector (javascript only)
|
70 |
+
* Add new compare type "in_array_contains"
|
71 |
+
* Fix error when elementor is disabled
|
72 |
+
* Styling dynamic-tag field
|
73 |
+
* Prevent shortcode-execution on hidden elements
|
74 |
+
* Make condition value dynamic
|
75 |
+
|
76 |
= 1.4.5 =
|
77 |
* Fix some issues with date-parsing
|
78 |
* Add option to disable date-parsing
|
dynamic-conditions.php
CHANGED
@@ -22,7 +22,7 @@ use DynamicConditions\Lib\Deactivator;
|
|
22 |
* Plugin Name: DynamicConditions
|
23 |
* Plugin URI: https://github.com/RTO-Websites/dynamic-conditions
|
24 |
* Description: Activates conditions for dynamic tags to show/hides a widget.
|
25 |
-
* Version: 1.
|
26 |
* Author: RTO GmbH
|
27 |
* Author URI: https://www.rto.de
|
28 |
* License: GPL-2.0+
|
@@ -36,7 +36,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
36 |
die;
|
37 |
}
|
38 |
|
39 |
-
define( 'DynamicConditions_VERSION', '1.
|
40 |
|
41 |
define( 'DynamicConditions_DIR', str_replace( '\\', '/', __DIR__ ) );
|
42 |
define( 'DynamicConditions_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
|
22 |
* Plugin Name: DynamicConditions
|
23 |
* Plugin URI: https://github.com/RTO-Websites/dynamic-conditions
|
24 |
* Description: Activates conditions for dynamic tags to show/hides a widget.
|
25 |
+
* Version: 1.5.0
|
26 |
* Author: RTO GmbH
|
27 |
* Author URI: https://www.rto.de
|
28 |
* License: GPL-2.0+
|
36 |
die;
|
37 |
}
|
38 |
|
39 |
+
define( 'DynamicConditions_VERSION', '1.5.0' );
|
40 |
|
41 |
define( 'DynamicConditions_DIR', str_replace( '\\', '/', __DIR__ ) );
|
42 |
define( 'DynamicConditions_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
|
languages/dynamicconditions-de_DE.mo
CHANGED
Binary file
|
languages/dynamicconditions-de_DE.po
CHANGED
@@ -2,12 +2,12 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: dynamic-conditions\n"
|
4 |
"POT-Creation-Date: 2018-11-07 09:29+0100\n"
|
5 |
-
"PO-Revision-Date:
|
6 |
"Language-Team: \n"
|
7 |
"MIME-Version: 1.0\n"
|
8 |
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
"Content-Transfer-Encoding: 8bit\n"
|
10 |
-
"X-Generator: Poedit 2.
|
11 |
"X-Poedit-Basepath: .\n"
|
12 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
"X-Poedit-KeywordsList: __;_e\n"
|
@@ -146,3 +146,21 @@ msgstr "Verhindere Datums-Parsing"
|
|
146 |
|
147 |
msgid "Debug-Mode"
|
148 |
msgstr "Debug-Modus"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: dynamic-conditions\n"
|
4 |
"POT-Creation-Date: 2018-11-07 09:29+0100\n"
|
5 |
+
"PO-Revision-Date: 2021-04-02 12:43+0200\n"
|
6 |
"Language-Team: \n"
|
7 |
"MIME-Version: 1.0\n"
|
8 |
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"X-Generator: Poedit 2.4.1\n"
|
11 |
"X-Poedit-Basepath: .\n"
|
12 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
"X-Poedit-KeywordsList: __;_e\n"
|
146 |
|
147 |
msgid "Debug-Mode"
|
148 |
msgstr "Debug-Modus"
|
149 |
+
|
150 |
+
msgid "Use comma-separated values, to check if dynamic-value contains one of each item."
|
151 |
+
msgstr "Verwende Komma-getrennte Werte, um zu prüfen ob der Dynamic-Wert einen der einzelnem Werte enthält."
|
152 |
+
|
153 |
+
msgid "In array contains"
|
154 |
+
msgstr "Im Array enthält"
|
155 |
+
|
156 |
+
msgid "Hide wrapper"
|
157 |
+
msgstr "Verstecke Wrapper"
|
158 |
+
|
159 |
+
msgid "Hide other elements"
|
160 |
+
msgstr "Verstecke andere Elemente"
|
161 |
+
|
162 |
+
msgid "Will hide a parent matching the selector."
|
163 |
+
msgstr "Versteckt ein Elternelement, welches auf den Selector zutrifft."
|
164 |
+
|
165 |
+
msgid "Will hide all other elements matching the selector."
|
166 |
+
msgstr "Versteckt alle elements auf welche der Selectior zutrifft."
|