Advertisement
dmwmartin

WordPress Search & Filter amend for url parameter

May 2nd, 2014
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. /* POST TYPES */
  2. if((isset($_POST[SF_FPRE.'post_types']))&&($this->has_form_posted))
  3. {
  4.     $the_post_types = ($_POST[SF_FPRE.'post_types']);
  5.  
  6.     //make the post an array for easy looping
  7.     if(!is_array($the_post_types))
  8.     {
  9.         $post_types_arr[] = $the_post_types;
  10.     }
  11.     else
  12.     {
  13.         $post_types_arr = $the_post_types;
  14.     }
  15.  
  16.     $num_post_types = count($post_types_arr);
  17.  
  18.     for($i=0; $i<$num_post_types; $i++)
  19.     {
  20.         if($post_types_arr[$i]=="0")
  21.         {
  22.                 $post_types_arr[$i] = "all";
  23.         }
  24.     }
  25.  
  26.     if(count($post_types_arr)>1)
  27.     {
  28.         $operator = ","; //default behaviour
  29.                
  30.         //check to see if an operator has been specified - only applies with fields that use multiple selects such as checkboxes or multi selects
  31.         /*if(isset($_POST[SF_FPRE.'post_types_operator']))
  32.         {
  33.                 if($_POST[SF_FPRE.'post_types_operator']=="and")
  34.                 {
  35.                         $operator = "+";
  36.                 }
  37.                 else if($_POST[SF_FPRE.'post_types_operator']=="or")
  38.                 {
  39.                         $operator = ",";
  40.                 }
  41.                 else
  42.                 {
  43.                         $operator = "+";
  44.                 }
  45.         }*/
  46.        
  47.         $post_types = implode($operator,$post_types_arr);
  48.        
  49.         if(!$this->hasqmark)
  50.         {
  51.                 $this->urlparams .= "?";
  52.                 $this->hasqmark = true;
  53.         }
  54.         else
  55.         {
  56.                 $this->urlparams .= "&";
  57.         }
  58.         $this->urlparams .= "post_types=".$post_types;
  59.  
  60.     }
  61.     else
  62.     {
  63.         $operator = ","; //default behaviour
  64.        
  65.         $post_types = implode($operator,$post_types_arr);
  66.        
  67.         if(!$this->hasqmark)
  68.         {
  69.                 $this->urlparams .= "?";
  70.                 $this->hasqmark = true;
  71.         }
  72.         else
  73.         {
  74.                 $this->urlparams .= "&";
  75.         }
  76.        
  77.         $this->urlparams .= "post_type=".$post_types;
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement