WordPress.org

Make WordPress Core

Ticket #14746: ticket.14746.post_formats.diff

File ticket.14746.post_formats.diff, 2.4 KB (added by ptahdunbar, 9 years ago)

adds a check for wp error

  • wp-includes/post-template.php

     
    327327        $classes[] = $post->post_type;
    328328        $classes[] = 'type-' . $post->post_type;
    329329        $classes[] = 'status-' . $post->post_status;
    330         if ( get_post_format( $post->ID ) )
    331                 $classes[] = 'format-' . sanitize_html_class( get_post_format( $post->ID ) );
     330       
     331        // Post Format
     332        $post_format = get_post_format( $post->ID );
     333
     334        if ( $post_format && !is_wp_error($post_format) )
     335                $classes[] = 'format-' . sanitize_html_class( $post_format );
    332336        else
    333337                $classes[] = 'format-default';
    334338
     
    424428                $classes[] = 'single';
    425429                $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
    426430                $classes[] = 'postid-' . $post_id;
    427                 if ( get_post_format( $post_id ) )
    428                         $classes[] = 'single-format-' . sanitize_html_class( get_post_format( $post_id ) );
     431               
     432                // Post Format
     433                $post_format = get_post_format( $post->ID );
     434
     435                if ( $post_format && !is_wp_error($post_format) )
     436                        $classes[] = 'single-format-' . sanitize_html_class( $post_format );
    429437                else
    430438                        $classes[] = 'single-format-default';
    431439
  • wp-admin/includes/class-wp-posts-list-table.php

     
    468468                $title = _draft_or_post_title();
    469469                $post_type_object = get_post_type_object( $post->post_type );
    470470                $can_edit_post = current_user_can( 'edit_post', $post->ID );
     471                $post_format = get_post_format( $post->ID );
     472                $post_format_class = ( $post_format && !is_wp_error($post_format) ) ? 'format-' . sanitize_html_class( $post_format ) : 'format-default';
    471473        ?>
    472                 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status . ' ' . sanitize_html_class( 'format-' . ( get_post_format( $post->ID ) ? get_post_format( $post->ID ) : 'default' ) ) ); ?> iedit' valign="top">
     474                <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status . ' ' . $post_format_class); ?> iedit' valign="top">
    473475        <?php
    474476
    475477                list( $columns, $hidden ) = $this->get_column_info();