/** * Print terms for the element selected * * @access public * @return void */ public function ajax_print_terms() { $type = $_POST['value']; $attribute = $_POST['attribute']; $return = array('message' => '', 'content' => $_POST); $terms = get_terms('pa_' . $attribute, array('hide_empty' => '0')); $return['content'] = king_filter_attributes_table($type, $attribute, $_POST['id'], $_POST['name'], json_decode($_POST['value']), false); echo json_encode($return); die; }
function form($instance) { global $woocommerce; $defaults = array('title' => '', 'attribute' => '', 'query_type' => 'and', 'type' => 'list', 'colors' => '', 'labels' => '', 'display' => 'all'); $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label> <strong><?php _e('Title', 'king'); ?> :</strong><br /> <input class="widefat" type="text" id="<?php echo esc_attr($this->get_field_id('title')); ?> " name="<?php echo esc_attr($this->get_field_name('title')); ?> " value="<?php echo esc_attr($instance['title']); ?> " /> </label> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('attribute')); ?> "><strong><?php _e('Attribute:', 'king'); ?> </strong></label> <select class="king_filter_attributes widefat" id="<?php echo esc_attr($this->get_field_id('attribute')); ?> " name="<?php echo esc_attr($this->get_field_name('attribute')); ?> "> <?php king_filter_dropdown_attributes($instance['attribute']); ?> </select></p> <p><label for="<?php echo esc_attr($this->get_field_id('query_type')); ?> "><?php _e('Query Type:', 'king'); ?> </label> <select id="<?php echo esc_attr($this->get_field_id('query_type')); ?> " name="<?php echo esc_attr($this->get_field_name('query_type')); ?> "> <option value="and" <?php selected($instance['query_type'], 'and'); ?> ><?php _e('AND', 'king'); ?> </option> <option value="or" <?php selected($instance['query_type'], 'or'); ?> ><?php _e('OR', 'king'); ?> </option> </select></p> <p><label for="<?php echo esc_attr($this->get_field_id('type')); ?> "><strong><?php _e('Type:', 'king'); ?> </strong></label> <select class="king_filter_type widefat" id="<?php echo esc_attr($this->get_field_id('type')); ?> " name="<?php echo esc_attr($this->get_field_name('type')); ?> "> <option value="list" <?php selected('list', $instance['type']); ?> ><?php _e('List', 'king'); ?> </option> <option value="color" <?php selected('color', $instance['type']); ?> ><?php _e('Color', 'king'); ?> </option> <option value="label" <?php selected('label', $instance['type']); ?> ><?php _e('Label', 'king'); ?> </option> <option value="select" <?php selected('select', $instance['type']); ?> ><?php _e('Dropdown', 'king'); ?> </option> </select> </p> <p id="dev-filter-display" class="dev-filter-display-<?php echo esc_attr($instance['type']); ?> "> <label for="<?php echo esc_attr($this->get_field_id('display')); ?> "><strong><?php _e('Display (default All):', 'king'); ?> </strong></label> <select class="king_filter_type widefat" id="<?php echo esc_attr($this->get_field_id('display')); ?> " name="<?php echo esc_attr($this->get_field_name('display')); ?> "> <option value="all" <?php selected('all', $instance['display']); ?> > <?php _e('All (no hierarchical)', 'king'); ?> </option> <option value="hierarchical" <?php selected('hierarchical', $instance['display']); ?> > <?php _e('All Hierarchical', 'king'); ?> </option> <option value="parent" <?php selected('parent', $instance['display']); ?> > <?php _e('Only Parent', 'king'); ?> </option> </select> </p> <div class="king_filter_placeholder"> <?php king_filter_attributes_table($instance['type'], $instance['attribute'], 'widget-' . $this->id . '-', 'widget-' . $this->id_base . '[' . $this->number . ']', $instance['type'] == 'color' ? $instance['colors'] : ($instance['type'] == 'label' ? $instance['labels'] : array()), $instance['display']); ?> </div> <span class="spinner" style="display: none;"></span> <input type="hidden" name="widget_id" value="widget-<?php echo esc_attr($this->id); ?> -" /> <input type="hidden" name="widget_name" value="widget-<?php echo esc_attr($this->id_base); ?> [<?php echo esc_attr($this->number); ?> ]" /> <script>jQuery(document).trigger('king_colorpicker');</script> <?php }