PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 4.0.5
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v4.0.5
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / includes / widgets / option-tabs / settings.php
widget-options / includes / widgets / option-tabs Last commit date
alignment.php 2 years ago animation.php 2 years ago behavior.php 2 years ago days-dates.php 2 years ago devices.php 2 years ago settings.php 2 years ago state.php 2 years ago styling.php 2 years ago upsell.php 2 years ago visibility.php 2 years ago
settings.php
195 lines
1 <?php
2
3 /**
4 * Settings Widget Options
5 *
6 * @copyright Copyright (c) 2015, Jeffrey Carandang
7 * @since 1.0
8 */
9
10 // Exit if accessed directly
11 if (!defined('ABSPATH')) exit;
12
13 /**
14 * Add Settings Widget Options Tab
15 *
16 * @since 1.0
17 * @return void
18 */
19
20 /**
21 * Called on 'extended_widget_opts_tabs'
22 * create new tab navigation for alignment options
23 */
24 if (!function_exists('widgetopts_tab_settings')) :
25 function widgetopts_tab_settings($args)
26 { ?>
27 <li class="extended-widget-opts-tab-class">
28 <a href="#extended-widget-opts-tab-<?php echo $args['id']; ?>-class" title="<?php _e('Logic & ACF', 'widget-options'); ?>"><span class="dashicons dashicons-code-standards"></span> <span class="tabtitle"><?php _e('Logic & ACF', 'widget-options'); ?></span></a>
29 </li>
30 <?php
31 }
32 add_action('extended_widget_opts_tabs', 'widgetopts_tab_settings', 8);
33 endif;
34
35 /**
36 * Called on 'extended_widget_opts_tabcontent'
37 * create new tab content options for alignment options
38 */
39 if (!function_exists('widgetopts_tabcontent_settings')) :
40 function widgetopts_tabcontent_settings($args)
41 {
42 global $widget_options;
43
44 $id = '';
45 $classes = '';
46 $logic = '';
47 $selected = 0;
48 $check = '';
49 if (isset($args['params']) && isset($args['params']['class'])) {
50 if (isset($args['params']['class']['id'])) {
51 $id = $args['params']['class']['id'];
52 }
53 if (isset($args['params']['class']['classes'])) {
54 $classes = $args['params']['class']['classes'];
55 }
56 if (isset($args['params']['class']['selected'])) {
57 $selected = $args['params']['class']['selected'];
58 }
59 if (isset($args['params']['class']['logic'])) {
60 $logic = $args['params']['class']['logic'];
61 }
62 if (isset($args['params']['class']['title']) && $args['params']['class']['title'] == '1') {
63 $check = 'checked="checked"';
64 }
65 }
66
67 if (isset($args['params']) && isset($args['params']['visibility'])) {
68 if (isset($args['params']['visibility']['acf'])) {
69 $acf_values = $args['params']['visibility']['acf'];
70 }
71 }
72
73 $predefined = array();
74 if (isset($widget_options['settings']['classes']) && isset($widget_options['settings']['classes']['classlists']) && !empty($widget_options['settings']['classes']['classlists'])) {
75 $predefined = $widget_options['settings']['classes']['classlists'];
76 }
77 ?>
78 <div id="extended-widget-opts-tab-<?php echo $args['id']; ?>-class" class="extended-widget-opts-tabcontent extended-widget-opts-inside-tabcontent extended-widget-opts-tabcontent-class">
79
80 <div class="extended-widget-opts-settings-tabs extended-widget-opts-inside-tabs">
81 <input type="hidden" id="extended-widget-opts-settings-selectedtab" value="<?php echo $selected; ?>" name="<?php echo $args['namespace']; ?>[extended_widget_opts][class][selected]" />
82 <!-- start tab nav -->
83 <ul style="margin-top: 10px;" class="extended-widget-opts-settings-tabnav-ul">
84
85 <?php if ('activate' == $widget_options['logic']) { ?>
86 <li class="extended-widget-opts-settings-tab-logic">
87 <a href="#extended-widget-opts-settings-tab-<?php echo $args['id']; ?>-logic" title="<?php _e('Display Logic', 'widget-options'); ?>"><?php _e('Logic', 'widget-options'); ?></a>
88 </li>
89 <?php } ?>
90
91 <?php if (isset($widget_options['acf']) && 'activate' == $widget_options['acf']) { ?>
92 <li class="extended-widget-opts-visibility-tab-acf">
93 <a href="#extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-acf" title="<?php _e('ACF', 'widget-options'); ?>"><?php _e('ACF', 'widget-options'); ?></a>
94 </li>
95 <?php } ?>
96 <div class="extended-widget-opts-clearfix"></div>
97 </ul><!-- end tab nav -->
98 <div class="extended-widget-opts-clearfix"></div>
99
100 <?php if ('activate' == $widget_options['logic']) { ?>
101 <!-- start logic tab content -->
102 <div id="extended-widget-opts-settings-tab-<?php echo $args['id']; ?>-logic" class="extended-widget-opts-settings-tabcontent extended-widget-opts-inner-tabcontent">
103 <div class="widget-opts-logic">
104 <p><small><?php _e('The text field lets you use <a href="http://codex.wordpress.org/Conditional_Tags" target="_blank">WP Conditional Tags</a>, or any general PHP code.', 'widget-options'); ?></small></p>
105 <textarea class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][class][logic]"><?php echo stripslashes($logic); ?></textarea>
106
107 <?php if (
108 !isset($widget_options['settings']['logic']) ||
109 (isset($widget_options['settings']['logic']) && !isset($widget_options['settings']['logic']['notice']))
110 ) { ?>
111 <p><a href="#" class="widget-opts-toggler-note"><?php _e('Click to Toggle Note', 'widget-options'); ?></a></p>
112 <p class="widget-opts-toggle-note"><small><?php _e('PLEASE NOTE that the display logic you introduce is EVAL\'d directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter <em>"widget_options_logic_override"</em> which you can use to bypass the EVAL with your own code if needed.', 'widget-options'); ?></small></p>
113 <?php } ?>
114 </div>
115 </div><!-- end logiv tab content -->
116 <?php } ?>
117
118 <!-- Start ACF tab -->
119 <?php if (isset($widget_options['acf']) && 'activate' == $widget_options['acf']) : ?>
120
121 <?php if (isset($widget_options['acf']) && 'activate' == $widget_options['acf']) : ?>
122 <div id="extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-acf" class="extended-widget-opts-visibility-tabcontent extended-widget-opts-inside-tabcontent extended-widget-opts-inner-tabcontent">
123 <p class="widgetopts-subtitle" style="display: none !important;"><?php _e('ACF', 'widget-options'); ?></p>
124 <?php
125 $fields = array();
126
127 if (function_exists('acf_get_field_groups')) {
128 $groups = acf_get_field_groups();
129 if (is_array($groups)) {
130 foreach ($groups as $group) {
131 $fields[$group['ID']] = array('title' => $group['title'], 'fields' => acf_get_fields($group));
132 }
133 }
134 } else {
135 $groups = apply_filters('acf/get_field_groups', array());
136 if (is_array($groups)) {
137 foreach ($groups as $group) {
138 $fields[$group['id']] = array('title' => $group['title'], 'fields' => apply_filters('acf/field_group/get_fields', array(), $group['id']));
139 }
140 }
141 }
142 ?>
143 <p><strong><?php _e('Hide/Show', 'widget-options'); ?></strong>
144 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][visibility]">
145 <option value="hide" <?php echo (isset($acf_values['visibility']) && $acf_values['visibility'] == 'hide') ? 'selected="selected"' : '' ?>><?php _e('Hide when Condition\'s met', 'widget-options'); ?></option>
146 <option value="show" <?php echo (isset($acf_values['visibility']) && $acf_values['visibility'] == 'show') ? 'selected="selected"' : '' ?>><?php _e('Show when Condition\'s met', 'widget-options'); ?></option>
147 </select>
148 </p>
149
150 <p><strong><?php _e('Choose ACF Field', 'widget-options'); ?></strong>
151 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][field]">
152 <option value=""><?php _e('Select Field', 'widget-options'); ?></option>
153 <?php
154 if (!empty($fields)) {
155 foreach ($fields as $k => $field) { ?>
156 <optgroup label="<?php echo $field['title']; ?>">
157 <?php foreach ($field['fields'] as $key => $f) { ?>
158 <option value="<?php echo $f['key']; ?>" <?php echo (isset($acf_values['field']) && $acf_values['field'] == $f['key']) ? 'selected="selected"' : '' ?>><?php echo $f['label']; ?></option>
159 <?php } ?>
160 </optgroup>
161 <?php }
162 } ?>
163 </select>
164 </p>
165 <p><strong><?php _e('Condition', 'widget-options'); ?></strong>
166 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][condition]">
167 <option value=""><?php _e('Select Condition', 'widget-options'); ?></option>
168 <optgroup label="<?php _e('Conditional', 'widget-options'); ?>">
169 <option value="equal" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'equal') ? 'selected="selected"' : '' ?>><?php _e('Is Equal to', 'widget-options'); ?></option>
170 <option value="not_equal" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'not_equal') ? 'selected="selected"' : '' ?>><?php _e('Is Not Equal to', 'widget-options'); ?></option>
171 <option value="contains" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'contains') ? 'selected="selected"' : '' ?>><?php _e('Contains', 'widget-options'); ?></option>
172 <option value="not_contains" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'not_contains') ? 'selected="selected"' : '' ?>><?php _e('Does Not Contain', 'widget-options'); ?></option>
173 </optgroup>
174 <optgroup label="<?php _e('Value Based', 'widget-options'); ?>">
175 <option value="empty" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'empty') ? 'selected="selected"' : '' ?>><?php _e('Is Empty', 'widget-options'); ?></option>
176 <option value="not_empty" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'not_empty') ? 'selected="selected"' : '' ?>><?php _e('Is Not Empty', 'widget-options'); ?></option>
177 </optgroup>
178 </select>
179 </p>
180 <p><strong><?php _e('Conditional Value', 'widget-options'); ?></strong>
181 <textarea name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][value]" id="<?php echo $args['id']; ?>-opts-acf-value" class="widefat widgetopts-acf-conditional"><?php echo (isset($acf_values['value'])) ? $acf_values['value'] : '' ?></textarea>
182 </p>
183 </div>
184 <?php endif; ?>
185 <?php endif; ?>
186 <!-- End ACF tab -->
187
188 </div><!-- end .extended-widget-opts-settings-tabs -->
189
190
191 </div>
192 <?php
193 }
194 add_action('extended_widget_opts_tabcontent', 'widgetopts_tabcontent_settings');
195 endif; ?>