Changeset 47180
- Timestamp:
- 02/04/2020 11:00:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r47179 r47180 3067 3067 if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) { 3068 3068 $status = get_post_status( $this->posts[0] ); 3069 3070 3069 if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) { 3071 3070 $this->is_page = false; … … 3073 3072 $this->is_attachment = true; 3074 3073 } 3074 $post_status_obj = get_post_status_object( $status ); 3075 3075 3076 3076 // If the post_status was specifically requested, let it pass through. 3077 if ( ! in_array( $status, $q_status ) ) { 3078 $post_status_obj = get_post_status_object( $status ); 3079 3080 if ( $post_status_obj && ! $post_status_obj->public ) { 3081 if ( ! is_user_logged_in() ) { 3082 // User must be logged in to view unpublished posts. 3083 $this->posts = array(); 3084 } else { 3085 if ( $post_status_obj->protected ) { 3086 // User must have edit permissions on the draft to preview. 3087 if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) { 3088 $this->posts = array(); 3089 } else { 3090 $this->is_preview = true; 3091 if ( 'future' != $status ) { 3092 $this->posts[0]->post_date = current_time( 'mysql' ); 3093 } 3077 if ( ! $post_status_obj->public && ! in_array( $status, $q_status ) ) { 3078 3079 if ( ! is_user_logged_in() ) { 3080 // User must be logged in to view unpublished posts. 3081 $this->posts = array(); 3082 } else { 3083 if ( $post_status_obj->protected ) { 3084 // User must have edit permissions on the draft to preview. 3085 if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) { 3086 $this->posts = array(); 3087 } else { 3088 $this->is_preview = true; 3089 if ( 'future' != $status ) { 3090 $this->posts[0]->post_date = current_time( 'mysql' ); 3094 3091 } 3095 } elseif ( $post_status_obj->private ) { 3096 if ( ! current_user_can( $read_cap, $this->posts[0]->ID ) ) { 3097 $this->posts = array(); 3098 } 3099 } else { 3092 } 3093 } elseif ( $post_status_obj->private ) { 3094 if ( ! current_user_can( $read_cap, $this->posts[0]->ID ) ) { 3100 3095 $this->posts = array(); 3101 3096 } 3097 } else { 3098 $this->posts = array(); 3102 3099 } 3103 } else {3104 // Post status is not registered, assume it's not public.3105 $this->posts = array();3106 3100 } 3107 3101 }
Note: See TracChangeset
for help on using the changeset viewer.