Changeset 2267313
- Timestamp:
- 03/25/2020 12:46:40 PM (6 years ago)
- Location:
- search-filter/trunk
- Files:
-
- 4 edited
-
of-admin.php (modified) (1 diff)
-
of-taxonomy-walker.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
-
search-filter.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
search-filter/trunk/of-admin.php
r1986250 r2267313 64 64 This will display a search box, a category dropdown and a tag dropdown. You can use the shortcode within posts/pages and widget areas.<br /><br /> 65 65 66 To use this within a theme file you simple need to call the `do_shor code` function with the shortcode above within the theme file:<br />66 To use this within a theme file you simple need to call the `do_shortcode` function with the shortcode above within the theme file:<br /> 67 67 68 68 <pre><code class="php"><?php echo do_shortcode( \'[searchandfilter fields="search,category,post_tag"]\' ); ?></code></pre> -
search-filter/trunk/of-taxonomy-walker.php
r1196498 r2267313 2 2 3 3 class Taxonomy_Walker extends Walker_Category { 4 5 4 6 5 private $type = ''; … … 11 10 12 11 function __construct($type = 'checkbox', $defaults = array()) { 13 // fetch the list of term ids for the given post14 //$this->term_ids = wp_get_post_terms( $post_id, $taxonomy, 'fields=ids' );15 12 16 13 $this->type = $type; … … 19 16 20 17 function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { 21 /*$display = false;22 18 23 $id = $element->term_id; 24 25 $display = true; 26 if ( isset( $children_elements[ $id ] ) ) { 27 // the current term has children 28 foreach ( $children_elements[ $id ] as $child ) { 29 if ( in_array( $child->term_id, $this->term_ids ) ) { 30 // one of the term's children is in the list 31 $display = true; 32 // can stop searching now 33 break; 34 } 35 } 36 } 37 38 if ( $display )*/ 39 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); 19 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); 40 20 } 41 21 … … 43 23 function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) 44 24 { 45 46 25 if($this->type=="list") 47 26 { … … 120 99 if($defaults) 121 100 { 122 $noselected = count($this->defaults); 123 124 if(($noselected>0)&&(is_array($defaults))) 101 if(is_array($defaults)) 125 102 { 126 foreach($defaults as $defaultid) 103 $noselected = count($defaults); 104 105 if($noselected>0) 127 106 { 128 if($defaultid==$cat_id)107 foreach($defaults as $defaultid) 129 108 { 130 $checked = ' checked="checked"'; 109 if($defaultid==$cat_id) 110 { 111 $checked = ' checked="checked"'; 112 } 131 113 } 132 114 } … … 171 153 if($defaults) 172 154 { 173 $noselected = count($this->defaults); 174 175 if(($noselected>0)&&(is_array($defaults))) 155 if(is_array($defaults)) 176 156 { 177 foreach($defaults as $defaultid) 157 $noselected = count($defaults); 158 159 if($noselected>0) 178 160 { 179 if($defaultid==$cat_id)161 foreach($defaults as $defaultid) 180 162 { 181 $checked = ' selected="selected"'; 163 if($defaultid==$cat_id) 164 { 165 $checked = ' selected="selected"'; 166 } 182 167 } 183 168 } -
search-filter/trunk/readme.txt
r2234765 r2267313 5 5 Requires at least: 3.5 6 6 Tested up to: 5.3 7 Stable tag: 1.2.1 17 Stable tag: 1.2.12 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 35 35 == Changelog == 36 37 = 1.2.12 = 38 * Fixed - some PHP warnings when using radio, checkbox and multiselects 39 * Fixed - a typo (thanks sunjunkie) 40 * Tested with WP 5.3 36 41 37 42 = 1.2.11 = -
search-filter/trunk/search-filter.php
r1986250 r2267313 6 6 Author: Designs & Code 7 7 Author URI: http://www.designsandcode.com/ 8 Version: 1.2.1 18 Version: 1.2.12 9 9 Text Domain: searchandfilter 10 10 License: GPLv2 … … 15 15 */ 16 16 if (!defined('SEARCHANDFILTER_VERSION_NUM')) 17 define('SEARCHANDFILTER_VERSION_NUM', '1.2.1 1');17 define('SEARCHANDFILTER_VERSION_NUM', '1.2.12'); 18 18 19 19 if (!defined('SEARCHANDFILTER_THEME_DIR')) … … 1107 1107 foreach($post_types as $post_type) 1108 1108 { 1109 $returnvar .= "<input type=\"hidden\" name=\"".SF_FPRE."post_types[]\" value=\"". $post_type."\" />";1109 $returnvar .= "<input type=\"hidden\" name=\"".SF_FPRE."post_types[]\" value=\"".esc_attr($post_type)."\" />"; 1110 1110 } 1111 1111 } … … 1128 1128 } 1129 1129 $clean_searchterm = (esc_attr($this->searchterm)); 1130 $returnvar .= '<input type="text" name="'.SF_FPRE.'search" placeholder="'. $search_placeholder.'" value="'.$clean_searchterm.'">';1130 $returnvar .= '<input type="text" name="'.SF_FPRE.'search" placeholder="'.esc_attr($search_placeholder).'" value="'.esc_attr($clean_searchterm).'">'; 1131 1131 $returnvar .= '</li>'; 1132 1132 } … … 1176 1176 $returnvar .= 1177 1177 '<input type="hidden" name="'.SF_FPRE.'submitted" value="1"> 1178 <input type="submit" value="'. $submitlabel.'">1178 <input type="submit" value="'.esc_attr($submitlabel).'"> 1179 1179 </li>'; 1180 1180 … … 1437 1437 if(($operators[$i]=="and")||($operators[$i]=="or")) 1438 1438 { 1439 $returnvar .= '<input type="hidden" name="'. SF_FPRE.$taxonomy.'_operator" value="'.$operators[$i].'" />';1439 $returnvar .= '<input type="hidden" name="'.esc_attr(SF_FPRE.$taxonomy).'_operator" value="'.esc_attr($operators[$i]).'" />'; 1440 1440 } 1441 1441 } … … 1521 1521 $checked = ($defaultval=="0") ? " checked='checked'" : ""; 1522 1522 $returnvar = '<ul>'; 1523 $returnvar .= '<li>'."<label><input type='radio' name='". $args['sf_name']."[]' value='0'$checked /> ".$show_option_all."</label>".'</li>';1523 $returnvar .= '<li>'."<label><input type='radio' name='".esc_attr($args['sf_name'])."[]' value='0'$checked /> ".$show_option_all."</label>".'</li>'; 1524 1524 $returnvar .= walk_taxonomy('radio', $args); 1525 1525 $returnvar .= "</ul>"; … … 1601 1601 } 1602 1602 } 1603 $returnvar .= '<li class="cat-item"><label><input class="postform cat-item" type="checkbox" name="'. SF_FPRE.$name.'[]" value="'.$dropdown->term_id.'"'.$checked.'> '.$dropdown->cat_name.'</label></li>';1603 $returnvar .= '<li class="cat-item"><label><input class="postform cat-item" type="checkbox" name="'.esc_attr(SF_FPRE.$name).'[]" value="'.esc_attr($dropdown->term_id).'"'.$checked.'> '.$dropdown->cat_name.'</label></li>'; 1604 1604 1605 1605 } … … 1659 1659 } 1660 1660 1661 $returnvar .= '<li class="cat-item"><label><input class="postform" type="radio" name="'. SF_FPRE.$name.'[]" value="'.$defaultval.'"'.$checked.'> '.$all_items_name.'</label></li>';1661 $returnvar .= '<li class="cat-item"><label><input class="postform" type="radio" name="'.esc_attr(SF_FPRE.$name).'[]" value="'.esc_attr($defaultval).'"'.$checked.'> '.$all_items_name.'</label></li>'; 1662 1662 } 1663 1663 … … 1684 1684 } 1685 1685 } 1686 $returnvar .= '<li class="cat-item"><label><input class="postform" type="radio" name="'. SF_FPRE.$name.'[]" value="'.$dropdown->term_id.'"'.$checked.'> '.$dropdown->cat_name.'</label></li>';1686 $returnvar .= '<li class="cat-item"><label><input class="postform" type="radio" name="'.esc_attr(SF_FPRE.$name).'[]" value="'.esc_attr($dropdown->term_id).'"'.$checked.'> '.$dropdown->cat_name.'</label></li>'; 1687 1687 1688 1688 } … … 1711 1711 } 1712 1712 1713 $returnvar .= '<input class="postform" type="date" name="'. SF_FPRE.$name.'[]" value="' . $current_date .'" />';1713 $returnvar .= '<input class="postform" type="date" name="'.esc_attr(SF_FPRE.$name).'[]" value="'. esc_attr($current_date) .'" />'; 1714 1714 1715 1715 return $returnvar; … … 1723 1723 $args['walker'] = new Taxonomy_Walker($type, $args['sf_name']); 1724 1724 1725 //unset($args['sf_name']);1726 1727 1725 $output = wp_list_categories($args); 1728 if ( $output ) 1726 if ( $output ){ 1729 1727 return $output; 1728 } 1730 1729 } 1731 1730
Note: See TracChangeset
for help on using the changeset viewer.