public function _filter_field_category_filter($output, $field_array)
 {
     extract($field_array);
     $description_html = apply_filters('wpsc_settings_' . $name . '_description', $description, $field_array);
     if (!isset($class)) {
         $class = 'wpsc-settings-category-filter';
     }
     $output = '';
     $selected = wpsc_get_option('categories_to_filter');
     $output .= wpsc_form_radios($name, $selected, array('all' => _x('All categories', 'category filter settings', 'wpsc'), 'first_level' => _x('First level categories only', 'category filter settings', 'wpsc'), 'custom' => _x('Custom', 'category filter settings', 'wpsc')), array('id' => $id), false);
     $terms = get_terms('wpsc_product_category', array('hide_empty' => false));
     $options = array();
     foreach ($terms as $term) {
         $options[$term->term_id] = $term->name;
     }
     $selected = wpsc_get_option("categories_to_filter_custom");
     $output .= '<div class="wpsc-settings-category-filter-custom">';
     $output .= '<div class="wpsc-settings-category-filter-custom-all wpsc-settings-all-none">';
     $output .= sprintf(_x('Select: %1$s %2$s', 'select all / none', 'wpsc'), '<a href="#" data-for="' . $id . '-custom-select" class="wpsc-multi-select-all">' . _x('All', 'select all', 'wpsc') . '</a>', '<a href="#" data-for="' . $id . '-custom-select" class="wpsc-multi-select-none">' . _x('None', 'select none', 'wpsc') . '</a>');
     $output .= '</div>';
     $output .= wpsc_form_select("{$name}_custom[]", $selected, $options, array('id' => "{$id}-custom-select", 'class' => 'wpsc-multi-select', 'multiple' => 'multiple', 'size' => 5, 'data-placeholder' => __('Select categories', 'wpsc')), false);
     $output .= '</div>';
     return $output;
 }
Пример #2
0
function _wpsc_filter_control_select_region($output, $field, $args)
{
    global $wpdb;
    extract($field);
    $options = array();
    if ($country == 'all') {
        $state_data = $wpdb->get_results("SELECT `regions`.*, country.country as country, country.isocode as country_isocode FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id`");
        $options[__('No State', 'wp-e-commerce')] = array('' => __('No State', 'wp-e-commerce'));
        foreach ($state_data as $state) {
            if (!array_key_exists($state->country, $options)) {
                $options[$state->country] = array();
            }
            $options[$state->country][$state->id] = array('title' => $state->name, 'attributes' => array('data-alternative-spellings' => $state->code, 'data-country-id' => $state->country_id, 'data-country-isocode' => $state->country_isocode));
        }
    } else {
        $state_data = $wpdb->get_results($wpdb->prepare("SELECT `regions`.*, country.isocode as country FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN(%s)", $country));
        foreach ($state_data as $state) {
            $options[$state->id] = $state->name;
        }
    }
    $output .= wpsc_form_select($name, $value, $options, array('id' => $id . '-control', 'class' => 'wpsc-form-select-region'), false);
    return $output;
}
Пример #3
0
?>
	</li>
	<li>
		<?php 
printf(_x('%1$s %2$s %3$s', 'product category widget width / height option', 'wp-e-commerce'), wpsc_form_label(_x('Height:', 'product category widget', 'wp-e-commerce'), $this->get_field_id('height'), array(), false), wpsc_form_input($this->get_field_name('height'), $height, array('id' => $this->get_field_id('height'), 'size' => 3), false), __('px', 'wp-e-commerce'));
?>
	</li>
</ul>

<p>
	<?php 
echo _x('Select Categories:', 'product category widget', 'wp-e-commerce');
?>
<br />
	<small><?php 
esc_html_e('Leave all unchecked if you want to display all', 'wp-e-commerce');
?>
</small><br>
</p>
<p>
	<span class="wpsc-cat-drill-down-all-actions wpsc-settings-all-none">
		<?php 
printf(_x('Select: %1$s %2$s', 'select all / none', 'wp-e-commerce'), '<a href="#" data-for="' . esc_attr($this->get_field_id('categories')) . '" class="wpsc-multi-select-all">' . _x('All', 'select all', 'wp-e-commerce') . '</a>', '<a href="#" data-for="' . esc_attr($this->get_field_id('categories')) . '" class="wpsc-multi-select-none">' . __('None', 'wp-e-commerce') . '</a>');
?>
	</span><br>
	<?php 
wpsc_form_select($this->get_field_name('categories') . '[]', $instance['categories'], $options, array('id' => $this->get_field_id('categories'), 'multiple' => 'multiple', 'size' => 5, 'class' => 'wpsc-multi-select widefat', 'data-placeholder' => __('Select categories', 'wp-e-commerce')));
?>
</p>

    public function form($instance)
    {
        $instance = wp_parse_args($instance, $this->defaults);
        $terms = get_terms('wpsc_product_category', array('hide_empty' => false));
        $options = array();
        foreach ($terms as $term) {
            $options[$term->term_id] = $term->name;
        }
        ?>
<p>
	<?php 
        wpsc_form_label(_x('Title', 'widget title', 'wpsc'), $this->get_field_id('title'));
        ?>
<br>
	<?php 
        wpsc_form_input($this->get_field_name('title'), $instance['title'], array('id' => $this->get_field_id('title'), 'class' => 'widefat'));
        ?>
</p>

<p>
	<?php 
        wpsc_form_label(__('Categories to display', 'wpsc'), $this->get_field_id('categories'));
        ?>
<br>
	<span class="wpsc-cat-drill-down-all-actions wpsc-settings-all-none">
		<?php 
        printf(_x('Select: %1$s %2$s', 'select all / none', 'wpsc'), '<a href="#" data-for="' . esc_attr($this->get_field_id('categories')) . '" class="wpsc-multi-select-all">' . _x('All', 'select all', 'wpsc') . '</a>', '<a href="#" data-for="' . esc_attr($this->get_field_id('categories')) . '" class="wpsc-multi-select-none">' . __('None', 'wpsc') . '</a>');
        ?>
	</span><br>
	<?php 
        wpsc_form_select($this->get_field_name('categories') . '[]', $instance['categories'], $options, array('id' => $this->get_field_id('categories'), 'multiple' => 'multiple', 'size' => 5, 'class' => 'wpsc-multi-select widefat', 'data-placeholder' => __('Select categories', 'wpsc')));
        ?>
</p>
<?php 
    }