コード例 #1
0
ファイル: pf-settings.php プロジェクト: hikaram/wee
    public static function get_terms($filter, $customization, $addkey)
    {
        /*			$curr_tax = ( isset($_POST['taxonomy']) ? $_POST['taxonomy'] : '' );
        			$curr_style = ( isset($_POST['style']) ? $_POST['style'] : '' );*/
        if ($filter == '') {
            return '';
        }
        $curr_style = $customization['style'];
        $settings = $customization['settings'];
        if (taxonomy_exists($filter) && !in_array($filter, array('price', 'per_page'))) {
            $catalog_attrs = get_terms($filter, array('hide_empty' => false));
        } else {
            switch ($filter) {
                case 'instock':
                    $curr_set = apply_filters('prdctfltr_catalog_instock', array('both' => __('All Products', 'prdctfltr'), 'in' => __('In Stock', 'prdctfltr'), 'out' => __('Out Of Stock', 'prdctfltr')));
                    foreach ($curr_set as $k => $v) {
                        $catalog_attrs[] = (object) array('slug' => $k, 'name' => $v);
                    }
                    break;
                case 'sort':
                    $curr_set = apply_filters('prdctfltr_catalog_orderby', array('' => apply_filters('prdctfltr_none_text', __('None', 'prdctfltr')), 'menu_order' => __('Default', 'prdctfltr'), 'comment_count' => __('Review Count', 'prdctfltr'), 'popularity' => __('Popularity', 'prdctfltr'), 'rating' => __('Average rating', 'prdctfltr'), 'date' => __('Newness', 'prdctfltr'), 'price' => __('Price: low to high', 'prdctfltr'), 'price-desc' => __('Price: high to low', 'prdctfltr'), 'rand' => __('Random Products', 'prdctfltr'), 'title' => __('Product Name', 'prdctfltr')));
                    foreach ($curr_set as $k => $v) {
                        $catalog_attrs[] = (object) array('slug' => $k, 'name' => $v);
                    }
                    break;
                case 'price':
                    $filter_customization = WC_Prdctfltr::get_filter_customization('price', $addkey);
                    if (!empty($filter_customization) && isset($filter_customization['settings']) && is_array($filter_customization['settings'])) {
                        foreach ($filter_customization['settings'] as $k => $v) {
                            $catalog_attrs[] = (object) array('slug' => $k, 'name' => $v);
                        }
                    } else {
                        $curr_price_set = get_option('wc_settings_prdctfltr_price_range', 100);
                        $curr_price_add = get_option('wc_settings_prdctfltr_price_range_add', 100);
                        $curr_price_limit = get_option('wc_settings_prdctfltr_price_range_limit', 6);
                        global $wpdb;
                        $min = floor($wpdb->get_var($wpdb->prepare('
									SELECT min(meta_value + 0)
									FROM %1$s
									LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id
									WHERE ( meta_key = \'%3$s\' OR meta_key = \'%4$s\' )
									AND meta_value != ""
									', $wpdb->posts, $wpdb->postmeta, '_price', '_min_variation_price')));
                        if (get_option('wc_settings_prdctfltr_price_none', 'no') == 'no') {
                            $catalog_ready_price = array('-' => apply_filters('prdctfltr_none_text', __('None', 'prdctfltr')));
                        }
                        for ($i = 0; $i < $curr_price_limit; $i++) {
                            if ($i == 0) {
                                $min_price = $min;
                                $max_price = $curr_price_set;
                            } else {
                                $min_price = $curr_price_set + ($i - 1) * $curr_price_add;
                                $max_price = $curr_price_set + $i * $curr_price_add;
                            }
                            $slug = $min_price . '-' . ($i + 1 == $curr_price_limit ? '' : $max_price);
                            $name = wc_price($min_price) . ($i + 1 == $curr_price_limit ? '+' : ' - ' . wc_price($max_price));
                            $catalog_attrs[] = (object) array('slug' => $slug, 'name' => $name);
                        }
                    }
                    break;
                case 'per_page':
                    $filter_customization = WC_Prdctfltr::get_filter_customization('price', $addkey);
                    if (!empty($filter_customization) && isset($filter_customization['settings']) && is_array($filter_customization['settings'])) {
                        foreach ($filter_customization['settings'] as $v) {
                            $catalog_attrs[] = (object) array('slug' => $v['value'], 'name' => $v['text']);
                        }
                    } else {
                        $curr_perpage_set = get_option('wc_settings_prdctfltr_perpage_range', 20);
                        $curr_perpage_limit = get_option('wc_settings_prdctfltr_perpage_range', 5);
                        $curr_perpage = array();
                        for ($i = 1; $i <= $curr_perpage_limit; $i++) {
                            $slug = $curr_perpage_set * $i;
                            $name = $curr_perpage_set * $i . ' ' . (get_option('wc_settings_prdctfltr_perpage_label', '') == '' ? __('Products', 'prdctfltr') : get_option('wc_settings_prdctfltr_perpage_label', ''));
                            $catalog_attrs[] = (object) array('slug' => $slug, 'name' => $name);
                        }
                    }
                    break;
                default:
                    $catalog_attrs = array();
                    break;
            }
        }
        if (!empty($catalog_attrs)) {
            ob_start();
            switch ($curr_style) {
                case 'text':
                    ?>
							<div class="prdctfltr_st_term_style">
								<span class="prdctfltr_st_option">
									<em><?php 
                    _e('Type', 'prdctfltr');
                    ?>
</em>
									<select name="type">
								<?php 
                    $styles = array('border' => __('Border', 'prdctfltr_set_termswoo'), 'background' => __('Background', 'prdctfltr_set_termswoo'), 'round' => __('Round', 'prdctfltr_set_termswoo'));
                    $selected = isset($settings['type']) ? $settings['type'] : 'border';
                    $c = 0;
                    foreach ($styles as $k => $v) {
                        ?>
										<option value="<?php 
                        echo $k;
                        ?>
"<?php 
                        echo $selected == $k ? ' selected="selected"' : '';
                        ?>
><?php 
                        echo $v;
                        ?>
</option>
								<?php 
                        $c++;
                    }
                    ?>
									</select>
								</span>
								<span class="prdctfltr_st_option">
									<em><?php 
                    _e('Normal', 'prdctfltr');
                    ?>
</em> <input class="prdctfltr_st_color" type="text" name="normal" value="<?php 
                    echo isset($settings['normal']) ? $settings['normal'] : '#bbbbbb';
                    ?>
" />
								</span>
								<span class="prdctfltr_st_option">
									<em><?php 
                    _e('Active', 'prdctfltr');
                    ?>
</em> <input class="prdctfltr_st_color" type="text" name="active" value="<?php 
                    echo isset($settings['active']) ? $settings['active'] : '#333333';
                    ?>
" />
								</span>
								<span class="prdctfltr_st_option">
									<em><?php 
                    _e('Disabled', 'prdctfltr');
                    ?>
</em> <input class="prdctfltr_st_color" type="text" name="disabled" value="<?php 
                    echo isset($settings['disabled']) ? $settings['disabled'] : '#eeeeee';
                    ?>
"/>
								</span>

							</div>
						<?php 
                    foreach ($catalog_attrs as $term) {
                        ?>
								<div class="prdctfltr_st_term prdctfltr_style_text" data-term="<?php 
                        echo $term->slug;
                        ?>
">
									<span class="prdctfltr_st_option prdctfltr_st_option_plaintext">
										<em><?php 
                        echo $term->name . ' ' . __('Tooltip', 'prdctfltr');
                        ?>
</em> <input type="text" name="tooltip_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['tooltip_' . $term->slug]) ? $settings['tooltip_' . $term->slug] : '';
                        ?>
" />
									</span>
								</div>
							<?php 
                    }
                    break;
                case 'color':
                    foreach ($catalog_attrs as $term) {
                        ?>
							<div class="prdctfltr_st_term prdctfltr_style_color" data-term="<?php 
                        echo $term->slug;
                        ?>
">
								<span class="prdctfltr_st_option prdctfltr_st_option_color">
									<em><?php 
                        echo $term->name . ' ' . __('Color', 'prdctfltr');
                        ?>
</em> <input class="prdctfltr_st_color" type="text" name="term_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['term_' . $term->slug]) ? $settings['term_' . $term->slug] : '#cccccc';
                        ?>
" />
								</span>
								<span class="prdctfltr_st_option prdctfltr_st_option_tooltip">
									<em><?php 
                        echo $term->name . ' ' . __('Tooltip', 'prdctfltr');
                        ?>
</em> <input type="text" name="tooltip_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['tooltip_' . $term->slug]) ? $settings['tooltip_' . $term->slug] : '';
                        ?>
" />
								</span>
							</div>
						<?php 
                    }
                    break;
                case 'image':
                    foreach ($catalog_attrs as $term) {
                        ?>
							<div class="prdctfltr_st_term prdctfltr_style_image" data-term="<?php 
                        echo $term->slug;
                        ?>
">
								<span class="prdctfltr_st_option prdctfltr_st_option_imgurl">
									<em><?php 
                        echo $term->name . ' ' . __('Image URL', 'prdctfltr');
                        ?>
</em> <input type="text" name="term_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['term_' . $term->slug]) ? $settings['term_' . $term->slug] : '';
                        ?>
" />
								</span>
								<span class="prdctfltr_st_option prdctfltr_st_option_button">
									<em><?php 
                        _e('Add/Upload image', 'prdctfltr_set_termswoo');
                        ?>
</em> <a href="#" class="prdctfltr_st_upload_media button"><?php 
                        _e('Image Gallery', 'prdctfltr');
                        ?>
</a>
								</span>
								<span class="prdctfltr_st_option prdctfltr_st_option_tooltip">
									<em><?php 
                        echo $term->name . ' ' . __('Tooltip', 'prdctfltr');
                        ?>
</em> <input type="text" name="tooltip_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['tooltip_' . $term->slug]) ? $settings['tooltip_' . $term->slug] : '';
                        ?>
" />
								</span>
							</div>
						<?php 
                    }
                    break;
                case 'html':
                    foreach ($catalog_attrs as $term) {
                        ?>
							<div class="prdctfltr_st_term prdctfltr_style_html" data-term="<?php 
                        echo $term->slug;
                        ?>
">
								<span class="prdctfltr_st_option prdctfltr_st_option_html">
									<em><?php 
                        echo $term->name . ' ' . __('HTML', 'prdctfltr');
                        ?>
</em> <textarea type="text" name="term_<?php 
                        echo $term->slug;
                        ?>
"><?php 
                        echo isset($settings['term_' . $term->slug]) ? $settings['term_' . $term->slug] : '';
                        ?>
</textarea>
								</span>
								<span class="prdctfltr_st_option prdctfltr_st_option_tooltip">
									<em><?php 
                        echo $term->name . ' ' . __('Tooltip', 'prdctfltr');
                        ?>
</em> <input type="text" name="tooltip_<?php 
                        echo $term->slug;
                        ?>
" value="<?php 
                        echo isset($settings['tooltip_' . $term->slug]) ? $settings['tooltip_' . $term->slug] : '';
                        ?>
" />
								</span>
							</div>
						<?php 
                    }
                    break;
                case 'select':
                    ?>
						<div class="prdctfltr_select">
							<?php 
                    _e('Select Box currently has no special options. !Important Do not use select boxes inside the select box mode!', 'prdctfltr');
                    ?>
						</div>
					<?php 
                    break;
                default:
                    break;
            }
            $html = ob_get_clean();
            return $html;
        } else {
            return '';
        }
    }
コード例 #2
0
                    } else {
                        $max_price = ' +';
                    }
                    echo '<a href="#" data-key="byprice"><i class="prdctfltr-delete"></i></a> <span>' . $min_price . (isset($max_price) && $max_price > 0 ? ' - ' . strip_tags(wc_price($max_price)) : $max_price) . '</span> / ';
                }
            }
            if ($curr_options['wc_settings_prdctfltr_price_title'] != '') {
                echo $curr_options['wc_settings_prdctfltr_price_title'];
            } else {
                _e('Price range', 'prdctfltr');
            }
            ?>
							<i class="prdctfltr-down"></i>
							<?php 
            echo $pf_after_title;
            $filter_customization = WC_Prdctfltr::get_filter_customization('price', $curr_options['wc_settings_prdctfltr_price_filter_customization']);
            $catalog_ready_price = array();
            $curr_price = isset($pf_activated['min_price']) ? $pf_activated['min_price'] . '-' . (isset($pf_activated['max_price']) ? $pf_activated['max_price'] : '') : '';
            if (!empty($filter_customization) && isset($filter_customization['settings']) && is_array($filter_customization['settings'])) {
                if ($curr_options['wc_settings_prdctfltr_price_none'] == 'no') {
                    $catalog_ready_price = array('-' => apply_filters('prdctfltr_none_text', __('None', 'prdctfltr')));
                }
                foreach ($filter_customization['settings'] as $k => $v) {
                    $catalog_ready_price[$k] = $v;
                }
            } else {
                $curr_prices = array();
                $curr_prices_currency = array();
                $curr_price_set = $curr_options['wc_settings_prdctfltr_price_range'];
                $curr_price_add = $curr_options['wc_settings_prdctfltr_price_range_add'];
                $curr_price_limit = $curr_options['wc_settings_prdctfltr_price_range_limit'];