Advertisement
Guest User

custom get taxonomy array function

a guest
Jul 10th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. add_filter('ajwpqsf_get_taxo','my_custom_process');
  2. function my_custom_process($taxo,$id, $gettaxo ){
  3.     if($id='1222'){
  4. //put your form id here to test. Ensure that the changes only affect result from current form.
  5.     $mytaxo = '';
  6.         global $wp_query;
  7.             $options = get_post_meta($id, 'ajaxwpqsf-relbool', true);
  8.             $taxrel = isset($options[0]['tax']) ? $options[0]['tax'] : 'AND';
  9.             if(!empty($gettaxo)){
  10.                        
  11.                 $mytaxo =array('relation' => $taxrel,'');
  12.                 foreach($gettaxo as  $v){
  13.                    if(isset($v['term']))    {  
  14.                     if( $v['term'] == 'awpqsftaxoall'){
  15.                       $mytaxo[] = array(
  16.                             'taxonomy' => strip_tags( stripslashes($v['name'])),
  17.                             'field' => 'slug',
  18.                             'terms' => strip_tags( stripslashes($v['term'])),
  19.                             'operator' => 'NOT IN'
  20.                         );
  21.                      
  22.                       }
  23.                     elseif(is_array($v['term'])){
  24.                      $mytaxo[] = array(
  25.                             'taxonomy' =>  strip_tags( stripslashes($v['name'])),
  26.                             'field' => 'slug',
  27.                             'terms' =>$v['term'],
  28.                             'operator' => 'AND'
  29.                         );
  30.                     }
  31.                     else{
  32.                  
  33.                     $mytaxo[] = array(
  34.                             'taxonomy' => strip_tags( stripslashes($v['name'])),
  35.                             'field' => 'slug',
  36.                             'terms' => strip_tags( stripslashes($v['term'])),      
  37.                             'operator' => 'AND'
  38.                         );
  39.                     }
  40.                    }
  41.                  } //end foreach
  42.                    
  43.                     unset($mytaxo[0]);
  44.                     return $mytaxo;
  45.  
  46.  
  47.  
  48.     }
  49.   return $taxo;    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement