Search & Filter - Version 1.2.9

Version Description

  • Fixed - bugs with WP 4.4 compatibility
  • Fixed - an issue with operators being case sensitive - they are no longer case sensitive
Download this release

Release Info

Developer DesignsAndCode
Plugin Icon 128x128 Search & Filter
Version 1.2.9
Comparing to
See all releases

Code changes from version 1.2.8 to 1.2.9

Files changed (2) hide show
  1. readme.txt +6 -2
  2. search-filter.php +25 -17
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: DesignsAndCode
3
  Donate link:
4
  Tags: category, filter, taxonomy, search, wordpress, post type, post date
5
  Requires at least: 3.5
6
- Tested up to: 4.4
7
- Stable tag: 1.2.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -34,6 +34,10 @@ The documentation has been updated to include examples almost all configurable o
34
 
35
  == Changelog ==
36
 
 
 
 
 
37
  = 1.2.8 =
38
  * Fixed - an issue with rewrites - thanks [@iohannis](https://wordpress.org/support/profile/iohannis)
39
 
3
  Donate link:
4
  Tags: category, filter, taxonomy, search, wordpress, post type, post date
5
  Requires at least: 3.5
6
+ Tested up to: 4.8
7
+ Stable tag: 1.2.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
34
 
35
  == Changelog ==
36
 
37
+ = 1.2.9 =
38
+ * Fixed - bugs with WP 4.4 compatibility
39
+ * Fixed - an issue with operators being case sensitive - they are no longer case sensitive
40
+
41
  = 1.2.8 =
42
  * Fixed - an issue with rewrites - thanks [@iohannis](https://wordpress.org/support/profile/iohannis)
43
 
search-filter.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.designsandcode.com/447/wordpress-search-filter-plugin-for
5
  Description: Search and Filtering system for Pages, Posts, Categories, Tags and Taxonomies
6
  Author: Designs & Code
7
  Author URI: http://www.designsandcode.com/
8
- Version: 1.2.8
9
  Text Domain: searchandfilter
10
  License: GPLv2
11
  */
@@ -16,7 +16,7 @@ License: GPLv2
16
  * Set up Plugin Globals
17
  */
18
  if (!defined('SEARCHANDFILTER_VERSION_NUM'))
19
- define('SEARCHANDFILTER_VERSION_NUM', '1.2.8');
20
 
21
  if (!defined('SEARCHANDFILTER_THEME_DIR'))
22
  define('SEARCHANDFILTER_THEME_DIR', ABSPATH . 'wp-content/themes/' . get_template());
@@ -131,7 +131,7 @@ if ( ! class_exists( 'SearchAndFilter' ) )
131
  'empty_search_url' => ""
132
 
133
  ), $atts));
134
-
135
  //init `fields`
136
  if($fields!=null)
137
  {
@@ -359,6 +359,8 @@ if ( ! class_exists( 'SearchAndFilter' ) )
359
 
360
  if(isset($operators[$i]))
361
  {
 
 
362
  if(($operators[$i]!="and")&&($operators[$i]!="or"))
363
  {
364
  $operators[$i] = "and"; //else use default - possible typo or use of unknown value
@@ -368,7 +370,6 @@ if ( ! class_exists( 'SearchAndFilter' ) )
368
  {
369
  $operators[$i] = "and"; //use default
370
  }
371
-
372
  }
373
 
374
  //set all form defaults / dropdowns etc
@@ -572,7 +573,7 @@ if ( ! class_exists( 'SearchAndFilter' ) )
572
 
573
  $this->defaults[SF_FPRE.'post_tag'] = $tags;
574
 
575
- $taxs = array();
576
  //loop through all the query vars
577
  foreach($wp_query->query as $key=>$val)
578
  {
@@ -586,7 +587,9 @@ if ( ! class_exists( 'SearchAndFilter' ) )
586
  //$tax_params = explode("+",esc_attr($taxslug));
587
 
588
  $tax_params = (preg_split("/[,\+ ]/", esc_attr($taxslug))); //explode with 2 delims
589
-
 
 
590
  foreach($tax_params as $tax_param)
591
  {
592
  $tax = get_term_by("slug",$tax_param, $key);
@@ -675,11 +678,11 @@ if ( ! class_exists( 'SearchAndFilter' ) )
675
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
676
  if(isset($_POST[SF_FPRE.'category_operator']))
677
  {
678
- if($_POST[SF_FPRE.'category_operator']=="and")
679
  {
680
  $operator = "+";
681
  }
682
- else if($_POST[SF_FPRE.'category_operator']=="or")
683
  {
684
  $operator = ",";
685
  }
@@ -756,11 +759,11 @@ if ( ! class_exists( 'SearchAndFilter' ) )
756
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
757
  if(isset($_POST[SF_FPRE.'post_tag_operator']))
758
  {
759
- if($_POST[SF_FPRE.'post_tag_operator']=="and")
760
  {
761
  $operator = "+";
762
  }
763
- else if($_POST[SF_FPRE.'post_tag_operator']=="or")
764
  {
765
  $operator = ",";
766
  }
@@ -802,6 +805,7 @@ if ( ! class_exists( 'SearchAndFilter' ) )
802
  {
803
  foreach($_POST as $key=>$val)
804
  {
 
805
  if(!in_array($key, $this->frmreserved))
806
  {//if the key is not in the reserved array (ie, on a custom taxonomy - not tags, categories, search term, post type & post date)
807
 
@@ -810,12 +814,13 @@ if ( ! class_exists( 'SearchAndFilter' ) )
810
  {
811
  $key = substr($key, strlen(SF_FPRE));
812
  }
813
-
814
  $the_post_tax = $val;
815
 
 
816
 
817
  //make the post an array for easy looping
818
- if(!is_array($val))
819
  {
820
  $post_tax[] = $the_post_tax;
821
  }
@@ -823,13 +828,14 @@ if ( ! class_exists( 'SearchAndFilter' ) )
823
  {
824
  $post_tax = $the_post_tax;
825
  }
 
826
  $taxarr = array();
827
 
828
  foreach ($post_tax as $tax)
829
  {
830
  $tax = esc_attr($tax);
831
- $taxobj = get_term_by('id',$tax,$key);
832
-
833
  if(isset($taxobj->slug))
834
  {
835
  $taxarr[] = $taxobj->slug;
@@ -843,11 +849,11 @@ if ( ! class_exists( 'SearchAndFilter' ) )
843
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
844
  if(isset($_POST[SF_FPRE.$key.'_operator']))
845
  {
846
- if($_POST[SF_FPRE.$key.'_operator']=="and")
847
  {
848
  $operator = "+";
849
  }
850
- else if($_POST[SF_FPRE.$key.'_operator']=="or")
851
  {
852
  $operator = ",";
853
  }
@@ -1055,6 +1061,8 @@ if ( ! class_exists( 'SearchAndFilter' ) )
1055
  }
1056
  }
1057
 
 
 
1058
  if($this->has_form_posted)
1059
  {//if the search has been posted, redirect to the newly formed url with all the right params
1060
 
@@ -1073,10 +1081,10 @@ if ( ! class_exists( 'SearchAndFilter' ) )
1073
  exit;
1074
  }
1075
  }
1076
-
1077
  wp_redirect((home_url().$this->urlparams));
1078
  exit;
1079
  }
 
1080
  }
1081
 
1082
  public function get_search_filter_form($submitlabel, $search_placeholder, $fields, $types, $labels, $hierarchical, $hide_empty, $show_count, $post_types, $order_by, $order_dir, $operators, $all_items_labels, $empty_search_url, $add_search_param, $class)
5
  Description: Search and Filtering system for Pages, Posts, Categories, Tags and Taxonomies
6
  Author: Designs & Code
7
  Author URI: http://www.designsandcode.com/
8
+ Version: 1.2.9
9
  Text Domain: searchandfilter
10
  License: GPLv2
11
  */
16
  * Set up Plugin Globals
17
  */
18
  if (!defined('SEARCHANDFILTER_VERSION_NUM'))
19
+ define('SEARCHANDFILTER_VERSION_NUM', '1.2.9');
20
 
21
  if (!defined('SEARCHANDFILTER_THEME_DIR'))
22
  define('SEARCHANDFILTER_THEME_DIR', ABSPATH . 'wp-content/themes/' . get_template());
131
  'empty_search_url' => ""
132
 
133
  ), $atts));
134
+
135
  //init `fields`
136
  if($fields!=null)
137
  {
359
 
360
  if(isset($operators[$i]))
361
  {
362
+ $operators[$i] = strtolower($operators[$i]);
363
+
364
  if(($operators[$i]!="and")&&($operators[$i]!="or"))
365
  {
366
  $operators[$i] = "and"; //else use default - possible typo or use of unknown value
370
  {
371
  $operators[$i] = "and"; //use default
372
  }
 
373
  }
374
 
375
  //set all form defaults / dropdowns etc
573
 
574
  $this->defaults[SF_FPRE.'post_tag'] = $tags;
575
 
576
+
577
  //loop through all the query vars
578
  foreach($wp_query->query as $key=>$val)
579
  {
587
  //$tax_params = explode("+",esc_attr($taxslug));
588
 
589
  $tax_params = (preg_split("/[,\+ ]/", esc_attr($taxslug))); //explode with 2 delims
590
+
591
+ $taxs = array();
592
+
593
  foreach($tax_params as $tax_param)
594
  {
595
  $tax = get_term_by("slug",$tax_param, $key);
678
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
679
  if(isset($_POST[SF_FPRE.'category_operator']))
680
  {
681
+ if(strtolower($_POST[SF_FPRE.'category_operator'])=="and")
682
  {
683
  $operator = "+";
684
  }
685
+ else if(strtolower($_POST[SF_FPRE.'category_operator'])=="or")
686
  {
687
  $operator = ",";
688
  }
759
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
760
  if(isset($_POST[SF_FPRE.'post_tag_operator']))
761
  {
762
+ if(strtolower($_POST[SF_FPRE.'post_tag_operator'])=="and")
763
  {
764
  $operator = "+";
765
  }
766
+ else if(strtolower($_POST[SF_FPRE.'post_tag_operator'])=="or")
767
  {
768
  $operator = ",";
769
  }
805
  {
806
  foreach($_POST as $key=>$val)
807
  {
808
+
809
  if(!in_array($key, $this->frmreserved))
810
  {//if the key is not in the reserved array (ie, on a custom taxonomy - not tags, categories, search term, post type & post date)
811
 
814
  {
815
  $key = substr($key, strlen(SF_FPRE));
816
  }
817
+
818
  $the_post_tax = $val;
819
 
820
+ $post_tax = array();
821
 
822
  //make the post an array for easy looping
823
+ if(!is_array($the_post_tax))
824
  {
825
  $post_tax[] = $the_post_tax;
826
  }
828
  {
829
  $post_tax = $the_post_tax;
830
  }
831
+
832
  $taxarr = array();
833
 
834
  foreach ($post_tax as $tax)
835
  {
836
  $tax = esc_attr($tax);
837
+ $taxobj = get_term_by('id', $tax, $key);
838
+
839
  if(isset($taxobj->slug))
840
  {
841
  $taxarr[] = $taxobj->slug;
849
  //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
850
  if(isset($_POST[SF_FPRE.$key.'_operator']))
851
  {
852
+ if(strtolower($_POST[SF_FPRE.$key.'_operator'])=="and")
853
  {
854
  $operator = "+";
855
  }
856
+ else if(strtolower($_POST[SF_FPRE.$key.'_operator'])=="or")
857
  {
858
  $operator = ",";
859
  }
1061
  }
1062
  }
1063
 
1064
+
1065
+
1066
  if($this->has_form_posted)
1067
  {//if the search has been posted, redirect to the newly formed url with all the right params
1068
 
1081
  exit;
1082
  }
1083
  }
 
1084
  wp_redirect((home_url().$this->urlparams));
1085
  exit;
1086
  }
1087
+
1088
  }
1089
 
1090
  public function get_search_filter_form($submitlabel, $search_placeholder, $fields, $types, $labels, $hierarchical, $hide_empty, $show_count, $post_types, $order_by, $order_dir, $operators, $all_items_labels, $empty_search_url, $add_search_param, $class)