From 75d045de8eec5eac74a69c4c85a17ed349cd9269 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Fri, 12 Nov 2010 04:10:56 +0000 Subject: [PATCH] Add checks for WP_Error. props ptahdunbar. see #14746 git-svn-id: http://svn.automattic.com/wordpress/trunk@16315 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-posts-list-table.php | 4 +++- wp-includes/post-template.php | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 4910294e6b..dea8f65409 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -468,8 +468,10 @@ class WP_Posts_List_Table extends WP_List_Table { $title = _draft_or_post_title(); $post_type_object = get_post_type_object( $post->post_type ); $can_edit_post = current_user_can( 'edit_post', $post->ID ); + $post_format = get_post_format( $post->ID ); + $post_format_class = ( $post_format && !is_wp_error($post_format) ) ? 'format-' . sanitize_html_class( $post_format ) : 'format-default'; ?> - post_status . ' ' . sanitize_html_class( 'format-' . ( get_post_format( $post->ID ) ? get_post_format( $post->ID ) : 'default' ) ) ); ?> iedit' valign="top"> + post_status . ' ' . $post_format_class); ?> iedit' valign="top"> get_column_info(); diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 5642d931bb..b14cb3a4db 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -327,8 +327,12 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = $post->post_type; $classes[] = 'type-' . $post->post_type; $classes[] = 'status-' . $post->post_status; - if ( get_post_format( $post->ID ) ) - $classes[] = 'format-' . sanitize_html_class( get_post_format( $post->ID ) ); + + // Post Format + $post_format = get_post_format( $post->ID ); + + if ( $post_format && !is_wp_error($post_format) ) + $classes[] = 'format-' . sanitize_html_class( $post_format ); else $classes[] = 'format-default'; @@ -424,8 +428,12 @@ function get_body_class( $class = '' ) { $classes[] = 'single'; $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id); $classes[] = 'postid-' . $post_id; - if ( get_post_format( $post_id ) ) - $classes[] = 'single-format-' . sanitize_html_class( get_post_format( $post_id ) ); + + // Post Format + $post_format = get_post_format( $post->ID ); + + if ( $post_format && !is_wp_error($post_format) ) + $classes[] = 'single-format-' . sanitize_html_class( $post_format ); else $classes[] = 'single-format-default';