diff --git src/wp-includes/class-wp-post.php src/wp-includes/class-wp-post.php
index 5904e58..ec6f96d 100644
|
|
final class WP_Post { |
211 | 211 | global $wpdb; |
212 | 212 | |
213 | 213 | $post_id = (int) $post_id; |
214 | | if ( ! $post_id ) |
| 214 | if ( ! $post_id ) { |
215 | 215 | return false; |
| 216 | } |
216 | 217 | |
217 | 218 | $_post = wp_cache_get( $post_id, 'posts' ); |
218 | 219 | |
219 | 220 | if ( ! $_post ) { |
220 | 221 | $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) ); |
221 | 222 | |
222 | | if ( ! $_post ) |
223 | | return false; |
224 | | |
225 | | $_post = sanitize_post( $_post, 'raw' ); |
226 | | wp_cache_add( $_post->ID, $_post, 'posts' ); |
| 223 | if ( ! $_post ) { |
| 224 | $_post = false; |
| 225 | } else { |
| 226 | $_post = sanitize_post( $_post, 'raw' ); |
| 227 | wp_cache_add( $_post->ID, $_post, 'posts' ); |
| 228 | } |
227 | 229 | } elseif ( empty( $_post->filter ) ) { |
228 | 230 | $_post = sanitize_post( $_post, 'raw' ); |
229 | 231 | } |
230 | 232 | |
| 233 | if ( is_customize_preview() ) { |
| 234 | |
| 235 | /** |
| 236 | * Filter post data instance in Customizer, the return value of `WP_Post::get_instance()`. |
| 237 | * |
| 238 | * The filtered value will be added to |
| 239 | * |
| 240 | * @since 4.6 |
| 241 | * |
| 242 | * @param object|false $_post Post data, or false if it was not found in the database. |
| 243 | * @param int $post_id Post ID. |
| 244 | */ |
| 245 | $_post = apply_filters( 'customize_preview_post_instance', $_post, $post_id ); |
| 246 | } |
| 247 | |
| 248 | if ( false === $_post ) { |
| 249 | return $_post; |
| 250 | } |
| 251 | |
231 | 252 | return new WP_Post( $_post ); |
232 | 253 | } |
233 | 254 | |