_wp_preview_terms_filter

Filters terms lookup to set the post format.

Description

(array) _wp_preview_terms_filter( (array) $terms, (int) $post_id, (string) $taxonomy ); 

Returns (array)

Parameters (3)

0. $terms (array)
The terms.
1. $post_id (int)
The post id.
2. $taxonomy (string)
The taxonomy.

Usage

  1. if ( !function_exists( '_wp_preview_terms_filter' ) ) { 
  2. require_once ABSPATH . WPINC . '/revision.php'; 
  3.  
  4. // The terms. 
  5. $terms = array(); 
  6.  
  7. // The post id. 
  8. $post_id = -1; 
  9.  
  10. // The taxonomy. 
  11. $taxonomy = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _wp_preview_terms_filter($terms, $post_id, $taxonomy); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/revision.php  
  1. function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { 
  2. if ( ! $post = get_post() ) 
  3. return $terms; 
  4.  
  5. if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) 
  6. return $terms; 
  7.  
  8. if ( 'standard' == $_REQUEST['post_format'] ) 
  9. $terms = array(); 
  10. elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) 
  11. $terms = array( $term ); // Can only have one post format 
  12.  
  13. return $terms;