WordPress.org

Make WordPress Core

Changeset 24057


Ignore:
Timestamp:
04/22/13 20:41:16 (23 months ago)
Author:
nacin
Message:

Return false in get_post_format() if the post does not exist.

props adamsilverstein, ericlewis.
fixes #23255.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-formats.php

    r24045 r24057  
    1212 * @since 3.1.0 
    1313 * 
    14  * @param int|object $post A post. 
    15  * 
    16  * @return mixed The format if successful. False if no format is set. WP_Error if errors. 
     14 * @param int|object $post Post ID or post object. Optional, default is the current post from the loop. 
     15 * @return mixed The format if successful. False otherwise. 
    1716 */ 
    1817function get_post_format( $post = null ) { 
    19     $post = get_post($post); 
     18    if ( ! $post = get_post( $post ) ) 
     19        return false; 
    2020 
    2121    if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) 
     
    2929    $format = array_shift( $_format ); 
    3030 
    31     return ( str_replace('post-format-', '', $format->slug ) ); 
     31    return str_replace('post-format-', '', $format->slug ); 
    3232} 
    3333 
Note: See TracChangeset for help on using the changeset viewer.