search-extras.php 1.46 KB
<?php



add_action( 'add_attachment', 'add_attachment_mime_type' );
function add_attachment_mime_type( $attachment_id ){
   $post =  get_post( $attachment_id );
   $post_mime_type = explode(".", $post->_wp_attached_file);
   update_post_meta( $attachment_id, 'file_type', end($post_mime_type) );

}


// function filter_function_name( $query_args, $sfid ) {
// 	global $searchandfilter;
// 	$sf_current_query = $searchandfilter->get(112)->current_query();
//     $sf_current_query_array = $sf_current_query->get_array();
//     error_log('get_array');
// 	error_log(print_r($sf_current_query->get_array(),true));

// 	if($sfid==102)
// 	{
//         foreach($sf_current_query_array as $key => $item){
//             $query_args[$key] = $item['active_terms'][0]['value'];
//             $query_args['_sfm_file_type'] = 'pdf';
            
//         }
// 	}
//     error_log('query_args');
//     error_log(print_r($query_args,true));
// 	return $query_args;
// }

// add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );



// function filter_function_url( $url,  $sfid) {
//     error_log('url');
//     error_log(print_r($url,true));
//     return $url;
//   }
//   add_filter( 'sf_results_url', 'filter_function_url', 10, 2 );


//   function filter_function_object($input_object, $sfid)
// {
//     error_log('input_object');
//     error_log(print_r($input_object,true));
// 	return $input_object;
// }
// add_filter('sf_input_object_pre', 'filter_function_object', 10, 2);