Plugin Directory

Changeset 2267313


Ignore:
Timestamp:
03/25/2020 12:46:40 PM (6 years ago)
Author:
DesignsAndCode
Message:

fix php warnings, typo, WP version test

Location:
search-filter/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • search-filter/trunk/of-admin.php

    r1986250 r2267313  
    6464                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 />
    6565               
    66                 To use this within a theme file you simple need to call the `do_shorcode` 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 />
    6767               
    6868                <pre><code class="php">&lt;?php echo do_shortcode( \'[searchandfilter fields="search,category,post_tag"]\' ); ?&gt;</code></pre>
  • search-filter/trunk/of-taxonomy-walker.php

    r1196498 r2267313  
    22
    33class Taxonomy_Walker extends Walker_Category {
    4 
    54   
    65    private $type = '';
     
    1110
    1211    function __construct($type = 'checkbox', $defaults = array())  {
    13         // fetch the list of term ids for the given post
    14         //$this->term_ids = wp_get_post_terms( $post_id, $taxonomy, 'fields=ids' );
    1512       
    1613        $this->type = $type;
     
    1916
    2017    function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
    21         /*$display = false;
    2218       
    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 );
    4020    }
    4121   
     
    4323    function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 )
    4424    {
    45    
    4625        if($this->type=="list")
    4726        {
     
    12099            if($defaults)
    121100            {
    122                 $noselected = count($this->defaults);
    123 
    124                 if(($noselected>0)&&(is_array($defaults)))
     101                if(is_array($defaults))
    125102                {
    126                     foreach($defaults as $defaultid)
     103                    $noselected = count($defaults);
     104
     105                    if($noselected>0)
    127106                    {
    128                         if($defaultid==$cat_id)
     107                        foreach($defaults as $defaultid)
    129108                        {
    130                             $checked = ' checked="checked"';
     109                            if($defaultid==$cat_id)
     110                            {
     111                                $checked = ' checked="checked"';
     112                            }
    131113                        }
    132114                    }
     
    171153            if($defaults)
    172154            {
    173                 $noselected = count($this->defaults);
    174 
    175                 if(($noselected>0)&&(is_array($defaults)))
     155                if(is_array($defaults))
    176156                {
    177                     foreach($defaults as $defaultid)
     157                    $noselected = count($defaults);
     158
     159                    if($noselected>0)
    178160                    {
    179                         if($defaultid==$cat_id)
     161                        foreach($defaults as $defaultid)
    180162                        {
    181                             $checked = ' selected="selected"';
     163                            if($defaultid==$cat_id)
     164                            {
     165                                $checked = ' selected="selected"';
     166                            }
    182167                        }
    183168                    }
  • search-filter/trunk/readme.txt

    r2234765 r2267313  
    55Requires at least: 3.5
    66Tested up to: 5.3
    7 Stable tag: 1.2.11
     7Stable tag: 1.2.12
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3434
    3535== 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
    3641
    3742= 1.2.11 =
  • search-filter/trunk/search-filter.php

    r1986250 r2267313  
    66Author: Designs & Code
    77Author URI: http://www.designsandcode.com/
    8 Version: 1.2.11
     8Version: 1.2.12
    99Text Domain: searchandfilter
    1010License: GPLv2
     
    1515*/
    1616if (!defined('SEARCHANDFILTER_VERSION_NUM'))
    17     define('SEARCHANDFILTER_VERSION_NUM', '1.2.11');
     17    define('SEARCHANDFILTER_VERSION_NUM', '1.2.12');
    1818
    1919if (!defined('SEARCHANDFILTER_THEME_DIR'))
     
    11071107                            foreach($post_types as $post_type)
    11081108                            {
    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)."\" />";
    11101110                            }
    11111111                        }
     
    11281128                                }
    11291129                                $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).'">';
    11311131                                $returnvar .=  '</li>';
    11321132                            }
     
    11761176                        $returnvar .=
    11771177                            '<input type="hidden" name="'.SF_FPRE.'submitted" value="1">
    1178                             <input type="submit" value="'.$submitlabel.'">
     1178                            <input type="submit" value="'.esc_attr($submitlabel).'">
    11791179                        </li>';
    11801180
     
    14371437                    if(($operators[$i]=="and")||($operators[$i]=="or"))
    14381438                    {
    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]).'" />';
    14401440                    }
    14411441                }
     
    15211521            $checked = ($defaultval=="0") ? " checked='checked'" : "";
    15221522            $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>';
    15241524            $returnvar .= walk_taxonomy('radio', $args);
    15251525            $returnvar .= "</ul>";
     
    16011601                    }
    16021602                }
    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>';
    16041604           
    16051605            }
     
    16591659                }
    16601660               
    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>';
    16621662            }
    16631663           
     
    16841684                    }
    16851685                }
    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>';
    16871687           
    16881688            }
     
    17111711            }
    17121712           
    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) .'" />';
    17141714
    17151715            return $returnvar;
     
    17231723    $args['walker'] = new Taxonomy_Walker($type, $args['sf_name']);
    17241724   
    1725     //unset($args['sf_name']);
    1726    
    17271725    $output = wp_list_categories($args);
    1728     if ( $output )
     1726    if ( $output ){
    17291727        return $output;
     1728    }
    17301729}
    17311730
Note: See TracChangeset for help on using the changeset viewer.