PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 3.9.6
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v3.9.6
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 / visibility.php
widget-options / includes / widgets / option-tabs Last commit date
alignment.php 2 years ago days-dates.php 4 years ago devices.php 2 years ago settings.php 2 years ago state.php 2 years ago styling.php 4 years ago upsell.php 2 years ago visibility.php 2 years ago
visibility.php
481 lines
1 <?php
2
3 /**
4 * Pages Visibility 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 Visibility 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 visibility options
23 */
24 function widgetopts_tab_visibility($args)
25 { ?>
26 <li class="extended-widget-opts-tab-visibility">
27 <a href="#extended-widget-opts-tab-<?php echo $args['id']; ?>-visibility" title="<?php _e('Visibility', 'widget-options'); ?>"><span class="dashicons dashicons-visibility"></span> <span class="tabtitle"><?php _e('Visibility', 'widget-options'); ?></span></a>
28 </li>
29 <?php
30 }
31 add_action('extended_widget_opts_tabs', 'widgetopts_tab_visibility');
32
33 /**
34 * Called on 'extended_widget_opts_tabcontent'
35 * create new tab content options for visibility options
36 */
37 function widgetopts_tabcontent_visibility($args)
38 {
39 global $widget_options, $widgetopts_taxonomies, $widgetopts_pages, $widgetopts_types, $widgetopts_categories;
40
41 $checked = "";
42 $main = "";
43 $selected = 0;
44 $tax_opts = (array) get_option('extwopts_taxonomy_settings');
45 $pages = (!empty($widgetopts_pages)) ? $widgetopts_pages : array();
46 $taxonomies = (!empty($widgetopts_taxonomies)) ? $widgetopts_taxonomies : array();
47 $types = (!empty($widgetopts_types)) ? $widgetopts_types : array();
48 $categories = (!empty($widgetopts_categories)) ? $widgetopts_categories : array();
49
50 //declare miscellaneous pages - wordpress default pages
51 $misc = array(
52 'home' => __('Home/Front', 'widget-options'),
53 'blog' => __('Blog', 'widget-options'),
54 'archives' => __('Archives', 'widget-options'),
55 // 'single' => __( 'Single Post', 'widget-options' ),
56 '404' => __('404', 'widget-options'),
57 'search' => __('Search', 'widget-options')
58 );
59
60 //unset builtin post types
61 foreach (array('revision', 'attachment', 'nav_menu_item') as $unset) {
62 unset($types[$unset]);
63 }
64
65 //pro version only
66 // $get_terms = array();
67 // if( !empty( $widget_options['settings']['taxonomies'] ) && is_array( $widget_options['settings']['taxonomies'] ) ){
68 // foreach ( $widget_options['settings']['taxonomies'] as $tax_opt => $vall ) {
69 // $tax_name = 'widgetopts_taxonomy_'. $tax_opt;
70 // global $$tax_name;
71 // $get_terms[ $tax_opt ] = $$tax_name;
72 // }
73 // }
74
75
76 //get save values
77 $options_values = '';
78 $misc_values = array();
79 $pages_values = array();
80 $types_values = array();
81 $cat_values = array();
82 $tax_values = array();
83 $terms_values = array();
84 $acf_values = array();
85 if (isset($args['params']) && isset($args['params']['visibility'])) {
86
87 if (isset($args['params']['visibility']['options'])) {
88 $options_values = $args['params']['visibility']['options'];
89 }
90
91 if (isset($args['params']['visibility']['misc'])) {
92 $misc_values = $args['params']['visibility']['misc'];
93 }
94
95 if (isset($args['params']['visibility']['pages'])) {
96 $pages_values = $args['params']['visibility']['pages'];
97 }
98
99 if (isset($args['params']['visibility']['types'])) {
100 $types_values = $args['params']['visibility']['types'];
101 }
102
103 if (isset($args['params']['visibility']['categories'])) {
104 $cat_values = $args['params']['visibility']['categories'];
105 }
106
107 if (isset($args['params']['visibility']['taxonomies'])) {
108 $tax_values = $args['params']['visibility']['taxonomies'];
109 }
110
111 if (isset($args['params']['visibility']['tax_terms'])) {
112 $terms_values = $args['params']['visibility']['tax_terms'];
113 }
114
115 if (isset($args['params']['visibility']['acf'])) {
116 $acf_values = $args['params']['visibility']['acf'];
117 }
118
119 if (isset($args['params']['visibility']['selected'])) {
120 $selected = $args['params']['visibility']['selected'];
121 }
122
123 if (isset($args['params']['visibility']['main'])) {
124 $main = $args['params']['visibility']['main'];
125 }
126 }
127
128 // fix values for older settings
129 $tmpPages_values = array();
130 foreach ($pages_values as $objKey => $objPage) {
131 if (isset($pages_values[$objKey]) && $pages_values[$objKey] == '1') {
132 $tmpPages_values[] = $objKey;
133 } else {
134 $tmpPages_values[] = $objPage;
135 }
136 }
137 $pages_values = $tmpPages_values;
138
139 // fix values for older settings
140 $tmpTerms_values = array();
141 foreach ($cat_values as $objKey => $objTerm) {
142 if (isset($cat_values[$objKey]) && $cat_values[$objKey] == '1') {
143 $_objKey = $objKey;
144 if (is_numeric($objKey)) {
145 if (intval($objKey) == 0) {
146 $_objKey = 1;
147 }
148 }
149
150 $tmpTerms_values[] = $_objKey;
151 } else {
152 $_objTerm = $objTerm;
153 if (is_numeric($objTerm)) {
154 if (intval($objTerm) == 0) {
155 $_objTerm = 1;
156 }
157 }
158
159 $tmpTerms_values[] = $_objTerm;
160 }
161 }
162 $term_values = $tmpTerms_values;
163 ?>
164 <div id="extended-widget-opts-tab-<?php echo $args['id']; ?>-visibility" class="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-visibility">
165
166 <div class="extended-widget-opts-styling-tabs extended-widget-opts-inside-tabs">
167 <input type="hidden" id="extended-widget-opts-visibility-m-selectedtab" value="<?php echo $main; ?>" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][main]" />
168
169 <p class="widgetopts-subtitle"><?php _e('WordPress Pages', 'widget-options'); ?></p>
170 <div id="extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-main" class="extended-widget-opts-visibility-tabcontent extended-widget-opts-inside-tabcontent extended-widget-opts-inner-tabcontent">
171 <p><strong><?php _e('Hide/Show', 'widget-options'); ?></strong>
172 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][options]">
173 <option value="hide" <?php if ($options_values == 'hide') {
174 echo 'selected="selected"';
175 } ?>><?php _e('Hide on checked pages', 'widget-options'); ?></option>
176 <option value="show" <?php if ($options_values == 'show') {
177 echo 'selected="selected"';
178 } ?>><?php _e('Show on checked pages', 'widget-options'); ?></option>
179 </select>
180 </p>
181
182 <div class="extended-widget-opts-visibility-tabs extended-widget-opts-inside-tabs">
183 <input type="hidden" id="extended-widget-opts-visibility-selectedtab" value="<?php echo $selected; ?>" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][selected]" />
184 <!-- start tab nav -->
185 <ul class="extended-widget-opts-visibility-tabnav-ul">
186 <?php if (
187 isset($widget_options['settings']['visibility']) &&
188 isset($widget_options['settings']['visibility']['misc']) &&
189 '1' == $widget_options['settings']['visibility']['misc']
190 ) { ?>
191 <li class="extended-widget-opts-visibility-tab-visibility">
192 <a href="#extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-misc" title="<?php _e('Home, Blog, Search, etc..', 'widget-options'); ?>"><?php _e('Misc', 'widget-options'); ?></a>
193 </li>
194 <?php } ?>
195
196 <?php if (
197 isset($widget_options['settings']['visibility']) &&
198 isset($widget_options['settings']['visibility']['post_type']) &&
199 '1' == $widget_options['settings']['visibility']['post_type']
200 ) { ?>
201 <li class="extended-widget-opts-visibility-tab-visibility">
202 <a href="#extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-types" title="<?php _e('Pages & Custom Post Types', 'widget-options'); ?>"><?php _e('Post Types', 'widget-options'); ?></a>
203 </li>
204 <?php } ?>
205
206 <?php if (
207 isset($widget_options['settings']['visibility']) &&
208 isset($widget_options['settings']['visibility']['taxonomies']) &&
209 '1' == $widget_options['settings']['visibility']['taxonomies']
210 ) { ?>
211 <li class="extended-widget-opts-visibility-tab-visibility">
212 <a href="#extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-tax" title="<?php _e('Categories, Tags & Taxonomies', 'widget-options'); ?>"><?php _e('Taxonomies', 'widget-options'); ?></a>
213 </li>
214 <?php } ?>
215 <div class="extended-widget-opts-clearfix"></div>
216 </ul><!-- end tab nav -->
217 <div class="extended-widget-opts-clearfix"></div>
218
219 <?php if (
220 isset($widget_options['settings']['visibility']) &&
221 isset($widget_options['settings']['visibility']['misc']) &&
222 '1' == $widget_options['settings']['visibility']['misc']
223 ) { ?>
224 <!-- start misc tab content -->
225 <div id="extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-misc" class="extended-widget-opts-visibility-tabcontent extended-widget-opts-inner-tabcontent">
226 <div class="extended-widget-opts-misc">
227 <?php foreach ($misc as $key => $value) {
228 if (isset($misc_values[$key]) && $misc_values[$key] == '1') {
229 $checked = 'checked="checked"';
230 } else {
231 $checked = '';
232 }
233 ?>
234 <p>
235 <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][misc][<?php echo $key; ?>]" id="<?php echo $args['id']; ?>-opts-misc-<?php echo $key; ?>" value="1" <?php echo $checked; ?> />
236 <label for="<?php echo $args['id']; ?>-opts-misc-<?php echo $key; ?>"><?php echo $value; ?></label>
237 </p>
238 <?php } ?>
239 </div>
240 </div><!-- end misc tab content -->
241 <?php } ?>
242
243 <?php if (
244 isset($widget_options['settings']['visibility']) &&
245 isset($widget_options['settings']['visibility']['post_type']) &&
246 '1' == $widget_options['settings']['visibility']['post_type']
247 ) { ?>
248 <!-- start types tab content -->
249 <div id="extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-types" class="extended-widget-opts-visibility-tabcontent extended-widget-opts-inner-tabcontent extended-widget-opts-tabcontent-pages">
250 <div class="extended-widget-opts-inner-lists" style="height: 230px;padding: 5px;overflow:auto;">
251 <h4 id="extended-widget-opts-pages"><?php _e('Pages', 'widget-options'); ?> +/-<br>
252 <small>Type atleast 3 characters to initiate the search</small>
253 </h4>
254 <div class="extended-widget-opts-pages">
255 <select class="widefat extended-widget-opts-select2-dropdown extended-widget-opts-select2-page-dropdown" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][pages][]" data-namespace="<?php echo $args['namespace']; ?>" multiple="multiple">
256 <?php if (!empty($pages_values)) {
257 $pageLoop = get_pages(['hierarchical' => false, 'include' => $pages_values]);
258 foreach ($pageLoop as $objPage) {
259 echo '<option value="' . $objPage->ID . '" selected>' . $objPage->post_title . '</option>';
260 }
261 } ?>
262 </select>
263
264
265 <?php
266 // $page_class = new WidgetOpts_Pages_Checkboxes();
267 // $page_checkboxes = $page_class->walk( $widgetopts_pages, 0, $args );
268 // if ( $page_checkboxes ) {
269 // echo '<div class="widgetopts-ul-pages">' . $page_checkboxes . '</div>';
270 // }
271 ?>
272 </div>
273
274 <h4 id="extended-widget-opts-types"><?php _e('Custom Post Types', 'widget-options'); ?> +/-</h4>
275 <div class="extended-widget-opts-types">
276 <?php foreach ($types as $ptype => $type) {
277 // if ( ! $type->has_archive ) {
278 // // don't give the option if there is no archive page
279 // continue;
280 // }
281
282 if (isset($types_values[$ptype]) && $types_values[$ptype] == '1') {
283 $checked = 'checked="checked"';
284 } else {
285 $checked = '';
286 }
287 ?>
288 <p>
289 <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][types][<?php echo $ptype; ?>]" id="<?php echo $args['id']; ?>-opts-types-<?php echo $ptype; ?>" value="1" <?php echo $checked; ?> />
290 <label for="<?php echo $args['id']; ?>-opts-types-<?php echo $ptype; ?>"><?php echo stripslashes($type->labels->name); ?></label>
291 </p>
292 <?php } ?>
293 </div>
294 </div>
295 </div><!-- end types tab content -->
296 <?php } ?>
297
298 <?php if (
299 isset($widget_options['settings']['visibility']) &&
300 isset($widget_options['settings']['visibility']['taxonomies']) &&
301 '1' == $widget_options['settings']['visibility']['taxonomies']
302 ) { ?>
303 <!-- start tax tab content -->
304 <div id="extended-widget-opts-visibility-tab-<?php echo $args['id']; ?>-tax" class="extended-widget-opts-visibility-tabcontent extended-widget-opts-inner-tabcontent extended-widget-opts-tabcontent-taxonomies">
305 <div class="extended-widget-opts-inner-lists" style="height: 230px;padding: 5px;overflow:auto;">
306 <h4 id="extended-widget-opts-categories"><?php _e('Categories', 'widget-options'); ?> +/-<br>
307 <small>Type atleast 3 characters to initiate the search for Category term</small>
308 </h4>
309 <div class="extended-widget-opts-categories">
310 <select class="widefat extended-widget-opts-select2-dropdown extended-widget-opts-select2-taxonomy-dropdown" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][categories][]" data-taxonomy="category" data-namespace="<?php echo $args['namespace']; ?>" multiple="multiple">
311 <?php if (!empty($term_values)) {
312 $taxLoop = get_terms(['taxonomy' => 'category', 'include' => $term_values, 'hide_empty' => false]);
313 foreach ($taxLoop as $objTax) {
314 echo '<option value="' . $objTax->term_id . '" selected>' . $objTax->name . '</option>';
315 }
316 } ?>
317 </select>
318 </div>
319
320 <h4 id="extended-widget-opts-taxonomies"><?php _e('Taxonomies', 'widget-options'); ?> +/-</h4>
321 <div class="extended-widget-opts-taxonomies">
322 <?php foreach ($taxonomies as $taxonomy) {
323 if (isset($tax_values[$taxonomy->name]) && $tax_values[$taxonomy->name] == '1') {
324 $checked = 'checked="checked"';
325 } else {
326 $checked = '';
327 }
328 ?>
329 <p>
330 <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][taxonomies][<?php echo $taxonomy->name; ?>]" id="<?php echo $args['id']; ?>-opts-taxonomies-<?php echo $taxonomy->name; ?>" value="1" <?php echo $checked; ?> />
331 <label for="<?php echo $args['id']; ?>-opts-taxonomies-<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></label> <?php if (isset($taxonomy->object_type) && isset($taxonomy->object_type[0])) {
332 echo ' <small>- ' . $taxonomy->object_type[0] . '</small>';
333 } ?>
334 </p>
335 <?php } ?>
336 </div>
337 </div>
338 <?php $upgrade_link = apply_filters('widget_options_site_url', trailingslashit(WIDGETOPTS_PLUGIN_WEBSITE)); ?>
339 <div class="extended-widget-opts-feature-warning">
340 <small><?php _e('<em>Upgrade to <a href="' . $upgrade_link . '" target="_blank">Pro Version</a> to manage visibility for Custom Taxonomies.</em>', 'widget-options'); ?></small>
341 </div>
342 </div><!-- end tax tab content -->
343 <?php } ?>
344 </div><!-- end .extended-widget-opts-visibility-tabs -->
345 </div><!-- End WordPress Pages tab -->
346
347 <!-- Start ACF tab -->
348 <?php if (isset($widget_options['acf']) && 'activate' == $widget_options['acf']) : ?>
349 <p><br></p>
350 <p class="widgetopts-subtitle"><?php _e('ACF', 'widget-options'); ?></p>
351 <?php if (isset($widget_options['acf']) && 'activate' == $widget_options['acf']) : ?>
352 <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">
353 <?php
354 $fields = array();
355
356 if (function_exists('acf_get_field_groups')) {
357 $groups = acf_get_field_groups();
358 if (is_array($groups)) {
359 foreach ($groups as $group) {
360 $fields[$group['ID']] = array('title' => $group['title'], 'fields' => acf_get_fields($group));
361 }
362 }
363 } else {
364 $groups = apply_filters('acf/get_field_groups', array());
365 if (is_array($groups)) {
366 foreach ($groups as $group) {
367 $fields[$group['id']] = array('title' => $group['title'], 'fields' => apply_filters('acf/field_group/get_fields', array(), $group['id']));
368 }
369 }
370 }
371 ?>
372 <p><strong><?php _e('Hide/Show', 'widget-options'); ?></strong>
373 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][visibility]">
374 <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>
375 <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>
376 </select>
377 </p>
378
379 <p><strong><?php _e('Choose ACF Field', 'widget-options'); ?></strong>
380 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][field]">
381 <option value=""><?php _e('Select Field', 'widget-options'); ?></option>
382 <?php
383 if (!empty($fields)) {
384 foreach ($fields as $k => $field) { ?>
385 <optgroup label="<?php echo $field['title']; ?>">
386 <?php foreach ($field['fields'] as $key => $f) { ?>
387 <option value="<?php echo $f['key']; ?>" <?php echo (isset($acf_values['field']) && $acf_values['field'] == $f['key']) ? 'selected="selected"' : '' ?>><?php echo $f['label']; ?></option>
388 <?php } ?>
389 </optgroup>
390 <?php }
391 } ?>
392 </select>
393 </p>
394 <p><strong><?php _e('Condition', 'widget-options'); ?></strong>
395 <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][visibility][acf][condition]">
396 <option value=""><?php _e('Select Condition', 'widget-options'); ?></option>
397 <optgroup label="<?php _e('Conditional', 'widget-options'); ?>">
398 <option value="equal" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'equal') ? 'selected="selected"' : '' ?>><?php _e('Is Equal to', 'widget-options'); ?></option>
399 <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>
400 <option value="contains" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'contains') ? 'selected="selected"' : '' ?>><?php _e('Contains', 'widget-options'); ?></option>
401 <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>
402 </optgroup>
403 <optgroup label="<?php _e('Value Based', 'widget-options'); ?>">
404 <option value="empty" <?php echo (isset($acf_values['condition']) && $acf_values['condition'] == 'empty') ? 'selected="selected"' : '' ?>><?php _e('Is Empty', 'widget-options'); ?></option>
405 <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>
406 </optgroup>
407 </select>
408 </p>
409 <p><strong><?php _e('Conditional Value', 'widget-options'); ?></strong>
410 <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>
411 </p>
412 </div>
413 <?php endif; ?>
414 <?php endif; ?>
415 <!-- End ACF tab -->
416 </div><!-- end main tab -->
417
418 </div>
419 <?php
420 }
421 add_action('extended_widget_opts_tabcontent', 'widgetopts_tabcontent_visibility');
422
423 // Page Options
424 function widgetopts_ajax_page_search()
425 {
426 $response = [
427 'results' => [],
428 'pagination' => ['more' => false]
429 ];
430
431 if (!empty($_POST['term'])) {
432 $args = array(
433 'post_type' => 'page',
434 'post_status' => 'publish',
435 's' => $_POST['term'],
436 );
437
438 $query = new WP_Query($args);
439 while ($query->have_posts()) {
440 $query->the_post();
441 $response['results'][] = [
442 'id' => get_the_ID(),
443 'text' => get_the_title()
444 ];
445 }
446 }
447
448 echo json_encode($response);
449 die();
450 }
451 add_action('wp_ajax_widgetopts_ajax_page_search', 'widgetopts_ajax_page_search');
452
453 // Taxonomy Options
454 function widgetopts_ajax_taxonomy_search()
455 {
456 $response = [
457 'results' => [],
458 'pagination' => ['more' => false]
459 ];
460
461 if (!empty($_POST['term']) && $_POST['taxonomy']) {
462 $args = array(
463 'taxonomy' => array($_POST['taxonomy']),
464 'fields' => 'all',
465 'name__like' => $_POST['term'],
466 'hide_empty' => false
467 );
468
469 $terms = get_terms($args);
470 foreach ($terms as $term) {
471 $response['results'][] = [
472 'id' => $term->term_id,
473 'text' => $term->name
474 ];
475 }
476 }
477
478 echo json_encode($response);
479 die();
480 }
481 add_action('wp_ajax_widgetopts_ajax_taxonomy_search', 'widgetopts_ajax_taxonomy_search'); ?>