diff options
Diffstat (limited to 'plugins/jetpack/modules/widgets/top-posts.php')
-rw-r--r-- | plugins/jetpack/modules/widgets/top-posts.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php index a5269976..3973a75e 100644 --- a/plugins/jetpack/modules/widgets/top-posts.php +++ b/plugins/jetpack/modules/widgets/top-posts.php @@ -510,12 +510,23 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { foreach ( (array) $post_ids as $post_id ) { $post = get_post( $post_id ); - if ( ! $post ) + if ( ! $post ) { continue; + } + + /** + * Attachment pages use the 'inherit' post status by default. + * To be able to remove attachment pages from private and password protect posts, + * we need to replace their post status by the parent post' status. + */ + if ( 'inherit' == $post->post_status && 'attachment' == $post->post_type ) { + $post->post_status = get_post_status( $post_id ); + } // hide private and password protected posts - if ( 'publish' != $post->post_status || ! empty( $post->post_password ) || empty( $post->ID ) ) + if ( 'publish' != $post->post_status || ! empty( $post->post_password ) ) { continue; + } // Both get HTML stripped etc on display if ( empty( $post->post_title ) ) { |