Dynamic Conditions - Version 1.4.6

Version Description

Download this release

Release Info

Developer rtowebsites
Plugin Icon wp plugin Dynamic Conditions
Version 1.4.6
Comparing to
See all releases

Version 1.4.6

Files changed (47) hide show
  1. Admin/DynamicConditionsAdmin.php +487 -0
  2. Admin/index.php +1 -0
  3. Admin/js/dynamic-conditions-admin.js +32 -0
  4. Admin/js/index.php +1 -0
  5. Admin/partials/dynamic-conditions-admin-display.php +22 -0
  6. Admin/partials/index.php +1 -0
  7. LICENSE.txt +339 -0
  8. Legacy/Lib/DynamicConditionsDate.php +18 -0
  9. Legacy/Lib/index.php +1 -0
  10. Legacy/index.php +1 -0
  11. Lib/Activator.php +43 -0
  12. Lib/Date.php +229 -0
  13. Lib/Deactivator.php +43 -0
  14. Lib/DynamicConditions.php +270 -0
  15. Lib/DynamicTags/NumberPostsTag.php +89 -0
  16. Lib/DynamicTags/index.php +1 -0
  17. Lib/I18n.php +70 -0
  18. Lib/Loader.php +136 -0
  19. Lib/index.php +1 -0
  20. Public/DynamicConditionsPublic.php +749 -0
  21. Public/css/debug.css +55 -0
  22. Public/css/dynamic-conditions-public.css +4 -0
  23. Public/css/index.php +1 -0
  24. Public/index.php +1 -0
  25. Public/js/dynamic-conditions-public.js +87 -0
  26. Public/js/index.php +1 -0
  27. Public/partials/debug.php +73 -0
  28. Public/partials/dynamic-conditions-public-display.php +22 -0
  29. Public/partials/index.php +1 -0
  30. README.txt +112 -0
  31. composer.json +12 -0
  32. dynamic-conditions.php +70 -0
  33. index.php +1 -0
  34. languages/dynamicconditions-de_DE.mo +0 -0
  35. languages/dynamicconditions-de_DE.po +148 -0
  36. languages/dynamicconditions.pot +103 -0
  37. languages/index.php +1 -0
  38. uninstall.php +31 -0
  39. vendor/autoload.php +7 -0
  40. vendor/composer/ClassLoader.php +445 -0
  41. vendor/composer/LICENSE +21 -0
  42. vendor/composer/autoload_classmap.php +9 -0
  43. vendor/composer/autoload_namespaces.php +9 -0
  44. vendor/composer/autoload_psr4.php +12 -0
  45. vendor/composer/autoload_real.php +52 -0
  46. vendor/composer/autoload_static.php +44 -0
  47. vendor/composer/installed.json +1 -0
Admin/DynamicConditionsAdmin.php ADDED
@@ -0,0 +1,487 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Admin;
4
+
5
+ use Elementor\Controls_Manager;
6
+ use Elementor\Modules\DynamicTags\Module;
7
+ use DynamicConditions\Lib\Date;
8
+
9
+ /**
10
+ * The admin-specific functionality of the plugin.
11
+ *
12
+ * @link https://www.rto.de
13
+ * @since 1.0.0
14
+ *
15
+ * @package DynamicConditions
16
+ * @subpackage DynamicConditions/admin
17
+ */
18
+
19
+ // If this file is called directly, abort.
20
+ if ( !defined( 'ABSPATH' ) ) {
21
+ die;
22
+ }
23
+
24
+ /**
25
+ * The admin-specific functionality of the plugin.
26
+ *
27
+ * Defines the plugin name, version, and two examples hooks for how to
28
+ * enqueue the admin-specific stylesheet and JavaScript.
29
+ *
30
+ * @package DynamicConditions
31
+ * @subpackage DynamicConditions/admin
32
+ * @author RTO GmbH <kundenhomepage@rto.de>
33
+ */
34
+ class DynamicConditionsAdmin {
35
+ /**
36
+ * The ID of this plugin.
37
+ *
38
+ * @since 1.0.0
39
+ * @access private
40
+ * @var string $pluginName The ID of this plugin.
41
+ */
42
+ private $pluginName;
43
+
44
+ /**
45
+ * The version of this plugin.
46
+ *
47
+ * @since 1.0.0
48
+ * @access private
49
+ * @var string $version The current version of this plugin.
50
+ */
51
+ private $version;
52
+
53
+ /**
54
+ * Initialize the class and set its properties.
55
+ *
56
+ * @param string $pluginName The name of this plugin.
57
+ * @param string $version The version of this plugin.
58
+ * @since 1.0.0
59
+ */
60
+ public function __construct( $pluginName, $version ) {
61
+
62
+ $this->pluginName = $pluginName;
63
+ $this->version = $version;
64
+
65
+ }
66
+
67
+
68
+ /**
69
+ * Register the stylesheets for the admin area.
70
+ *
71
+ * @since 1.0.0
72
+ */
73
+ public function enqueueStyles() {
74
+
75
+ wp_enqueue_style( $this->pluginName, DynamicConditions_URL . '/Admin/css/dynamic-conditions-admin.css', [], $this->version, 'all' );
76
+
77
+ }
78
+
79
+ public function addAdminNotices() {
80
+ $message = '';
81
+ $class = 'notice notice-error';
82
+
83
+ if ( !defined( 'ELEMENTOR_VERSION' ) && !defined( 'ELEMENTOR_PRO_VERSION' ) ) {
84
+ $message = __( 'Elementor and Elementor Pro not installed.', 'dynamic-conditions' );
85
+ } else if ( !defined( 'ELEMENTOR_PRO_VERSION' ) ) {
86
+ $message = __( 'Elementor Pro not installed.', 'dynamic-conditions' );
87
+ } else if ( !defined( 'ELEMENTOR_VERSION' ) ) {
88
+ $message = __( 'Elementor not installed.', 'dynamic-conditions' );
89
+ }
90
+
91
+
92
+ if ( empty( $message ) ) {
93
+ return;
94
+ }
95
+ printf( '<div class="%1$s"><p>DynamicConditions: %2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
96
+ }
97
+
98
+
99
+ /**
100
+ * Creates section for dynamic conditions in elementor-widgets
101
+ *
102
+ * @param $element
103
+ * @param $section_id
104
+ * @param $args
105
+ */
106
+ public function addConditionFields( $element, $section_id = null, $args = null ) {
107
+ $valueCondition = [ 'equal', 'not_equal', 'contains', 'not_contains', 'less', 'greater', 'between', 'in_array' ];
108
+ $allCondition = [ 'equal', 'not_equal', 'contains', 'not_contains', 'less', 'greater', 'between', 'empty', 'not_empty' ];
109
+ $type = 'element';
110
+ $renderType = 'ui';
111
+ if ( !empty( $element ) && is_object( $element ) && method_exists( $element, 'get_type' ) ) {
112
+ $type = $element->get_type();
113
+ }
114
+
115
+ $categories = [
116
+ Module::BASE_GROUP,
117
+ Module::TEXT_CATEGORY,
118
+ Module::URL_CATEGORY,
119
+ Module::GALLERY_CATEGORY,
120
+ Module::IMAGE_CATEGORY,
121
+ Module::MEDIA_CATEGORY,
122
+ Module::POST_META_CATEGORY,
123
+ ];
124
+
125
+ if ( defined( Module::class . '::COLOR_CATEGORY' ) ) {
126
+ $categories[] = Module::COLOR_CATEGORY;
127
+ }
128
+
129
+ $element->start_controls_section(
130
+ 'dynamicconditions_section',
131
+ [
132
+ 'tab' => Controls_Manager::TAB_ADVANCED,
133
+ 'label' => __( 'Dynamic Conditions', 'dynamicconditions' ),
134
+ ]
135
+ );
136
+
137
+ $element->add_control(
138
+ 'dynamicconditions_dynamic',
139
+ [
140
+ 'label' => __( 'Dynamic Tag', 'dynamiccondtions' ),
141
+ 'type' => Controls_Manager::MEDIA,
142
+ 'dynamic' => [
143
+ 'active' => true,
144
+ 'categories' => $categories,
145
+ ],
146
+ 'render_type' => $renderType,
147
+ 'placeholder' => __( 'Select condition field', 'dynamiccondtions' ),
148
+ ]
149
+ );
150
+
151
+ $element->add_control(
152
+ 'dynamicconditions_visibility',
153
+ [
154
+ 'label' => __( 'Show/Hide', 'dynamicconditions' ),
155
+ 'type' => Controls_Manager::SELECT,
156
+ 'default' => 'hide',
157
+ 'options' => [
158
+ 'show' => __( 'Show when condition met', 'dynamicconditions' ),
159
+ 'hide' => __( 'Hide when condition met', 'dynamicconditions' ),
160
+ ],
161
+ 'render_type' => $renderType,
162
+ 'separator' => 'before',
163
+ ]
164
+ );
165
+
166
+ $element->add_control(
167
+ 'dynamicconditions_condition',
168
+ [
169
+ 'label' => __( 'Condition', 'dynamicconditions' ),
170
+ 'type' => Controls_Manager::SELECT2,
171
+ 'multiple' => false,
172
+ 'label_block' => true,
173
+ 'options' => [
174
+ 'equal' => __( 'Is equal to', 'dynamicconditions' ),
175
+ 'not_equal' => __( 'Is not equal to', 'dynamicconditions' ),
176
+ 'contains' => __( 'Contains', 'dynamicconditions' ),
177
+ 'not_contains' => __( 'Does not contain', 'dynamicconditions' ),
178
+ 'empty' => __( 'Is empty', 'dynamicconditions' ),
179
+ 'not_empty' => __( 'Is not empty', 'dynamicconditions' ),
180
+ 'between' => __( 'Between', 'dynamicconditions' ),
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
+
187
+ 'prefix_class' => 'dc-has-condition dc-condition-',
188
+ 'render_type' => 'template',
189
+ ]
190
+ );
191
+
192
+ $element->add_control(
193
+ 'dynamicconditions_type',
194
+ [
195
+ 'label' => __( 'Compare Type', 'dynamicconditions' ),
196
+ 'type' => Controls_Manager::SELECT,
197
+ 'multiple' => false,
198
+ 'label_block' => true,
199
+ 'options' => [
200
+ 'default' => __( 'Text', 'dynamicconditions' ),
201
+ 'date' => __( 'Date', 'dynamicconditions' ),
202
+ 'days' => __( 'Weekdays', 'dynamicconditions' ),
203
+ 'months' => __( 'Months', 'dynamicconditions' ),
204
+ 'strtotime' => __( 'String to time', 'dynamicconditions' ),
205
+ ],
206
+ 'default' => 'default',
207
+ 'render_type' => $renderType,
208
+ 'description' => __( 'Select what do you want to compare', 'dynamicconditions' ),
209
+ 'condition' => [
210
+ 'dynamicconditions_condition' => $valueCondition,
211
+ ],
212
+ ]
213
+ );
214
+
215
+ $element->add_control(
216
+ 'dynamicconditions_value',
217
+ [
218
+ 'type' => Controls_Manager::TEXTAREA,
219
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
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' ],
226
+ ],
227
+ ]
228
+ );
229
+
230
+ $element->add_control(
231
+ 'dynamicconditions_value2',
232
+ [
233
+ 'type' => Controls_Manager::TEXTAREA,
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' ],
240
+ 'dynamicconditions_type' => [ 'default', 'strtotime' ],
241
+ ],
242
+ ]
243
+ );
244
+
245
+
246
+ $element->add_control(
247
+ 'dynamicconditions_date_value',
248
+ [
249
+ 'type' => Controls_Manager::DATE_TIME,
250
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
251
+ 'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
252
+ 'render_type' => $renderType,
253
+
254
+ 'condition' => [
255
+ 'dynamicconditions_condition' => $valueCondition,
256
+ 'dynamicconditions_type' => 'date',
257
+ ],
258
+ ]
259
+ );
260
+
261
+ $element->add_control(
262
+ 'dynamicconditions_date_value2',
263
+ [
264
+ 'type' => Controls_Manager::DATE_TIME,
265
+ 'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
266
+ 'description' => __( 'Add a second condition value, if between is selected', 'dynamicconditions' ),
267
+ 'render_type' => $renderType,
268
+ 'condition' => [
269
+ 'dynamicconditions_condition' => [ 'between' ],
270
+ 'dynamicconditions_type' => 'date',
271
+ ],
272
+ ]
273
+ );
274
+
275
+ $element->add_control(
276
+ 'dynamicconditions_day_array_value',
277
+ [
278
+ 'type' => Controls_Manager::SELECT2,
279
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
280
+ 'render_type' => $renderType,
281
+ 'condition' => [
282
+ 'dynamicconditions_condition' => [ 'in_array' ],
283
+ 'dynamicconditions_type' => 'days',
284
+ ],
285
+ 'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
286
+ 'options' => Date::getDaysTranslated(),
287
+ 'multiple' => true,
288
+ ]
289
+ );
290
+ $element->add_control(
291
+ 'dynamicconditions_day_value',
292
+ [
293
+ 'type' => Controls_Manager::SELECT,
294
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
295
+ 'render_type' => $renderType,
296
+ 'condition' => [
297
+ 'dynamicconditions_condition' => array_diff( $valueCondition, [ 'in_array' ] ),
298
+ 'dynamicconditions_type' => 'days',
299
+ ],
300
+ 'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
301
+ 'options' => Date::getDaysTranslated(),
302
+ ]
303
+ );
304
+
305
+ $element->add_control(
306
+ 'dynamicconditions_day_value2',
307
+ [
308
+ 'type' => Controls_Manager::SELECT,
309
+ 'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
310
+ 'render_type' => $renderType,
311
+ 'condition' => [
312
+ 'dynamicconditions_condition' => [ 'between' ],
313
+ 'dynamicconditions_type' => 'days',
314
+ ],
315
+ 'description' => __( 'Add a second condition value, if between is selected', 'dynamicconditions' ),
316
+ 'options' => Date::getDaysTranslated(),
317
+ ]
318
+ );
319
+
320
+ $element->add_control(
321
+ 'dynamicconditions_month_array_value',
322
+ [
323
+ 'type' => Controls_Manager::SELECT2,
324
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
325
+ 'render_type' => $renderType,
326
+ 'condition' => [
327
+ 'dynamicconditions_condition' => [ 'in_array' ],
328
+ 'dynamicconditions_type' => 'months',
329
+ ],
330
+ 'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
331
+ 'options' => Date::getMonthsTranslated(),
332
+ 'multiple' => true,
333
+ ]
334
+ );
335
+
336
+ $element->add_control(
337
+ 'dynamicconditions_month_value',
338
+ [
339
+ 'type' => Controls_Manager::SELECT,
340
+ 'label' => __( 'Conditional value', 'dynamicconditions' ),
341
+ 'render_type' => $renderType,
342
+ 'condition' => [
343
+ 'dynamicconditions_condition' => array_diff( $valueCondition, [ 'in_array' ] ),
344
+ 'dynamicconditions_type' => 'months',
345
+ ],
346
+ 'description' => __( 'Add your conditional value to compare here.', 'dynamicconditions' ),
347
+ 'options' => Date::getMonthsTranslated(),
348
+ ]
349
+ );
350
+
351
+ $element->add_control(
352
+ 'dynamicconditions_month_value2',
353
+ [
354
+ 'type' => Controls_Manager::SELECT,
355
+ 'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
356
+ 'render_type' => $renderType,
357
+ 'condition' => [
358
+ 'dynamicconditions_condition' => [ 'between' ],
359
+ 'dynamicconditions_type' => 'months',
360
+ ],
361
+ 'description' => __( 'Add a second condition value, if between is selected', 'dynamicconditions' ),
362
+ 'options' => Date::getMonthsTranslated(),
363
+ ]
364
+ );
365
+
366
+
367
+ $element->add_control(
368
+ 'dynamicconditions_in_array_description',
369
+ [
370
+ 'type' => Controls_Manager::RAW_HTML,
371
+ 'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
372
+ 'render_type' => $renderType,
373
+ 'condition' => [
374
+ 'dynamicconditions_condition' => [ 'in_array' ],
375
+ ],
376
+ 'show_label' => false,
377
+ 'raw' => __( 'Use comma-separated values, to check if dynamic-value is equal with one of each item.', 'dynamicconditions' ),
378
+ ]
379
+ );
380
+
381
+ $languageArray = explode( '_', get_locale() );
382
+ $language = array_shift( $languageArray );
383
+ $element->add_control(
384
+ 'dynamicconditions_date_description',
385
+ [
386
+ 'type' => Controls_Manager::RAW_HTML,
387
+ 'label' => __( 'Conditional value', 'dynamicconditions' ) . ' 2',
388
+ 'render_type' => $renderType,
389
+ 'condition' => [
390
+ 'dynamicconditions_condition' => $valueCondition,
391
+ 'dynamicconditions_type' => 'strtotime',
392
+ ],
393
+ 'show_label' => false,
394
+ 'raw' => '<div class="elementor-control-field-description">'
395
+ . '<a href="https://php.net/manual/' . $language . '/function.strtotime.php" target="_blank">'
396
+ . __( 'Supported Date and Time Formats', 'dynamicconditions' ) . '</a></div>',
397
+ ]
398
+ );
399
+
400
+ $element->add_control(
401
+ 'dynamicconditions_hr',
402
+ [
403
+ 'type' => Controls_Manager::DIVIDER,
404
+ 'style' => 'thick',
405
+ 'condition' => [
406
+ 'dynamicconditions_condition' => $valueCondition,
407
+ ],
408
+ ]
409
+ );
410
+
411
+ $element->add_control(
412
+ 'dynamicconditions_hideContentOnly',
413
+ [
414
+ 'type' => Controls_Manager::SWITCHER,
415
+ 'label' => __( 'Hide only content', 'dynamicconditions' ),
416
+ 'description' => __( 'If checked, only the inner content will be hidden, so you will see an empty section', 'dynamicconditions' ),
417
+ 'return_value' => 'on',
418
+ 'render_type' => $renderType,
419
+ 'condition' => [
420
+ 'dynamicconditions_condition' => $allCondition,
421
+ ],
422
+ ]
423
+ );
424
+
425
+ if ( $type === 'column' ) {
426
+ $element->add_control(
427
+ 'dynamicconditions_resizeOtherColumns',
428
+ [
429
+ 'type' => Controls_Manager::SWITCHER,
430
+ 'label' => __( 'Resize other columns', 'dynamicconditions' ),
431
+ 'render_type' => $renderType,
432
+ 'condition' => [
433
+ 'dynamicconditions_condition' => $allCondition,
434
+ 'dynamicconditions_hideContentOnly!' => 'on',
435
+ ],
436
+ 'return_value' => 'on',
437
+ ]
438
+ );
439
+ }
440
+
441
+
442
+ $element->add_control(
443
+ 'dynamicconditions_headline_expert',
444
+ [
445
+ 'label' => __( 'Expert', 'dynamicconditions' ),
446
+ 'type' => Controls_Manager::HEADING,
447
+ 'separator' => 'before',
448
+ ]
449
+ );
450
+
451
+ $element->add_control(
452
+ 'dynamicconditions_parse_shortcodes',
453
+ [
454
+ 'type' => Controls_Manager::SWITCHER,
455
+ 'label' => __( 'Parse shortcodes', 'dynamicconditions' ),
456
+ 'render_type' => $renderType,
457
+ ]
458
+ );
459
+
460
+ $element->add_control(
461
+ 'dynamicconditions_prevent_date_parsing',
462
+ [
463
+ 'type' => Controls_Manager::SWITCHER,
464
+ 'label' => __( 'Prevent date parsing', 'dynamicconditions' ),
465
+ 'render_type' => $renderType,
466
+ ]
467
+ );
468
+
469
+ $element->add_control(
470
+ 'dynamicconditions_hr3',
471
+ [
472
+ 'type' => Controls_Manager::DIVIDER,
473
+ 'style' => 'thick',
474
+ ]
475
+ );
476
+
477
+ $element->add_control(
478
+ 'dynamicconditions_debug',
479
+ [
480
+ 'type' => Controls_Manager::SWITCHER,
481
+ 'label' => __( 'Debug-Mode', 'dynamicconditions' ),
482
+ 'render_type' => $renderType,
483
+ ]
484
+ );
485
+ $element->end_controls_section();
486
+ }
487
+ }
Admin/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Admin/js/dynamic-conditions-admin.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $ ) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * All of the code for your admin-specific JavaScript source
6
+ * should reside in this file.
7
+ *
8
+ * Note that this assume you're going to use jQuery, so it prepares
9
+ * the $ function reference to be used within the scope of this
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
+ })( jQuery );
Admin/js/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Admin/partials/dynamic-conditions-admin-display.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a admin area view for the plugin
5
+ *
6
+ * This file is used to markup the admin-facing aspects of the plugin.
7
+ *
8
+ * @link https://www.rto.de
9
+ * @since 1.0.0
10
+ *
11
+ * @package DynamicConditions
12
+ * @subpackage DynamicConditions/admin/partials
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ ?>
21
+
22
+ <!-- This file should primarily consist of HTML with a little bit of PHP. -->
Admin/partials/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
LICENSE.txt ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
Legacy/Lib/DynamicConditionsDate.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Lib;
4
+
5
+ use DynamicConditions\Lib\Date;
6
+
7
+ // If this file is called directly, abort.
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ die;
10
+ }
11
+
12
+ /**
13
+ * @deprecated Will be removed in future updates. Use DynamicTag\Lib\Date instead.
14
+ * @package Lib
15
+ */
16
+ class DynamicConditionsDate extends Date {
17
+
18
+ }
Legacy/Lib/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Legacy/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Lib/Activator.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ /**
6
+ * Fired during plugin activation
7
+ *
8
+ * @link https://www.rto.de
9
+ * @since 1.0.0
10
+ *
11
+ * @package DynamicConditions
12
+ * @subpackage DynamicConditions/includes
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ /**
21
+ * Fired during plugin activation.
22
+ *
23
+ * This class defines all code necessary to run during the plugin's activation.
24
+ *
25
+ * @since 1.0.0
26
+ * @package DynamicConditions
27
+ * @subpackage DynamicConditions/includes
28
+ * @author RTO GmbH <kundenhomepage@rto.de>
29
+ */
30
+ class Activator {
31
+
32
+ /**
33
+ * Short Description. (use period)
34
+ *
35
+ * Long Description.
36
+ *
37
+ * @since 1.0.0
38
+ */
39
+ public static function activate() {
40
+
41
+ }
42
+
43
+ }
Lib/Date.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ // If this file is called directly, abort.
6
+ use WP_Post;
7
+
8
+ if ( !defined( 'ABSPATH' ) ) {
9
+ die;
10
+ }
11
+
12
+ /**
13
+ * Class Date
14
+ * @package DynamicConditions\Lib
15
+ */
16
+ class Date {
17
+
18
+ /**
19
+ * Filter date-output from date_i18n() to return always a timestamp
20
+ *
21
+ * @param string $formatedDate Formatted date string.
22
+ * @param string $reqFormat Format to display the date.
23
+ * @param int $unixTimestamp Unix timestamp.
24
+ * @param bool $gmt Whether to convert to GMT for time. Default false.
25
+ * @return int Unix timestamp
26
+ */
27
+ public function filterDateI18n( $formatedDate, $reqFormat, $unixTimestamp, $gmt ) {
28
+ return $unixTimestamp;
29
+ }
30
+
31
+ /**
32
+ * Filters the date of a post to return a timestamp
33
+ *
34
+ * @param string|bool $theTime The formatted date or false if no post is found.
35
+ * @param string $dateFormat PHP date format. Defaults to value specified in
36
+ * 'date_format' option.
37
+ * @param WP_Post|null $post WP_Post object or null if no post is found.
38
+ *
39
+ * @return mixed
40
+ */
41
+ public function filterPostDate( $theTime, $dateFormat, $post ) {
42
+ if ( empty( $dateFormat ) ) {
43
+ $dateFormat = get_option( 'date_format' );
44
+ }
45
+
46
+ $date = \DateTime::createFromFormat( $dateFormat, self::unTranslateDate( $theTime ) );
47
+
48
+ if ( empty( $date)) {
49
+ $date = \DateTime::createFromFormat( $dateFormat, $theTime );
50
+ }
51
+
52
+ if ( empty( $date ) ) {
53
+ return $theTime;
54
+ }
55
+
56
+ return $date->getTimestamp();
57
+ }
58
+
59
+ /**
60
+ * Convert string to timestamp or return string if it´s already a timestamp
61
+ *
62
+ * @param $string
63
+ * @return int
64
+ */
65
+ public static function stringToTime( $string = '' ) {
66
+ $timestamp = $string;
67
+ $strToTime = strtotime( $string, time() );
68
+ if ( !empty( $strToTime ) && !self::isTimestamp( $timestamp ) ) {
69
+ $timestamp = $strToTime;
70
+ }
71
+
72
+ return intval( $timestamp );
73
+ }
74
+
75
+ /**
76
+ * @param string $string
77
+ * @return bool
78
+ */
79
+ public static function isTimestamp( $string ) {
80
+ if ( !is_numeric( $string ) ) {
81
+ return false;
82
+ }
83
+ try {
84
+ new \DateTime( '@' . $string );
85
+ } catch ( \Exception $e ) {
86
+ return false;
87
+ }
88
+ return true;
89
+ }
90
+
91
+ /**
92
+ * Untranslate a date-string to english date
93
+ *
94
+ * @param string $needle
95
+ * @param null $setLocale
96
+ * @return mixed|string
97
+ */
98
+ public static function unTranslateDate( $needle = '', $setLocale = null ) {
99
+ // get in translated lang
100
+ $translatedMonths = self::getMonthsTranslated();
101
+ $translatedDays = self::getDaysTranslated();
102
+
103
+ // get in english
104
+ $englishMonths = self::getMonths();
105
+ $englishDays = self::getDays();
106
+
107
+ // replace translated days/months with english ones
108
+ $needle = str_ireplace( $translatedDays, $englishDays, $needle );
109
+ $needle = str_ireplace( $translatedMonths, $englishMonths, $needle );
110
+
111
+ return $needle;
112
+ }
113
+
114
+ /**
115
+ * Get a list of months (january, february,...) in current language
116
+ *
117
+ * @return array
118
+ */
119
+ public static function getMonthsTranslated() {
120
+ $monthList = [];
121
+ // translate monthlist by wordpress-lang
122
+ $monthList[1] = __( 'January' );
123
+ $monthList[2] = __( 'February' );
124
+ $monthList[3] = __( 'March' );
125
+ $monthList[4] = __( 'April' );
126
+ $monthList[5] = __( 'May' );
127
+ $monthList[6] = __( 'June' );
128
+ $monthList[7] = __( 'July' );
129
+ $monthList[8] = __( 'August' );
130
+ $monthList[9] = __( 'September' );
131
+ $monthList[10] = __( 'October' );
132
+ $monthList[11] = __( 'November' );
133
+ $monthList[12] = __( 'December' );
134
+
135
+ return $monthList;
136
+ }
137
+
138
+ /**
139
+ * Get a list of months (january, february,...)
140
+ *
141
+ * @return array
142
+ */
143
+ private static function getMonths() {
144
+ $monthList = [];
145
+ $monthList[1] = 'January';
146
+ $monthList[2] = 'February';
147
+ $monthList[3] = 'March';
148
+ $monthList[4] = 'April';
149
+ $monthList[5] = 'May';
150
+ $monthList[6] = 'June';
151
+ $monthList[7] = 'July';
152
+ $monthList[8] = 'August';
153
+ $monthList[9] = 'September';
154
+ $monthList[10] = 'October';
155
+ $monthList[11] = 'November';
156
+ $monthList[12] = 'December';
157
+
158
+ return $monthList;
159
+ }
160
+
161
+ /**
162
+ * Get a list of days (monday, tuesday,...) in current language
163
+ *
164
+ * @return array
165
+ */
166
+ public static function getDaysTranslated() {
167
+ $dayList = [];
168
+
169
+ // translate by wordpress-lang
170
+ $dayList[1] = __( 'Monday' );
171
+ $dayList[2] = __( 'Tuesday' );
172
+ $dayList[3] = __( 'Wednesday' );
173
+ $dayList[4] = __( 'Thursday' );
174
+ $dayList[5] = __( 'Friday' );
175
+ $dayList[6] = __( 'Saturday' );
176
+ $dayList[7] = __( 'Sunday' );
177
+
178
+ return $dayList;
179
+ }
180
+
181
+ /**
182
+ * Get a list of days (monday, tuesday,...)
183
+ *
184
+ * @return array
185
+ */
186
+ private static function getDays() {
187
+ $dayList = [];
188
+ $dayList[1] = 'Monday';
189
+ $dayList[2] = 'Tuesday';
190
+ $dayList[3] = 'Wednesday';
191
+ $dayList[4] = 'Thursday';
192
+ $dayList[5] = 'Friday';
193
+ $dayList[6] = 'Saturday';
194
+ $dayList[7] = 'Sunday';
195
+
196
+ return $dayList;
197
+ }
198
+
199
+ /**
200
+ * Sets a local
201
+ * Fix issue with too long locales returned by setLocale(LC_ALL, 0)
202
+ *
203
+ * @param $locale
204
+ */
205
+ public static function setLocale( $locale ) {
206
+ $localeSettings = explode( ";", $locale );
207
+
208
+ foreach ( $localeSettings as $localeSetting ) {
209
+ if ( strpos( $localeSetting, "=" ) !== false ) {
210
+ $categorylocale = explode( "=", $localeSetting );
211
+ $category = $categorylocale[0];
212
+ $locale = $categorylocale[1];
213
+ } else {
214
+ $category = LC_ALL;
215
+ $locale = $localeSetting;
216
+ }
217
+
218
+ if ( is_string( $category ) && defined( $category ) ) {
219
+ $category = constant( $category );
220
+ }
221
+
222
+ if ( !is_integer( $category ) ) {
223
+ continue;
224
+ }
225
+
226
+ setlocale( $category, $locale );
227
+ }
228
+ }
229
+ }
Lib/Deactivator.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ /**
6
+ * Fired during plugin deactivation
7
+ *
8
+ * @link https://www.rto.de
9
+ * @since 1.0.0
10
+ *
11
+ * @package DynamicConditions
12
+ * @subpackage DynamicConditions/includes
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ /**
21
+ * Fired during plugin deactivation.
22
+ *
23
+ * This class defines all code necessary to run during the plugin's deactivation.
24
+ *
25
+ * @since 1.0.0
26
+ * @package DynamicConditions
27
+ * @subpackage DynamicConditions/includes
28
+ * @author RTO GmbH <kundenhomepage@rto.de>
29
+ */
30
+ class Deactivator {
31
+
32
+ /**
33
+ * Short Description. (use period)
34
+ *
35
+ * Long Description.
36
+ *
37
+ * @since 1.0.0
38
+ */
39
+ public static function deactivate() {
40
+
41
+ }
42
+
43
+ }
Lib/DynamicConditions.php ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ use DynamicConditions\Admin\DynamicConditionsAdmin;
6
+ use Elementor\Plugin;
7
+ use DynamicConditions\Lib\DynamicTags\NumberPostsTag;
8
+ use DynamicConditions\Pub\DynamicConditionsPublic;
9
+
10
+ /**
11
+ * The file that defines the core plugin class
12
+ *
13
+ * A class definition that includes attributes and functions used across both the
14
+ * public-facing side of the site and the admin area.
15
+ *
16
+ * @link https://www.rto.de
17
+ * @since 1.0.0
18
+ *
19
+ * @package DynamicConditions
20
+ * @subpackage DynamicConditions/includes
21
+ */
22
+
23
+ // If this file is called directly, abort.
24
+ if ( ! defined( 'ABSPATH' ) ) {
25
+ die;
26
+ }
27
+
28
+ /**
29
+ * The core plugin class.
30
+ *
31
+ * This is used to define internationalization, admin-specific hooks, and
32
+ * public-facing site hooks.
33
+ *
34
+ * Also maintains the unique identifier of this plugin as well as the current
35
+ * version of the plugin.
36
+ *
37
+ * @since 1.0.0
38
+ * @package DynamicConditions
39
+ * @subpackage DynamicConditions/includes
40
+ * @author RTO GmbH <kundenhomepage@rto.de>
41
+ */
42
+ class DynamicConditions {
43
+
44
+ /**
45
+ * The loader that's responsible for maintaining and registering all hooks that power
46
+ * the plugin.
47
+ *
48
+ * @since 1.0.0
49
+ * @access protected
50
+ * @var Loader $loader Maintains and registers all hooks for the plugin.
51
+ */
52
+ protected $loader;
53
+
54
+ /**
55
+ * The unique identifier of this plugin.
56
+ *
57
+ * @since 1.0.0
58
+ * @access protected
59
+ * @var string $pluginName The string used to uniquely identify this plugin.
60
+ */
61
+ protected $pluginName;
62
+
63
+ /**
64
+ * The current version of the plugin.
65
+ *
66
+ * @since 1.0.0
67
+ * @access protected
68
+ * @var string $version The current version of the plugin.
69
+ */
70
+ protected $version;
71
+
72
+ /**
73
+ * Define the core functionality of the plugin.
74
+ *
75
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
76
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
77
+ * the public-facing side of the site.
78
+ *
79
+ * @since 1.0.0
80
+ */
81
+ public function __construct() {
82
+ $this->pluginName = 'dynamic-conditions';
83
+ $this->version = DynamicConditions_VERSION;
84
+
85
+ $this->loadDependencies();
86
+ $this->setLocale();
87
+
88
+ $this->defineAdminHooks();
89
+ $this->definePublicHooks();
90
+ $this->defineElementorHooks();
91
+
92
+ }
93
+
94
+ /**
95
+ * Load the required dependencies for this plugin.
96
+ *
97
+ * Include the following files that make up the plugin:
98
+ *
99
+ * - DynamicConditionsLoader. Orchestrates the hooks of the plugin.
100
+ * - DynamicConditionsI18n. Defines internationalization functionality.
101
+ * - DynamicConditionsAdmin. Defines all hooks for the admin area.
102
+ * - DynamicConditionsPublic. Defines all hooks for the public side of the site.
103
+ *
104
+ * Create an instance of the loader which will be used to register the hooks
105
+ * with WordPress.
106
+ *
107
+ * @since 1.0.0
108
+ * @access private
109
+ */
110
+ private function loadDependencies() {
111
+
112
+ $this->loader = new Loader();
113
+
114
+ }
115
+
116
+ /**
117
+ * Define the locale for this plugin for internationalization.
118
+ *
119
+ * Uses the DynamicConditionsI18n class in order to set the domain and to register the hook
120
+ * with WordPress.
121
+ *
122
+ * @since 1.0.0
123
+ * @access private
124
+ */
125
+ private function setLocale() {
126
+
127
+ $pluginI18n = new I18n();
128
+ $pluginI18n->setDomain( 'dynamicconditions' );
129
+
130
+ $this->loader->addAction( 'plugins_loaded', $pluginI18n, 'loadPluginTextdomain' );
131
+
132
+ }
133
+
134
+ /**
135
+ * Register all of the hooks related to the admin area functionality
136
+ * of the plugin.
137
+ *
138
+ * @since 1.0.0
139
+ * @access private
140
+ */
141
+ private function defineAdminHooks() {
142
+ $pluginAdmin = new DynamicConditionsAdmin( $this->getDynamicConditions(), $this->getVersion() );
143
+
144
+ $this->loader->addAction( 'elementor/element/column/section_advanced/after_section_end', $pluginAdmin, 'addConditionFields', 10, 3 );
145
+ $this->loader->addAction( 'elementor/element/section/section_advanced/after_section_end', $pluginAdmin, 'addConditionFields', 10, 3 );
146
+ $this->loader->addAction( 'elementor/element/common/_section_style/after_section_end', $pluginAdmin, 'addConditionFields', 10, 3 );
147
+
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
+ /**
156
+ * Register all of the hooks related to the public-facing functionality
157
+ * of the plugin.
158
+ *
159
+ * @since 1.0.0
160
+ * @access private
161
+ */
162
+ private function definePublicHooks() {
163
+ $pluginPublic = new DynamicConditionsPublic( $this->getDynamicConditions(), $this->getVersion() );
164
+
165
+ $this->loader->addAction( 'wp_enqueue_scripts', $pluginPublic, 'enqueueScripts' );
166
+
167
+ // filter widgets
168
+ $this->loader->addAction( "elementor/frontend/widget/before_render", $pluginPublic, 'filterSectionContentBefore', 10, 1 );
169
+ $this->loader->addAction( "elementor/frontend/widget/after_render", $pluginPublic, 'filterSectionContentAfter', 10, 1 );
170
+
171
+ // filter sections
172
+ $this->loader->addAction( "elementor/frontend/section/before_render", $pluginPublic, 'filterSectionContentBefore', 10, 1 );
173
+ $this->loader->addAction( "elementor/frontend/section/after_render", $pluginPublic, 'filterSectionContentAfter', 10, 1 );
174
+
175
+ // filter columns
176
+ $this->loader->addAction( "elementor/frontend/column/before_render", $pluginPublic, 'filterSectionContentBefore', 10, 1 );
177
+ $this->loader->addAction( "elementor/frontend/column/after_render", $pluginPublic, 'filterSectionContentAfter', 10, 1 );
178
+
179
+ // filter popup
180
+ $this->loader->addAction( "elementor/theme/before_do_popup", $pluginPublic, 'checkPopupsCondition', 10, 1 );
181
+ }
182
+
183
+ /**
184
+ * Register all of the hooks related to the elementor-facing functionality
185
+ * of the plugin.
186
+ *
187
+ * @since 1.2.0
188
+ * @access private
189
+ */
190
+ private function defineElementorHooks() {
191
+ $this->loader->addAction( 'elementor/dynamic_tags/register_tags', $this, 'registerDynamicTags', 10, 1 );
192
+ $this->loader->addAction( 'wp_footer', $this, 'setFooterStyleForPreview', 10, 0 );
193
+ }
194
+
195
+ /**
196
+ * Register some useful dynamic tags
197
+ *
198
+ * @since 1.2.0
199
+ * @param $dynamicTags
200
+ */
201
+ public function registerDynamicTags( $dynamicTags ) {
202
+ $dynamicTags->register_tag( NumberPostsTag::class );
203
+ }
204
+
205
+ /**
206
+ * Sets style for preview
207
+ *
208
+ * @since 1.3.0
209
+ */
210
+ public function setFooterStyleForPreview() {
211
+ if ( !Plugin::$instance->preview->is_preview_mode() ) {
212
+ return;
213
+ }
214
+ ?>
215
+ <style>
216
+ body.elementor-editor-active .elementor-element.dc-has-condition::after {
217
+ content: '\e8ed';
218
+ display: inline-block;
219
+ position: absolute;
220
+ top: 0;
221
+ right: 5px;
222
+ font-size: 15px;
223
+ font-family: eicons;
224
+ color: #71d7f7;
225
+ }
226
+ </style>
227
+ <?php
228
+ }
229
+
230
+ /**
231
+ * The name of the plugin used to uniquely identify it within the context of
232
+ * WordPress and to define internationalization functionality.
233
+ *
234
+ * @return string The name of the plugin.
235
+ * @since 1.0.0
236
+ */
237
+ public function getDynamicConditions() {
238
+ return $this->pluginName;
239
+ }
240
+
241
+ /**
242
+ * The reference to the class that orchestrates the hooks with the plugin.
243
+ *
244
+ * @return Loader Orchestrates the hooks of the plugin.
245
+ * @since 1.0.0
246
+ */
247
+ public function getLoader() {
248
+ return $this->loader;
249
+ }
250
+
251
+ /**
252
+ * Retrieve the version number of the plugin.
253
+ *
254
+ * @return string The version number of the plugin.
255
+ * @since 1.0.0
256
+ */
257
+ public function getVersion() {
258
+ return $this->version;
259
+ }
260
+
261
+ /**
262
+ * Run the loader to execute all of the hooks with WordPress.
263
+ *
264
+ * @since 1.0.0
265
+ */
266
+ public static function run() {
267
+ $plugin = new self();
268
+ $plugin->loader->run();
269
+ }
270
+ }
Lib/DynamicTags/NumberPostsTag.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib\DynamicTags;
4
+
5
+ use Elementor\Controls_Manager;
6
+ use ElementorPro\Modules\DynamicTags\Module;
7
+
8
+ // If this file is called directly, abort.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die;
11
+ }
12
+
13
+ Class NumberPostsTag extends \Elementor\Core\DynamicTags\Tag {
14
+ const WRAPPED_TAG = false;
15
+ public static $dtCount = 0;
16
+
17
+ public function get_name() {
18
+ return 'numberposts';
19
+ }
20
+
21
+ public function get_title() {
22
+ return __( 'Number posts', 'dynamicconditions' );
23
+ }
24
+
25
+ public function get_group() {
26
+ return [ Module::POST_GROUP ];
27
+ }
28
+
29
+ public function get_categories() {
30
+ return [ Module::TEXT_CATEGORY ];
31
+ }
32
+
33
+ protected function _register_controls() {
34
+
35
+ $this->add_control(
36
+ 'category',
37
+ [
38
+ 'label' => __( 'Category', 'elementor-pro' ),
39
+ 'type' => Controls_Manager::SELECT2,
40
+ 'label_block' => true,
41
+ 'default' => [],
42
+ 'options' => $this->getCategories(),
43
+ 'multiple' => true,
44
+ ]
45
+ );
46
+ $this->add_control(
47
+ 'posttypes',
48
+ [
49
+ 'label' => __( 'Post-Types', 'elementor-pro' ),
50
+ 'type' => Controls_Manager::SELECT2,
51
+ 'label_block' => true,
52
+ 'default' => [],
53
+ 'options' => get_post_types(),
54
+ 'multiple' => true,
55
+ ]
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Get a list of all categories
61
+ *
62
+ * @return array
63
+ */
64
+ private function getCategories() {
65
+ $result = [];
66
+ foreach ( get_categories() as $category ) {
67
+ $result[$category->term_id] = $category->name;
68
+ }
69
+
70
+ return $result;
71
+ }
72
+
73
+
74
+ /**
75
+ * Print the number of posts in category/post-type
76
+ */
77
+ public function render() {
78
+ $settings = $this->get_settings();
79
+ $posts = get_posts( [
80
+ 'category' => implode( ',', $settings['category'] ),
81
+ 'post_type' => empty( $settings['posttypes'] ) ? 'any' : $settings['posttypes'],
82
+ 'numberposts' => -1,
83
+ 'posts_per_page' => -1,
84
+ 'fields' => 'ids',
85
+ ] );
86
+
87
+ echo count( $posts );
88
+ }
89
+ }
Lib/DynamicTags/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Lib/I18n.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ /**
6
+ * Define the internationalization functionality
7
+ *
8
+ * Loads and defines the internationalization files for this plugin
9
+ * so that it is ready for translation.
10
+ *
11
+ * @link https://www.rto.de
12
+ * @since 1.0.0
13
+ *
14
+ * @package DynamicConditions
15
+ * @subpackage DynamicConditions/includes
16
+ */
17
+
18
+ // If this file is called directly, abort.
19
+ if ( ! defined( 'ABSPATH' ) ) {
20
+ die;
21
+ }
22
+
23
+ /**
24
+ * Define the internationalization functionality.
25
+ *
26
+ * Loads and defines the internationalization files for this plugin
27
+ * so that it is ready for translation.
28
+ *
29
+ * @since 1.0.0
30
+ * @package DynamicConditions
31
+ * @subpackage DynamicConditions/includes
32
+ * @author RTO GmbH <kundenhomepage@rto.de>
33
+ */
34
+ class I18n {
35
+
36
+ /**
37
+ * The domain specified for this plugin.
38
+ *
39
+ * @since 1.0.0
40
+ * @access private
41
+ * @var string $domain The domain identifier for this plugin.
42
+ */
43
+ private $domain;
44
+
45
+ /**
46
+ * Load the plugin text domain for translation.
47
+ *
48
+ * @since 1.0.0
49
+ */
50
+ public function loadPluginTextdomain() {
51
+
52
+ load_plugin_textdomain(
53
+ $this->domain,
54
+ false,
55
+ dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
56
+ );
57
+
58
+ }
59
+
60
+ /**
61
+ * Set the domain equal to that of the specified domain.
62
+ *
63
+ * @since 1.0.0
64
+ * @param string $domain The domain that represents the locale of this plugin.
65
+ */
66
+ public function setDomain( $domain ) {
67
+ $this->domain = $domain;
68
+ }
69
+
70
+ }
Lib/Loader.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Lib;
4
+
5
+ /**
6
+ * Register all actions and filters for the plugin
7
+ *
8
+ * @link https://www.rto.de
9
+ * @since 1.0.0
10
+ *
11
+ * @package DynamicConditions
12
+ * @subpackage DynamicConditions/includes
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ /**
21
+ * Register all actions and filters for the plugin.
22
+ *
23
+ * Maintain a list of all hooks that are registered throughout
24
+ * the plugin, and register them with the WordPress API. Call the
25
+ * run function to execute the list of actions and filters.
26
+ *
27
+ * @package DynamicConditions
28
+ * @subpackage DynamicConditions/includes
29
+ * @author RTO GmbH <kundenhomepage@rto.de>
30
+ */
31
+ class Loader {
32
+
33
+ /**
34
+ * The array of actions registered with WordPress.
35
+ *
36
+ * @since 1.0.0
37
+ * @access protected
38
+ * @var array $actions The actions registered with WordPress to fire when the plugin loads.
39
+ */
40
+ protected $actions;
41
+
42
+ /**
43
+ * The array of filters registered with WordPress.
44
+ *
45
+ * @since 1.0.0
46
+ * @access protected
47
+ * @var array $filters The filters registered with WordPress to fire when the plugin loads.
48
+ */
49
+ protected $filters;
50
+
51
+ /**
52
+ * Initialize the collections used to maintain the actions and filters.
53
+ *
54
+ * @since 1.0.0
55
+ */
56
+ public function __construct() {
57
+
58
+ $this->actions = array();
59
+ $this->filters = array();
60
+
61
+ }
62
+
63
+ /**
64
+ * Add a new action to the collection to be registered with WordPress.
65
+ *
66
+ * @since 1.0.0
67
+ * @param string $hook The name of the WordPress action that is being registered.
68
+ * @param object $component A reference to the instance of the object on which the action is defined.
69
+ * @param string $callback The name of the function definition on the $component.
70
+ * @param int Optional $priority The priority at which the function should be fired.
71
+ * @param int Optional $acceptedArgs The number of arguments that should be passed to the $callback.
72
+ */
73
+ public function addAction( $hook, $component, $callback, $priority = 10, $acceptedArgs = 1 ) {
74
+ $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $acceptedArgs );
75
+ }
76
+
77
+ /**
78
+ * Add a new filter to the collection to be registered with WordPress.
79
+ *
80
+ * @since 1.0.0
81
+ * @param string $hook The name of the WordPress filter that is being registered.
82
+ * @param object $component A reference to the instance of the object on which the filter is defined.
83
+ * @param string $callback The name of the function definition on the $component.
84
+ * @param int Optional $priority The priority at which the function should be fired.
85
+ * @param int Optional $acceptedArgs The number of arguments that should be passed to the $callback.
86
+ */
87
+ public function addFilter( $hook, $component, $callback, $priority = 10, $acceptedArgs = 1 ) {
88
+ $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $acceptedArgs );
89
+ }
90
+
91
+ /**
92
+ * A utility function that is used to register the actions and hooks into a single
93
+ * collection.
94
+ *
95
+ * @since 1.0.0
96
+ * @access private
97
+ * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
98
+ * @param string $hook The name of the WordPress filter that is being registered.
99
+ * @param object $component A reference to the instance of the object on which the filter is defined.
100
+ * @param string $callback The name of the function definition on the $component.
101
+ * @param int Optional $priority The priority at which the function should be fired.
102
+ * @param int Optional $acceptedArgs The number of arguments that should be passed to the $callback.
103
+ * @return array The collection of actions and filters registered with WordPress.
104
+ */
105
+ private function add( $hooks, $hook, $component, $callback, $priority, $acceptedArgs ) {
106
+
107
+ $hooks[] = array(
108
+ 'hook' => $hook,
109
+ 'component' => $component,
110
+ 'callback' => $callback,
111
+ 'priority' => $priority,
112
+ 'acceptedArgs' => $acceptedArgs
113
+ );
114
+
115
+ return $hooks;
116
+
117
+ }
118
+
119
+ /**
120
+ * Register the filters and actions with WordPress.
121
+ *
122
+ * @since 1.0.0
123
+ */
124
+ public function run() {
125
+
126
+ foreach ( $this->filters as $hook ) {
127
+ add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['acceptedArgs'] );
128
+ }
129
+
130
+ foreach ( $this->actions as $hook ) {
131
+ add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['acceptedArgs'] );
132
+ }
133
+
134
+ }
135
+
136
+ }
Lib/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Public/DynamicConditionsPublic.php ADDED
@@ -0,0 +1,749 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions\Pub;
4
+
5
+ use Elementor\Element_Base;
6
+ use Elementor\Plugin;
7
+ use ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager;
8
+ use ElementorPro\Modules\ThemeBuilder\Module;
9
+ use DynamicConditions\Lib\Date;
10
+
11
+ /**
12
+ * The public-facing functionality of the plugin.
13
+ *
14
+ * @link https://www.rto.de
15
+ * @since 1.0.0
16
+ *
17
+ * @package DynamicConditions
18
+ * @subpackage DynamicConditions/public
19
+ */
20
+
21
+ // If this file is called directly, abort.
22
+ if ( !defined( 'ABSPATH' ) ) {
23
+ die;
24
+ }
25
+
26
+ /**
27
+ * The public-facing functionality of the plugin.
28
+ *
29
+ * Defines the plugin name, version, and two examples hooks for how to
30
+ * enqueue the admin-specific stylesheet and JavaScript.
31
+ *
32
+ * @package DynamicConditions
33
+ * @subpackage DynamicConditions/public
34
+ * @author RTO GmbH <kundenhomepage@rto.de>
35
+ */
36
+ class DynamicConditionsPublic {
37
+
38
+ /**
39
+ * The ID of this plugin.
40
+ *
41
+ * @since 1.0.0
42
+ * @access private
43
+ * @var string $pluginName The ID of this plugin.
44
+ */
45
+ private $pluginName;
46
+
47
+ /**
48
+ * The version of this plugin.
49
+ *
50
+ * @since 1.0.0
51
+ * @access private
52
+ * @var string $version The current version of this plugin.
53
+ */
54
+ private $version;
55
+
56
+ private $elementSettings = [];
57
+
58
+ /**
59
+ * @var Date $dateInstance
60
+ */
61
+ private $dateInstance;
62
+
63
+ private static $debugCssRendered = false;
64
+
65
+ /**
66
+ * Initialize the class and set its properties.
67
+ *
68
+ * @param string $pluginName The name of the plugin.
69
+ * @param string $version The version of this plugin.
70
+ * @since 1.0.0
71
+ */
72
+ public function __construct( $pluginName, $version ) {
73
+
74
+ $this->pluginName = $pluginName;
75
+ $this->version = $version;
76
+ $this->dateInstance = new Date();
77
+ }
78
+
79
+ /**
80
+ * Gets settings with english locale (needed for date)
81
+ *
82
+ * @param Element_Base $element
83
+ * @return mixed
84
+ */
85
+ private function getElementSettings( $element ) {
86
+ $id = $element->get_id();
87
+
88
+ $clonedElement = clone $element;
89
+
90
+ $fields = '__dynamic__
91
+ dynamicconditions_dynamic
92
+ dynamicconditions_condition
93
+ dynamicconditions_type
94
+ dynamicconditions_resizeOtherColumns
95
+ dynamicconditions_hideContentOnly
96
+ dynamicconditions_visibility
97
+ dynamicconditions_day_value
98
+ dynamicconditions_day_value2
99
+ dynamicconditions_day_array_value
100
+ dynamicconditions_month_value
101
+ dynamicconditions_month_value2
102
+ dynamicconditions_month_array_value
103
+ dynamicconditions_date_value
104
+ dynamicconditions_date_value2
105
+ dynamicconditions_value
106
+ dynamicconditions_value2
107
+ dynamicconditions_parse_shortcodes
108
+ dynamicconditions_debug
109
+ _column_size
110
+ _inline_size';
111
+
112
+ $fieldArray = explode( "\n", $fields );
113
+
114
+ $this->elementSettings[$id]['dynamicconditions_dynamic_raw'] = $element->get_settings_for_display( 'dynamicconditions_dynamic' );
115
+
116
+ $preventDateParsing = $element->get_settings_for_display( 'dynamicconditions_prevent_date_parsing' );
117
+ $this->elementSettings[$id]['preventDateParsing'] = $preventDateParsing;
118
+
119
+ if ( empty( $preventDateParsing ) ) {
120
+ // set locale to english, for better parsing
121
+ $currentLocale = setlocale( LC_ALL, 0 );
122
+ setlocale( LC_ALL, 'en_GB' );
123
+ add_filter( 'date_i18n', [ $this->dateInstance, 'filterDateI18n' ], 10, 4 );
124
+ add_filter( 'get_the_date', [ $this->dateInstance, 'filterPostDate' ], 10, 3 );
125
+ add_filter( 'get_the_modified_date', [ $this->dateInstance, 'filterPostDate' ], 10, 3 );
126
+ }
127
+
128
+ foreach ( $fieldArray as $field ) {
129
+ $field = trim( $field );
130
+ $this->elementSettings[$id][$field] = $clonedElement->get_settings_for_display( $field );
131
+ }
132
+ unset( $clonedElement );
133
+
134
+ if ( empty( $preventDateParsing ) ) {
135
+ remove_filter( 'date_i18n', [ $this->dateInstance, 'filterDateI18n' ], 10 );
136
+ remove_filter( 'get_the_date', [ $this->dateInstance, 'filterPostDate' ], 10 );
137
+ remove_filter( 'get_the_modified_date', [ $this->dateInstance, 'filterPostDate' ], 10 );
138
+
139
+ // reset locale
140
+ Date::setLocale( $currentLocale );
141
+ }
142
+
143
+ $tagData = $this->getDynamicTagData( $id );
144
+ $this->convertAcfDate( $id, $tagData );
145
+
146
+ $this->elementSettings[$id]['dynamicConditionsData'] = [
147
+ 'id' => $id,
148
+ 'type' => $element->get_type(),
149
+ 'name' => $element->get_name(),
150
+ 'selectedTag' => $tagData['selectedTag'],
151
+ 'tagData' => $tagData['tagData'],
152
+ 'tagKey' => $tagData['tagKey'],
153
+ ];
154
+
155
+ return $this->elementSettings[$id];
156
+ }
157
+
158
+ /**
159
+ * Returns data of dynamic tag
160
+ *
161
+ * @param $id
162
+ * @return array
163
+ */
164
+ private function getDynamicTagData( $id ) {
165
+ $dynamicEmpty = empty( $this->elementSettings[$id]['__dynamic__'] )
166
+ || empty( $this->elementSettings[$id]['__dynamic__']['dynamicconditions_dynamic'] );
167
+ $staticEmpty = empty( $this->elementSettings[$id]['dynamicconditions_dynamic'] )
168
+ || empty( $this->elementSettings[$id]['dynamicconditions_dynamic']['url'] );
169
+
170
+ if ( $dynamicEmpty && $staticEmpty ) {
171
+ // no dynamic tag or static value set
172
+ return [
173
+ 'selectedTag' => null,
174
+ 'tagData' => null,
175
+ 'tagKey' => null,
176
+ ];
177
+ }
178
+
179
+ $selectedTag = null;
180
+ $tagSettings = null;
181
+ $tagData = [];
182
+ $tagKey = null;
183
+
184
+ if ( $dynamicEmpty ) {
185
+ // no dynamic tag set, but static value
186
+ $this->elementSettings[$id]['__dynamic__'] = [
187
+ 'dynamicconditions_dynamic' => $this->elementSettings[$id]['dynamicconditions_dynamic'],
188
+ ];
189
+ $selectedTag = 'static';
190
+ }
191
+
192
+
193
+ $tag = $this->elementSettings[$id]['__dynamic__']['dynamicconditions_dynamic'];
194
+ $splitTag = explode( ' name="', $tag );
195
+
196
+ // get selected tag
197
+ if ( !empty( $splitTag[1] ) ) {
198
+ $splitTag2 = explode( '"', $splitTag[1] );
199
+ $selectedTag = $splitTag2[0];
200
+ }
201
+
202
+ // get tag settings
203
+ if ( strpos( $selectedTag, 'acf-' ) === 0 ) {
204
+ $splitTag = explode( ' settings="', $tag );
205
+ if ( !empty( $splitTag[1] ) ) {
206
+ $splitTag2 = explode( '"', $splitTag[1] );
207
+ $tagSettings = json_decode( urldecode( $splitTag2[0] ), true );
208
+ if ( !empty( $tagSettings['key'] ) ) {
209
+ $tagKey = $tagSettings['key'];
210
+ $tagData = get_field_object( explode( ':', $tagSettings['key'] )[0] ); //, false, false );
211
+ }
212
+ }
213
+ }
214
+
215
+ return [
216
+ 'selectedTag' => $selectedTag,
217
+ 'tagData' => $tagData,
218
+ 'tagKey' => $tagKey,
219
+ ];
220
+
221
+ }
222
+
223
+ /**
224
+ * Convert acf date to timestamp
225
+ *
226
+ * @param $id
227
+ * @param array $data
228
+ */
229
+ private function convertAcfDate( $id, array $data ) {
230
+ if ( empty( $data ) ) {
231
+ return;
232
+ }
233
+
234
+ if ( !empty( $this->elementSettings[$id]['preventDateParsing'] ) ) {
235
+ return;
236
+ }
237
+
238
+ $allowedTypes = [
239
+ 'date_time_picker',
240
+ 'date_picker',
241
+ ];
242
+
243
+ $tagData = $data['tagData'];
244
+
245
+ if ( empty( $data['tagKey'] ) || strpos( $data['selectedTag'], 'acf-' ) !== 0 ) {
246
+ return;
247
+ }
248
+
249
+ if ( empty( $tagData['type'] ) || !in_array( trim( $tagData['type'] ), $allowedTypes, true ) ) {
250
+ return;
251
+ }
252
+
253
+ if ( empty( $tagData['value'] ) || empty( $tagData['return_format'] ) ) {
254
+ return;
255
+ }
256
+
257
+ $time = \DateTime::createFromFormat( $tagData['return_format'], Date::unTranslateDate( $tagData['value'] ) );
258
+
259
+ if ( empty( $time ) ) {
260
+ return;
261
+ }
262
+
263
+ if ( $tagData['type'] === 'date_picker' ) {
264
+ $time->setTime( 0, 0, 0 );
265
+ }
266
+
267
+ $timestamp = $time->getTimestamp();
268
+
269
+ // override value with timestamp
270
+ $this->elementSettings[$id]['dynamicconditions_dynamic'] = $timestamp;
271
+ }
272
+
273
+
274
+ /**
275
+ * Removes popup from location, if it is hidden by condition
276
+ *
277
+ * @param Locations_Manager $locationManager
278
+ */
279
+ public function checkPopupsCondition( $locationManager ) {
280
+ if ( $this->getMode() !== 'website' ) {
281
+ return;
282
+ }
283
+
284
+ $conditionManager = Module::instance()->get_conditions_manager();
285
+ $module = $conditionManager->get_documents_for_location( 'popup' );
286
+
287
+ foreach ( $module as $documentId => $document ) {
288
+ $settings = $this->getElementSettings( $document );
289
+ $hide = $this->checkCondition( $settings );
290
+
291
+ if ( $hide ) {
292
+ $locationManager->remove_doc_from_location( 'popup', $documentId );
293
+ }
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Check if section is hidden, before rendering
299
+ *
300
+ * @param Element_Base $section
301
+ */
302
+ public function filterSectionContentBefore( $section ) {
303
+ if ( $this->getMode() === 'edit' ) {
304
+ return;
305
+ }
306
+
307
+ $settings = $this->getElementSettings( $section );
308
+ $hide = $this->checkCondition( $settings );
309
+
310
+ if ( !$hide ) {
311
+ return;
312
+ }
313
+
314
+ $section->dynamicConditionIsHidden = true;
315
+ $section->dynamicConditionSettings = $settings;
316
+
317
+ ob_start();
318
+ }
319
+
320
+ /**
321
+ * Clean output of section if it is hidden
322
+ *
323
+ * @param Element_Base $section
324
+ */
325
+ public function filterSectionContentAfter( $section ) {
326
+ if ( empty( $section ) || empty( $section->dynamicConditionIsHidden ) ) {
327
+ return;
328
+ }
329
+
330
+ ob_end_clean();
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-elementor-hidden-column" data-size="' . $settings['_column_size'] . '"></div>';
341
+ }
342
+
343
+ echo "<!-- hidden $type -->";
344
+ }
345
+
346
+ /**
347
+ * Checks condition, return if element is hidden
348
+ *
349
+ * @param $settings
350
+ * @return bool
351
+ */
352
+ public function checkCondition( $settings ) {
353
+ if ( !$this->hasCondition( $settings ) ) {
354
+ return false;
355
+ }
356
+
357
+ if ( $this->getMode() === 'edit' ) {
358
+ return false;
359
+ }
360
+
361
+ // loop values
362
+ $condition = $this->loopValues( $settings );
363
+
364
+ $hide = false;
365
+
366
+ $visibility = self::checkEmpty( $settings, 'dynamicconditions_visibility', 'hide' );
367
+ switch ( $visibility ) {
368
+ case 'show':
369
+ if ( !$condition ) {
370
+ $hide = true;
371
+ }
372
+ break;
373
+ case 'hide':
374
+ default:
375
+ if ( $condition ) {
376
+ $hide = true;
377
+ }
378
+ break;
379
+ }
380
+
381
+ return $hide;
382
+ }
383
+
384
+ /**
385
+ * Loop widget-values and check the condition
386
+ *
387
+ * @param $settings
388
+ * @return bool|mixed
389
+ */
390
+ private function loopValues( $settings ) {
391
+ $condition = false;
392
+ $dynamicTagValueArray = self::checkEmpty( $settings, 'dynamicconditions_dynamic' );
393
+
394
+ if ( !is_array( $dynamicTagValueArray ) ) {
395
+ $dynamicTagValueArray = [ $dynamicTagValueArray ];
396
+ }
397
+
398
+ // get value form conditions
399
+ $compareType = self::checkEmpty( $settings, 'dynamicconditions_type', 'default' );
400
+ $checkValues = $this->getCheckValue( $compareType, $settings );
401
+ $checkValue = $checkValues[0];
402
+ $checkValue2 = $checkValues[1];
403
+
404
+ $debugValue = '';
405
+
406
+ foreach ( $dynamicTagValueArray as $dynamicTagValue ) {
407
+ if ( is_array( $dynamicTagValue ) ) {
408
+ if ( !empty( $dynamicTagValue['id'] ) ) {
409
+ $dynamicTagValue = wp_get_attachment_url( $dynamicTagValue['id'] );
410
+ } else {
411
+ continue;
412
+ }
413
+ }
414
+
415
+ if ( !empty( $settings['dynamicconditions_parse_shortcodes'] ) ) {
416
+ $dynamicTagValue = do_shortcode( $dynamicTagValue );
417
+ }
418
+
419
+ // parse value based on compare-type
420
+ $this->parseDynamicTagValue( $dynamicTagValue, $compareType );
421
+
422
+ $debugValue .= $dynamicTagValue . '~~*#~~';
423
+
424
+ // compare widget-value with check-values
425
+ $compareValues = $this->compareValues( $settings['dynamicconditions_condition'], $dynamicTagValue, $checkValue, $checkValue2 );
426
+ $condition = $compareValues[0];
427
+ $break = $compareValues[1];
428
+ $breakFalse = $compareValues[2];
429
+
430
+ if ( $break && $condition ) {
431
+ // break if condition is true
432
+ break;
433
+ }
434
+
435
+ if ( $breakFalse && !$condition ) {
436
+ // break if condition is false
437
+ break;
438
+ }
439
+ }
440
+
441
+ // debug output
442
+ $this->renderDebugInfo( $settings, $debugValue, $checkValue, $checkValue2, $condition );
443
+
444
+ return $condition;
445
+ }
446
+
447
+ /**
448
+ * Compare values
449
+ *
450
+ * @param $compare
451
+ * @param $dynamicTagValue
452
+ * @param $checkValue
453
+ * @param $checkValue2
454
+ * @return array
455
+ */
456
+ private function compareValues( $compare, $dynamicTagValue, $checkValue, $checkValue2 ) {
457
+ $break = false;
458
+ $breakFalse = false;
459
+ $condition = false;
460
+
461
+ switch ( $compare ) {
462
+ case 'equal':
463
+ $condition = $checkValue == $dynamicTagValue;
464
+ $break = true;
465
+ break;
466
+
467
+ case 'not_equal':
468
+ $condition = $checkValue != $dynamicTagValue;
469
+ $breakFalse = true;
470
+ break;
471
+
472
+ case 'contains':
473
+ if ( empty( $checkValue ) ) {
474
+ break;
475
+ }
476
+ $condition = strpos( $dynamicTagValue, $checkValue ) !== false;
477
+ $break = true;
478
+ break;
479
+
480
+ case 'not_contains':
481
+ if ( empty( $checkValue ) ) {
482
+ break;
483
+ }
484
+ $condition = strpos( $dynamicTagValue, $checkValue ) === false;
485
+ $breakFalse = true;
486
+ break;
487
+
488
+ case 'empty':
489
+ $condition = empty( $dynamicTagValue );
490
+ $breakFalse = true;
491
+ break;
492
+
493
+ case 'not_empty':
494
+ $condition = !empty( $dynamicTagValue );
495
+ $break = true;
496
+ break;
497
+
498
+ case 'less':
499
+ if ( is_numeric( $dynamicTagValue ) ) {
500
+ $condition = $dynamicTagValue < $checkValue;
501
+ } else {
502
+ $condition = strlen( $dynamicTagValue ) < strlen( $checkValue );
503
+ }
504
+ $break = true;
505
+ break;
506
+
507
+ case 'greater':
508
+ if ( is_numeric( $dynamicTagValue ) ) {
509
+ $condition = $dynamicTagValue > $checkValue;
510
+ } else {
511
+ $condition = strlen( $dynamicTagValue ) > strlen( $checkValue );
512
+ }
513
+ $break = true;
514
+ break;
515
+
516
+ case 'between':
517
+ $condition = $dynamicTagValue >= $checkValue && $dynamicTagValue <= $checkValue2;
518
+ $break = true;
519
+ break;
520
+
521
+ case 'in_array':
522
+ $condition = in_array( $dynamicTagValue, explode( ',', $checkValue ) ) !== false;
523
+ $break = true;
524
+ break;
525
+ }
526
+
527
+ return [
528
+ $condition,
529
+ $break,
530
+ $breakFalse,
531
+ ];
532
+ }
533
+
534
+ /**
535
+ * Parse value of widget to timestamp, day or month
536
+ *
537
+ * @param $dynamicTagValue
538
+ * @param $compareType
539
+ */
540
+ private function parseDynamicTagValue( &$dynamicTagValue, $compareType ) {
541
+ switch ( $compareType ) {
542
+ case 'days':
543
+ $dynamicTagValue = date( 'N', Date::stringToTime( $dynamicTagValue ) );
544
+ break;
545
+
546
+ case 'months':
547
+ $dynamicTagValue = date( 'n', Date::stringToTime( $dynamicTagValue ) );
548
+ break;
549
+
550
+ case 'strtotime':
551
+ // nobreak
552
+ case 'date':
553
+ $dynamicTagValue = Date::stringToTime( $dynamicTagValue );
554
+ break;
555
+ }
556
+ }
557
+
558
+ /**
559
+ * Get value to compare
560
+ *
561
+ * @param $compareType
562
+ * @param $settings
563
+ * @return array
564
+ */
565
+ private function getCheckValue( $compareType, $settings ) {
566
+
567
+ switch ( $compareType ) {
568
+ case 'days':
569
+ if ( $settings['dynamicconditions_condition'] === 'in_array' ) {
570
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_day_array_value' );
571
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
572
+ $checkValue = implode( ',', $checkValue );
573
+ } else {
574
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_day_value' );
575
+ $checkValue = $this->parseShortcode( $checkValue );
576
+ }
577
+ $checkValue2 = self::checkEmpty( $settings, 'dynamicconditions_day_value2' );
578
+ $checkValue2 = $this->parseShortcode( $checkValue2, $settings );
579
+ $checkValue = Date::unTranslateDate( $checkValue );
580
+ $checkValue2 = Date::unTranslateDate( $checkValue2 );
581
+ break;
582
+
583
+ case 'months':
584
+ if ( $settings['dynamicconditions_condition'] === 'in_array' ) {
585
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_month_array_value' );
586
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
587
+ $checkValue = implode( ',', $checkValue );
588
+ } else {
589
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_month_value' );
590
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
591
+ }
592
+ $checkValue2 = self::checkEmpty( $settings, 'dynamicconditions_month_value2' );
593
+ $checkValue2 = $this->parseShortcode( $checkValue2, $settings );
594
+ $checkValue = Date::unTranslateDate( $checkValue );
595
+ $checkValue2 = Date::unTranslateDate( $checkValue2 );
596
+ break;
597
+
598
+ case 'date':
599
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_date_value' );
600
+ $checkValue2 = self::checkEmpty( $settings, 'dynamicconditions_date_value2' );
601
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
602
+ $checkValue2 = $this->parseShortcode( $checkValue2, $settings );
603
+ $checkValue = Date::stringToTime( $checkValue );
604
+ $checkValue2 = Date::stringToTime( $checkValue2 );
605
+ break;
606
+
607
+ case 'strtotime':
608
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_value' );
609
+ $checkValue2 = self::checkEmpty( $settings, 'dynamicconditions_value2' );
610
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
611
+ $checkValue2 = $this->parseShortcode( $checkValue2, $settings );
612
+ $checkValue = Date::stringToTime( $checkValue );
613
+ $checkValue2 = Date::stringToTime( $checkValue2 );
614
+ break;
615
+
616
+ case 'default':
617
+ default:
618
+ $checkValue = self::checkEmpty( $settings, 'dynamicconditions_value' );
619
+ $checkValue2 = self::checkEmpty( $settings, 'dynamicconditions_value2' );
620
+ $checkValue = $this->parseShortcode( $checkValue, $settings );
621
+ $checkValue2 = $this->parseShortcode( $checkValue2, $settings );
622
+ break;
623
+ }
624
+
625
+ return [
626
+ $checkValue,
627
+ $checkValue2,
628
+ ];
629
+ }
630
+
631
+ /**
632
+ * Parse shortcode if active
633
+ *
634
+ * @param $value
635
+ * @param array $settings
636
+ * @return string
637
+ */
638
+ private function parseShortcode( $value, $settings = [] ) {
639
+ if ( empty( $settings['dynamicconditions_parse_shortcodes'] ) ) {
640
+ return $value;
641
+ }
642
+ return do_shortcode( $value );
643
+ }
644
+
645
+ /**
646
+ * Checks if an array or entry in array is empty and return its value
647
+ *
648
+ * @param array $array
649
+ * @param null $key
650
+ * @return array|mixed|null
651
+ */
652
+ public static function checkEmpty( $array = [], $key = null, $fallback = null ) {
653
+ if ( empty( $key ) ) {
654
+ return !empty( $array ) ? $array : $fallback;
655
+ }
656
+
657
+ return !empty( $array[$key] ) ? $array[$key] : $fallback;
658
+ }
659
+
660
+ /**
661
+ * Checks if element has a condition
662
+ *
663
+ * @param $settings
664
+ * @return bool
665
+ */
666
+ public function hasCondition( $settings ) {
667
+ if ( empty( $settings['dynamicconditions_condition'] ) || empty( $settings['dynamicConditionsData']['selectedTag'] )
668
+ ) {
669
+ // no condition or no tag selected - disable conditions
670
+ return false;
671
+ }
672
+
673
+ return true;
674
+ }
675
+
676
+ /**
677
+ * Renders debug info
678
+ *
679
+ * @param $settings
680
+ * @param $dynamicTagValue
681
+ * @param $checkValue
682
+ * @param $checkValue2
683
+ */
684
+ private function renderDebugInfo( $settings, $dynamicTagValue, $checkValue, $checkValue2, $conditionMets ) {
685
+ if ( !$settings['dynamicconditions_debug'] ) {
686
+ return;
687
+ }
688
+
689
+ if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
690
+ return;
691
+ }
692
+
693
+ $visibility = self::checkEmpty( $settings, 'dynamicconditions_visibility', 'hide' );
694
+
695
+ $dynamicTagValue = str_replace( '[', '&#91;', htmlentities( $dynamicTagValue ) );
696
+ $dynamicTagValue = str_replace( '~~*#~~', '<br />', $dynamicTagValue );
697
+ $checkValue = str_replace( '[', '&#91;', htmlentities( $checkValue ) );
698
+ $checkValue2 = str_replace( '[', '&#91;', htmlentities( $checkValue2 ) );
699
+ $dynamicTagValueRaw = self::checkEmpty( $settings, 'dynamicconditions_dynamic_raw', '' );
700
+
701
+ include( 'partials/debug.php' );
702
+
703
+ $this->renderDebugCss();
704
+ }
705
+
706
+ /**
707
+ * Renders css for debug-output
708
+ */
709
+ private function renderDebugCss() {
710
+ if ( self::$debugCssRendered ) {
711
+ return;
712
+ }
713
+ self::$debugCssRendered = true;
714
+
715
+ echo '<style>';
716
+ include( 'css/debug.css' );
717
+ echo '</style>';
718
+ }
719
+
720
+ /**
721
+ * Returns elementor-mode (edit, preview or website)
722
+ *
723
+ * @return string
724
+ */
725
+ private function getMode() {
726
+ if ( !empty( Plugin::$instance->editor ) && Plugin::$instance->editor->is_edit_mode() ) {
727
+ return 'edit';
728
+ }
729
+
730
+ if ( !empty( Plugin::$instance->preview ) && Plugin::$instance->preview->is_preview_mode() ) {
731
+ return 'preview';
732
+ }
733
+
734
+ return 'website';
735
+ }
736
+
737
+ /**
738
+ * Register the stylesheets for the public-facing side of the site.
739
+ *
740
+ * @since 1.0.0
741
+ */
742
+ public function enqueueScripts() {
743
+ if ( $this->getMode() === 'edit' ) {
744
+ return;
745
+ }
746
+ wp_enqueue_script( $this->pluginName, DynamicConditions_URL . '/Public/js/dynamic-conditions-public.js', [ 'jquery' ], $this->version, true );
747
+ }
748
+
749
+ }
Public/css/debug.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .dynamicconditions-debug {
3
+ position: relative;
4
+ width: 100%;
5
+ background-color: #efefef;
6
+ color: #333;
7
+ padding: 5px 10px;
8
+ font-size: 10px;
9
+ font-family: Verdana, Helvetica, sans-serif;
10
+ line-height: 16px;
11
+ letter-spacing: 0;
12
+ margin: 2px 2px;
13
+ border: 1px solid #333;
14
+ box-sizing: border-box;
15
+ }
16
+
17
+ .dynamicconditions-debug::before {
18
+ content: 'DynamicConditions-Debug';
19
+ position: relative;
20
+ display: block;
21
+ top: 0;
22
+ font-size: 9px;
23
+ background-color: #ccc;
24
+ padding: 0 10px 2px;
25
+ color: #333;
26
+ border-bottom: 1px solid #999;
27
+ margin: -5px -10px 2px;
28
+ }
29
+
30
+ .dc-debug-row {
31
+ position: relative;
32
+ }
33
+
34
+ .dc-debug-row::after {
35
+ content: '';
36
+ clear: both;
37
+ display: block;
38
+ }
39
+
40
+ .dc-debug-label {
41
+ float: left;
42
+ width: 135px;
43
+ white-space: nowrap;
44
+ }
45
+
46
+ .dc-debug-value {
47
+ float: left;
48
+ }
49
+
50
+ .dc-debug-remove {
51
+ position: absolute;
52
+ right: 5px;
53
+ top: 4px;
54
+ cursor: pointer;
55
+ }
Public/css/dynamic-conditions-public.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /**
2
+ * All of the CSS for your public-facing functionality should be
3
+ * included in this file.
4
+ */
Public/css/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Public/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Public/js/dynamic-conditions-public.js ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * All of the code for your public-facing JavaScript source
6
+ * should reside in this file.
7
+ *
8
+ * Note that this assume you're going to use jQuery, so it prepares
9
+ * the $ function reference to be used within the scope of this
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
+ let columns = $('.dc-elementor-hidden-column');
34
+ columns.each(function (index, column) {
35
+ column = $(column);
36
+ let hiddenSize = parseFloat(column.data('size')),
37
+ row = column.closest('.elementor-row'),
38
+ children = row.find('> .elementor-column'),
39
+ rowSize = 0;
40
+
41
+ if (children.length === 0) {
42
+ return;
43
+ }
44
+
45
+ // get percent-width of row
46
+ children.each(function (cIndex, child) {
47
+ child = $(child);
48
+ rowSize += parseFloat(child.width() / row.width() * 100);
49
+ });
50
+
51
+ children.each(function (cIndex, child) {
52
+ // resize columns
53
+ child = $(child);
54
+ let childSize = parseFloat(child.width() / row.width() * 100),
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
+ let columns = $('.dc-elementor-hidden-column');
67
+ columns.each(function (index, column) {
68
+ column = $(column);
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);
Public/js/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
Public/partials/debug.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var array $settings
4
+ * @var string $dynamicTagValue
5
+ * @var string $dynamicTagValueRaw
6
+ * @var string $checkValue
7
+ * @var string $checkValue2
8
+ * @var string $visibility
9
+ * @var bool $conditionMets
10
+ */
11
+ // If this file is called directly, abort.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ die;
14
+ }
15
+
16
+ ?>
17
+
18
+ <div class="dynamicconditions-debug">
19
+ <div class="dc-debug-row">
20
+ <div class="dc-debug-label">Element:</div>
21
+ <div class="dc-debug-value"><?php
22
+ echo $settings['dynamicConditionsData']['name'] . '-'
23
+ . $settings['dynamicConditionsData']['id']
24
+ . ' (' . $settings['dynamicConditionsData']['type'] . ')'; ?></div>
25
+ </div>
26
+
27
+ <div class="dc-debug-row">
28
+ <div class="dc-debug-label">DynamicTag-Tag:</div>
29
+ <div class="dc-debug-value"><?php echo $settings['dynamicConditionsData']['selectedTag']; ?></div>
30
+ </div>
31
+
32
+ <div class="dc-debug-row">
33
+ <div class="dc-debug-label">DynamicTag-Key:</div>
34
+ <div class="dc-debug-value"><?php echo $settings['dynamicConditionsData']['tagKey']; ?></div>
35
+ </div>
36
+
37
+ <div class="dc-debug-row">
38
+ <div class="dc-debug-label">DynamicTag-Value:</div>
39
+ <div class="dc-debug-value"><?php echo $dynamicTagValue; ?></div>
40
+ </div>
41
+ <div class="dc-debug-row">
42
+ <div class="dc-debug-label">DynamicTag-Value-Raw:</div>
43
+ <div class="dc-debug-value"><?php echo $dynamicTagValueRaw; ?></div>
44
+ </div>
45
+
46
+ <div class="dc-debug-row">
47
+ <div class="dc-debug-label">Check-Value:</div>
48
+ <div class="dc-debug-value"><?php echo $checkValue; ?></div>
49
+ </div>
50
+
51
+ <div class="dc-debug-row">
52
+ <div class="dc-debug-label">Check-Value2:</div>
53
+ <div class="dc-debug-value"><?php echo $checkValue2; ?></div>
54
+ </div>
55
+
56
+ <div class="dc-debug-row">
57
+ <div class="dc-debug-label">Condition-Type:</div>
58
+ <div class="dc-debug-value"><?php echo $settings['dynamicconditions_type']; ?></div>
59
+ </div>
60
+
61
+ <div class="dc-debug-row">
62
+ <div class="dc-debug-label">Condition:</div>
63
+ <div class="dc-debug-value"><?php echo ucfirst( $visibility ) . ' if ' . $settings['dynamicconditions_condition']; ?></div>
64
+ </div>
65
+
66
+ <div class="dc-debug-row">
67
+ <div class="dc-debug-label">Condition met:</div>
68
+ <div class="dc-debug-value"><?php echo $conditionMets ? 'yes' : 'no'; ?></div>
69
+ </div>
70
+
71
+ <i class="fa fa-window-close dc-debug-remove" aria-hidden="true" onclick="this.parentNode.remove();"></i>
72
+
73
+ </div>
Public/partials/dynamic-conditions-public-display.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the plugin
5
+ *
6
+ * This file is used to markup the public-facing aspects of the plugin.
7
+ *
8
+ * @link https://www.rto.de
9
+ * @since 1.0.0
10
+ *
11
+ * @package DynamicConditions
12
+ * @subpackage DynamicConditions/public/partials
13
+ */
14
+
15
+ // If this file is called directly, abort.
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ die;
18
+ }
19
+
20
+ ?>
21
+
22
+ <!-- This file should primarily consist of HTML with a little bit of PHP. -->
Public/partials/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
README.txt ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Dynamic Conditions ===
2
+ Contributors: rtowebsites
3
+ 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.4
8
+ Stable tag: 1.4.6
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Activates conditions for dynamic tags to show/hide a widget or section.
13
+
14
+ == Description ==
15
+
16
+ Dynamic Conditions is an Elementor addon that adds conditional logic to show or hide different elements. The plugin adds conditions to dynamic tags to show/hide a widget or section.
17
+
18
+ The plugin requires Elementor Pro since it uses Dynamic Tags to set the comparison conditions.
19
+
20
+ Setting display conditions is easy! Just enter the condition value and compare it to any dynamic tag. If the condition is met, set whether you want to show or hide the element. Can it be more simple?
21
+
22
+ Advanced users can set complex conditions - you can check if a field is empty, if it contains some value, if it equals a value, greater/smaller or between a certain value.
23
+
24
+ Special thanks to [WPTuts](https://wptuts.co.uk) for making a nice video tutorial:
25
+
26
+ https://www.youtube.com/watch?v=bRqW4Oaxtls
27
+
28
+ You can support development by contributing to the plugin´s GitHub repository:
29
+
30
+ https://github.com/RTO-Websites/dynamic-conditions
31
+
32
+ = Usage =
33
+
34
+ 1. Select a widget or a section.
35
+ 2. Go to the Advanced tab.
36
+ 3. Click the Dynamic Conditions area.
37
+ 4. Set the "Dynamic Tag" field you want to compare to.
38
+ 5. Set whether you want to "Show/Hide" the element if the condition is met.
39
+ 6. Under the "Condition" field, select what you wish to compare. You can compare whether the field is empty/not-empty, check if it has a specific value or if its value is between two other values.
40
+ 7. The "Compare Type" field defines what type of fields do you want to compare. Default compares two strings (text). But if you want to show a widget/section only on Monday or only in December, you can select Days or Month as Compare-Type.
41
+ 8. At last you have to enter the value to compare the dynamic-field with. Or two values, if you have selected the "between" condition.
42
+
43
+ == Frequently Asked Questions ==
44
+ = Can I use custom-fields, ACF fields, Pods ? =
45
+ Yes, all the above are supported and many others supported out-of-the-box by Elementor Pro.
46
+
47
+ = Can I set date based conditions ? =
48
+ Yes, the plugin supports date based conditions, for example current-date or post-date. You can compare dates, days and months.
49
+
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
61
+
62
+ = 1.4.4 =
63
+ * Fix issues with parsing of dates from shortcodes
64
+ * Fix issue with Elementor 2.9
65
+
66
+ = 1.4.3 =
67
+ * Fix issue with popups in editor
68
+ * Fix double slash on javascript-enqueue
69
+
70
+ = 1.4.2 =
71
+ * Fix issue with popups in preview
72
+
73
+ = 1.4.1 =
74
+ * Fix issue with calculation of hidden columns
75
+
76
+ = 1.4.0 =
77
+ * Add array conditions
78
+ * Add conditions for popups
79
+ * Change code-structure
80
+ * Fix issues with day-/month-translation
81
+
82
+ = 1.3.0 =
83
+ * Improve parsing of acf dates
84
+ * Add icon to elements with condition in preview
85
+ * Add option to parse shortcodes
86
+ * Fix some issues
87
+
88
+ = 1.2.1 =
89
+ * Fix issue with date timestamp in custom skins
90
+ * Improve performance
91
+
92
+ = 1.2.0 =
93
+ * Add condition between
94
+ * Add date, day and month compare options
95
+ * Add NumberPostsTag
96
+ * Add short documentation
97
+ * Add debug-mode
98
+
99
+ = 1.1.2 =
100
+ * Fix issue with section
101
+
102
+ = 1.1 =
103
+ * Add condition greater and less than
104
+
105
+ = 1.0.1 =
106
+ * Fix sections
107
+ * Some refactoring
108
+
109
+ = 1.0 =
110
+ * Release
111
+
112
+ `<?php code(); // goes in backticks ?>`
composer.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "require": {
3
+ "ext-json": "*"
4
+ },
5
+ "autoload": {
6
+ "psr-4": {
7
+ "DynamicConditions\\": "./",
8
+ "DynamicConditions\\Pub\\": "Public/",
9
+ "Lib\\" :"Legacy/Lib/"
10
+ }
11
+ }
12
+ }
dynamic-conditions.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DynamicConditions;
4
+
5
+ use DynamicConditions\Lib\DynamicConditions;
6
+ use DynamicConditions\Lib\Activator;
7
+ use DynamicConditions\Lib\Deactivator;
8
+
9
+ /**
10
+ * The plugin bootstrap file
11
+ *
12
+ * This file is read by WordPress to generate the plugin information in the plugin
13
+ * admin area. This file also includes all of the dependencies used by the plugin,
14
+ * registers the activation and deactivation functions, and defines a function
15
+ * that starts the plugin.
16
+ *
17
+ * @link https://www.rto.de
18
+ * @since 1.0.0
19
+ * @package DynamicConditions
20
+ *
21
+ * @wordpress-plugin
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.4.6
26
+ * Author: RTO GmbH
27
+ * Author URI: https://www.rto.de
28
+ * License: GPL-2.0+
29
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
30
+ * Text Domain: dynamicconditions
31
+ * Domain Path: /languages
32
+ */
33
+
34
+ // If this file is called directly, abort.
35
+ if ( ! defined( 'ABSPATH' ) ) {
36
+ die;
37
+ }
38
+
39
+ define( 'DynamicConditions_VERSION', '1.4.6' );
40
+
41
+ define( 'DynamicConditions_DIR', str_replace( '\\', '/', __DIR__ ) );
42
+ define( 'DynamicConditions_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
43
+
44
+ /**
45
+ * The class responsible for auto loading classes.
46
+ */
47
+ require_once DynamicConditions_DIR . '/vendor/autoload.php';
48
+
49
+ /**
50
+ * The code that runs during plugin activation.
51
+ * This action is documented in includes/DynamicConditionsActivator.php
52
+ */
53
+ register_activation_hook( __FILE__, [ Activator::class, 'activate' ] );
54
+
55
+ /**
56
+ * The code that runs during plugin deactivation.
57
+ * This action is documented in includes/DynamicConditionsDeactivator.php
58
+ */
59
+ register_deactivation_hook( __FILE__, [ Deactivator::class, 'deactivate' ] );
60
+
61
+ /**
62
+ * Begins execution of the plugin.
63
+ *
64
+ * Since everything within the plugin is registered via hooks,
65
+ * then kicking off the plugin from this point in the file does
66
+ * not affect the page life cycle.
67
+ *
68
+ * @since 1.0.0
69
+ */
70
+ DynamicConditions::run();
index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
languages/dynamicconditions-de_DE.mo ADDED
Binary file
languages/dynamicconditions-de_DE.po ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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: 2020-04-06 13:27+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.3\n"
11
+ "X-Poedit-Basepath: .\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "Last-Translator: \n"
15
+ "Language: de\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ #: admin/DynamicConditionsAdmin.php:66
19
+ msgid "Elementor and Elementor Pro not installed."
20
+ msgstr "Elementor und Elementor Pro nicht installiert."
21
+
22
+ #: admin/DynamicConditionsAdmin.php:68
23
+ msgid "Elementor Pro not installed."
24
+ msgstr "Elementor Pro nicht installiert."
25
+
26
+ #: admin/DynamicConditionsAdmin.php:70
27
+ msgid "Elementor not installed."
28
+ msgstr "Elementor nicht installiert."
29
+
30
+ #: admin/DynamicConditionsAdmin.php:93
31
+ msgid "Dynamic Conditions"
32
+ msgstr "Dynamic Conditions"
33
+
34
+ #: admin/DynamicConditionsAdmin.php:103
35
+ msgid "Dynamic Tag"
36
+ msgstr "Dynamic Tag"
37
+
38
+ #: admin/DynamicConditionsAdmin.php:117
39
+ msgid "Select condition field"
40
+ msgstr "Wähle Bedingungsfeld"
41
+
42
+ #: admin/DynamicConditionsAdmin.php:125
43
+ msgid "Show/Hide"
44
+ msgstr "Zeige/Verstecke"
45
+
46
+ #: admin/DynamicConditionsAdmin.php:129
47
+ msgid "Show when condition met"
48
+ msgstr "Zeige wenn Bedingung zutrifft"
49
+
50
+ #: admin/DynamicConditionsAdmin.php:130
51
+ msgid "Hide when condition met"
52
+ msgstr "Verstecke wenn Bedingung zutrifft"
53
+
54
+ #: admin/DynamicConditionsAdmin.php:143
55
+ msgid "Condition"
56
+ msgstr "Bedingung"
57
+
58
+ #: admin/DynamicConditionsAdmin.php:148
59
+ msgid "Is equal to"
60
+ msgstr "Ist identisch zu"
61
+
62
+ #: admin/DynamicConditionsAdmin.php:149
63
+ msgid "Is not equal to"
64
+ msgstr "Ist nicht identisch zu"
65
+
66
+ #: admin/DynamicConditionsAdmin.php:150
67
+ msgid "Contains"
68
+ msgstr "Enthält"
69
+
70
+ #: admin/DynamicConditionsAdmin.php:151
71
+ msgid "Does not contain"
72
+ msgstr "Enthält nicht"
73
+
74
+ #: admin/DynamicConditionsAdmin.php:152
75
+ msgid "Is empty"
76
+ msgstr "Ist leer"
77
+
78
+ #: admin/DynamicConditionsAdmin.php:153
79
+ msgid "Is not empty"
80
+ msgstr "Ist nicht leer"
81
+
82
+ #: admin/DynamicConditionsAdmin.php:154
83
+ msgid "Less than"
84
+ msgstr "Kleiner als"
85
+
86
+ #: admin/DynamicConditionsAdmin.php:155
87
+ msgid "Greater than"
88
+ msgstr "Größer als"
89
+
90
+ msgid "Between"
91
+ msgstr "Zwischen"
92
+
93
+ msgid "Compare Type"
94
+ msgstr "Vergleichs-Typ"
95
+
96
+ msgid "Date"
97
+ msgstr "Datum"
98
+
99
+ msgid "Months"
100
+ msgstr "Monate"
101
+
102
+ msgid "Weekdays"
103
+ msgstr "Wochentage"
104
+
105
+ #: admin/DynamicConditionsAdmin.php:158
106
+ msgid "Select your condition for this widget visibility."
107
+ msgstr "Wähle die Bedingung um das Widget anzuzeigen/verstecken."
108
+
109
+ msgid "Add a second condition value, if between is selected"
110
+ msgstr "Zweite Bedingung falls zwischen gewählt wurde"
111
+
112
+ #: admin/DynamicConditionsAdmin.php:168
113
+ msgid "Conditional value"
114
+ msgstr "Bedingter Wert"
115
+
116
+ msgid "Select what do you want to compare"
117
+ msgstr "Wähle aus was du vergleichen möchtest"
118
+
119
+ #: admin/DynamicConditionsAdmin.php:169
120
+ msgid "Add your conditional value to compare here."
121
+ msgstr "Gib hier deine Vergleichs-Bedingung an."
122
+
123
+ msgid "Supported Date and Time Formats"
124
+ msgstr "Unterstützte Datums- und Zeitformate"
125
+
126
+ msgid "Hide only content"
127
+ msgstr "Verstecke nur den Inhalt"
128
+
129
+ msgid "Resize other columns"
130
+ msgstr "Vergrößere andere Spalten"
131
+
132
+ msgid "If checked, only the inner content will be hidden, so you will see an empty section"
133
+ msgstr "Wenn aktiviert, wird nur der innere Inhalt versteckt und eine leere Section angezeigt"
134
+
135
+ msgid "Parse shortcodes"
136
+ msgstr "Führe Shortcodes aus"
137
+
138
+ msgid "In array"
139
+ msgstr "Im Array"
140
+
141
+ msgid "Use comma-separated values, to check if dynamic-value is equal with one of each item."
142
+ msgstr "Verwende Komma-getrennte Werte, um zu prüfen ob der Dynamic-Wert identisch mit dem einzelnem Wert ist."
143
+
144
+ msgid "Prevent date parsing"
145
+ msgstr "Verhindere Datums-Parsing"
146
+
147
+ msgid "Debug-Mode"
148
+ msgstr "Debug-Modus"
languages/dynamicconditions.pot ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Project-Id-Version: dynamic-conditions\n"
5
+ "POT-Creation-Date: 2018-11-07 14:41+0100\n"
6
+ "PO-Revision-Date: 2018-11-07 09:30+0100\n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: \n"
9
+ "Language: en\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.2\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: admin/DynamicConditionsAdmin.php:66
20
+ msgid "Elementor and Elementor Pro not installed."
21
+ msgstr ""
22
+
23
+ #: admin/DynamicConditionsAdmin.php:68
24
+ msgid "Elementor Pro not installed."
25
+ msgstr ""
26
+
27
+ #: admin/DynamicConditionsAdmin.php:70
28
+ msgid "Elementor not installed."
29
+ msgstr ""
30
+
31
+ #: admin/DynamicConditionsAdmin.php:93
32
+ msgid "Dynamic Conditions"
33
+ msgstr ""
34
+
35
+ #: admin/DynamicConditionsAdmin.php:103
36
+ msgid "Dynamic Tag"
37
+ msgstr ""
38
+
39
+ #: admin/DynamicConditionsAdmin.php:117
40
+ msgid "Select condition field"
41
+ msgstr ""
42
+
43
+ #: admin/DynamicConditionsAdmin.php:125
44
+ msgid "Show/Hide"
45
+ msgstr ""
46
+
47
+ #: admin/DynamicConditionsAdmin.php:129
48
+ msgid "Show when condition met"
49
+ msgstr ""
50
+
51
+ #: admin/DynamicConditionsAdmin.php:130
52
+ msgid "Hide when condition met"
53
+ msgstr ""
54
+
55
+ #: admin/DynamicConditionsAdmin.php:143
56
+ msgid "Condition"
57
+ msgstr ""
58
+
59
+ #: admin/DynamicConditionsAdmin.php:148
60
+ msgid "Is equal to"
61
+ msgstr ""
62
+
63
+ #: admin/DynamicConditionsAdmin.php:149
64
+ msgid "Is not equal to"
65
+ msgstr ""
66
+
67
+ #: admin/DynamicConditionsAdmin.php:150
68
+ msgid "Contains"
69
+ msgstr ""
70
+
71
+ #: admin/DynamicConditionsAdmin.php:151
72
+ msgid "Does not contain"
73
+ msgstr ""
74
+
75
+ #: admin/DynamicConditionsAdmin.php:152
76
+ msgid "Is empty"
77
+ msgstr ""
78
+
79
+ #: admin/DynamicConditionsAdmin.php:153
80
+ msgid "Is not empty"
81
+ msgstr ""
82
+
83
+ #: admin/DynamicConditionsAdmin.php:154
84
+ msgid "Less than"
85
+ msgstr "Kleiner als"
86
+
87
+ #: admin/DynamicConditionsAdmin.php:155
88
+ msgid "Greater than"
89
+ msgstr "Größer als"
90
+
91
+ #: admin/DynamicConditionsAdmin.php:158
92
+ msgid "Select your condition for this widget visibility."
93
+ msgstr ""
94
+
95
+ #: admin/DynamicConditionsAdmin.php:168
96
+ msgid "Conditional value"
97
+ msgstr ""
98
+
99
+ #: admin/DynamicConditionsAdmin.php:169
100
+ msgid ""
101
+ "Add your conditional value here if you selected equal to, not equal to or "
102
+ "contains on the selection above."
103
+ msgstr ""
languages/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
uninstall.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fired when the plugin is uninstalled.
5
+ *
6
+ * When populating this file, consider the following flow
7
+ * of control:
8
+ *
9
+ * - This method should be static
10
+ * - Check if the $_REQUEST content actually is the plugin name
11
+ * - Run an admin referrer check to make sure it goes through authentication
12
+ * - Verify the output of $_GET makes sense
13
+ * - Repeat with other user roles. Best directly by using the links/query string parameters.
14
+ * - Repeat things for multisite. Once for a single site in the network, once sitewide.
15
+ *
16
+ * This file may be updated more in future version of the Boilerplate; however, this is the
17
+ * general skeleton and outline for how the file should work.
18
+ *
19
+ * For more information, see the following discussion:
20
+ * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
21
+ *
22
+ * @link https://www.rto.de
23
+ * @since 1.0.0
24
+ *
25
+ * @package DynamicConditions
26
+ */
27
+
28
+ // If uninstall not called from WordPress, then exit.
29
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
30
+ exit;
31
+ }
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit808d05525ff962fd8697790ec816888f::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Lib\\' => array($baseDir . '/Legacy/Lib'),
10
+ 'DynamicConditions\\Pub\\' => array($baseDir . '/Public'),
11
+ 'DynamicConditions\\' => array($baseDir . '/'),
12
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit808d05525ff962fd8697790ec816888f
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit808d05525ff962fd8697790ec816888f', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit808d05525ff962fd8697790ec816888f', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit808d05525ff962fd8697790ec816888f::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ return $loader;
51
+ }
52
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit808d05525ff962fd8697790ec816888f
8
+ {
9
+ public static $prefixLengthsPsr4 = array (
10
+ 'L' =>
11
+ array (
12
+ 'Lib\\' => 4,
13
+ ),
14
+ 'D' =>
15
+ array (
16
+ 'DynamicConditions\\Pub\\' => 22,
17
+ 'DynamicConditions\\' => 18,
18
+ ),
19
+ );
20
+
21
+ public static $prefixDirsPsr4 = array (
22
+ 'Lib\\' =>
23
+ array (
24
+ 0 => __DIR__ . '/../..' . '/Legacy/Lib',
25
+ ),
26
+ 'DynamicConditions\\Pub\\' =>
27
+ array (
28
+ 0 => __DIR__ . '/../..' . '/Public',
29
+ ),
30
+ 'DynamicConditions\\' =>
31
+ array (
32
+ 0 => __DIR__ . '/../..' . '/',
33
+ ),
34
+ );
35
+
36
+ public static function getInitializer(ClassLoader $loader)
37
+ {
38
+ return \Closure::bind(function () use ($loader) {
39
+ $loader->prefixLengthsPsr4 = ComposerStaticInit808d05525ff962fd8697790ec816888f::$prefixLengthsPsr4;
40
+ $loader->prefixDirsPsr4 = ComposerStaticInit808d05525ff962fd8697790ec816888f::$prefixDirsPsr4;
41
+
42
+ }, null, ClassLoader::class);
43
+ }
44
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1 @@
 
1
+ []