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