wp/wp-includes/post.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    73 		'attachment',
    73 		'attachment',
    74 		array(
    74 		array(
    75 			'labels'                => array(
    75 			'labels'                => array(
    76 				'name'           => _x( 'Media', 'post type general name' ),
    76 				'name'           => _x( 'Media', 'post type general name' ),
    77 				'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
    77 				'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
    78 				'add_new'        => __( 'Add New Media File' ),
    78 				'add_new'        => __( 'Add Media File' ),
    79 				'edit_item'      => __( 'Edit Media' ),
    79 				'edit_item'      => __( 'Edit Media' ),
    80 				'view_item'      => ( '1' === get_option( 'wp_attachment_pages_enabled' ) ) ? __( 'View Attachment Page' ) : __( 'View Media File' ),
    80 				'view_item'      => ( '1' === get_option( 'wp_attachment_pages_enabled' ) ) ? __( 'View Attachment Page' ) : __( 'View Media File' ),
    81 				'attributes'     => __( 'Attachment Attributes' ),
    81 				'attributes'     => __( 'Attachment Attributes' ),
    82 			),
    82 			),
    83 			'public'                => true,
    83 			'public'                => true,
   200 		'customize_changeset',
   200 		'customize_changeset',
   201 		array(
   201 		array(
   202 			'labels'           => array(
   202 			'labels'           => array(
   203 				'name'               => _x( 'Changesets', 'post type general name' ),
   203 				'name'               => _x( 'Changesets', 'post type general name' ),
   204 				'singular_name'      => _x( 'Changeset', 'post type singular name' ),
   204 				'singular_name'      => _x( 'Changeset', 'post type singular name' ),
   205 				'add_new'            => __( 'Add New Changeset' ),
   205 				'add_new'            => __( 'Add Changeset' ),
   206 				'add_new_item'       => __( 'Add New Changeset' ),
   206 				'add_new_item'       => __( 'Add Changeset' ),
   207 				'new_item'           => __( 'New Changeset' ),
   207 				'new_item'           => __( 'New Changeset' ),
   208 				'edit_item'          => __( 'Edit Changeset' ),
   208 				'edit_item'          => __( 'Edit Changeset' ),
   209 				'view_item'          => __( 'View Changeset' ),
   209 				'view_item'          => __( 'View Changeset' ),
   210 				'all_items'          => __( 'All Changesets' ),
   210 				'all_items'          => __( 'All Changesets' ),
   211 				'search_items'       => __( 'Search Changesets' ),
   211 				'search_items'       => __( 'Search Changesets' ),
   282 		'wp_block',
   282 		'wp_block',
   283 		array(
   283 		array(
   284 			'labels'                => array(
   284 			'labels'                => array(
   285 				'name'                     => _x( 'Patterns', 'post type general name' ),
   285 				'name'                     => _x( 'Patterns', 'post type general name' ),
   286 				'singular_name'            => _x( 'Pattern', 'post type singular name' ),
   286 				'singular_name'            => _x( 'Pattern', 'post type singular name' ),
   287 				'add_new'                  => __( 'Add New Pattern' ),
   287 				'add_new'                  => __( 'Add Pattern' ),
   288 				'add_new_item'             => __( 'Add New Pattern' ),
   288 				'add_new_item'             => __( 'Add Pattern' ),
   289 				'new_item'                 => __( 'New Pattern' ),
   289 				'new_item'                 => __( 'New Pattern' ),
   290 				'edit_item'                => __( 'Edit Block Pattern' ),
   290 				'edit_item'                => __( 'Edit Block Pattern' ),
   291 				'view_item'                => __( 'View Pattern' ),
   291 				'view_item'                => __( 'View Pattern' ),
   292 				'view_items'               => __( 'View Patterns' ),
   292 				'view_items'               => __( 'View Patterns' ),
   293 				'all_items'                => __( 'All Patterns' ),
   293 				'all_items'                => __( 'All Patterns' ),
   348 		'wp_template',
   348 		'wp_template',
   349 		array(
   349 		array(
   350 			'labels'                          => array(
   350 			'labels'                          => array(
   351 				'name'                  => _x( 'Templates', 'post type general name' ),
   351 				'name'                  => _x( 'Templates', 'post type general name' ),
   352 				'singular_name'         => _x( 'Template', 'post type singular name' ),
   352 				'singular_name'         => _x( 'Template', 'post type singular name' ),
   353 				'add_new'               => __( 'Add New Template' ),
   353 				'add_new'               => __( 'Add Template' ),
   354 				'add_new_item'          => __( 'Add New Template' ),
   354 				'add_new_item'          => __( 'Add Template' ),
   355 				'new_item'              => __( 'New Template' ),
   355 				'new_item'              => __( 'New Template' ),
   356 				'edit_item'             => __( 'Edit Template' ),
   356 				'edit_item'             => __( 'Edit Template' ),
   357 				'view_item'             => __( 'View Template' ),
   357 				'view_item'             => __( 'View Template' ),
   358 				'all_items'             => __( 'Templates' ),
   358 				'all_items'             => __( 'Templates' ),
   359 				'search_items'          => __( 'Search Templates' ),
   359 				'search_items'          => __( 'Search Templates' ),
   413 		'wp_template_part',
   413 		'wp_template_part',
   414 		array(
   414 		array(
   415 			'labels'                          => array(
   415 			'labels'                          => array(
   416 				'name'                  => _x( 'Template Parts', 'post type general name' ),
   416 				'name'                  => _x( 'Template Parts', 'post type general name' ),
   417 				'singular_name'         => _x( 'Template Part', 'post type singular name' ),
   417 				'singular_name'         => _x( 'Template Part', 'post type singular name' ),
   418 				'add_new'               => __( 'Add New Template Part' ),
   418 				'add_new'               => __( 'Add Template Part' ),
   419 				'add_new_item'          => __( 'Add New Template Part' ),
   419 				'add_new_item'          => __( 'Add Template Part' ),
   420 				'new_item'              => __( 'New Template Part' ),
   420 				'new_item'              => __( 'New Template Part' ),
   421 				'edit_item'             => __( 'Edit Template Part' ),
   421 				'edit_item'             => __( 'Edit Template Part' ),
   422 				'view_item'             => __( 'View Template Part' ),
   422 				'view_item'             => __( 'View Template Part' ),
   423 				'all_items'             => __( 'Template Parts' ),
   423 				'all_items'             => __( 'Template Parts' ),
   424 				'search_items'          => __( 'Search Template Parts' ),
   424 				'search_items'          => __( 'Search Template Parts' ),
   487 			'rest_base'                       => 'global-styles',
   487 			'rest_base'                       => 'global-styles',
   488 			'rest_controller_class'           => 'WP_REST_Global_Styles_Controller',
   488 			'rest_controller_class'           => 'WP_REST_Global_Styles_Controller',
   489 			'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
   489 			'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
   490 			'late_route_registration'         => true,
   490 			'late_route_registration'         => true,
   491 			'capabilities'                    => array(
   491 			'capabilities'                    => array(
   492 				'read'                   => 'edit_theme_options',
   492 				'read'                   => 'edit_posts',
   493 				'create_posts'           => 'edit_theme_options',
   493 				'create_posts'           => 'edit_theme_options',
   494 				'edit_posts'             => 'edit_theme_options',
   494 				'edit_posts'             => 'edit_theme_options',
   495 				'edit_published_posts'   => 'edit_theme_options',
   495 				'edit_published_posts'   => 'edit_theme_options',
   496 				'delete_published_posts' => 'edit_theme_options',
   496 				'delete_published_posts' => 'edit_theme_options',
   497 				'edit_others_posts'      => 'edit_theme_options',
   497 				'edit_others_posts'      => 'edit_theme_options',
   520 		'wp_navigation',
   520 		'wp_navigation',
   521 		array(
   521 		array(
   522 			'labels'                => array(
   522 			'labels'                => array(
   523 				'name'                  => _x( 'Navigation Menus', 'post type general name' ),
   523 				'name'                  => _x( 'Navigation Menus', 'post type general name' ),
   524 				'singular_name'         => _x( 'Navigation Menu', 'post type singular name' ),
   524 				'singular_name'         => _x( 'Navigation Menu', 'post type singular name' ),
   525 				'add_new'               => __( 'Add New Navigation Menu' ),
   525 				'add_new'               => __( 'Add Navigation Menu' ),
   526 				'add_new_item'          => __( 'Add New Navigation Menu' ),
   526 				'add_new_item'          => __( 'Add Navigation Menu' ),
   527 				'new_item'              => __( 'New Navigation Menu' ),
   527 				'new_item'              => __( 'New Navigation Menu' ),
   528 				'edit_item'             => __( 'Edit Navigation Menu' ),
   528 				'edit_item'             => __( 'Edit Navigation Menu' ),
   529 				'view_item'             => __( 'View Navigation Menu' ),
   529 				'view_item'             => __( 'View Navigation Menu' ),
   530 				'all_items'             => __( 'Navigation Menus' ),
   530 				'all_items'             => __( 'Navigation Menus' ),
   531 				'search_items'          => __( 'Search Navigation Menus' ),
   531 				'search_items'          => __( 'Search Navigation Menus' ),
   850 
   850 
   851 /**
   851 /**
   852  * Updates attachment file path based on attachment ID.
   852  * Updates attachment file path based on attachment ID.
   853  *
   853  *
   854  * Used to update the file path of the attachment, which uses post meta name
   854  * Used to update the file path of the attachment, which uses post meta name
   855  * '_wp_attached_file' to store the path of the attachment.
   855  * `_wp_attached_file` to store the path of the attachment.
   856  *
   856  *
   857  * @since 2.1.0
   857  * @since 2.1.0
   858  *
   858  *
   859  * @param int    $attachment_id Attachment ID.
   859  * @param int    $attachment_id Attachment ID.
   860  * @param string $file          File path for the attachment.
   860  * @param string $file          File path for the attachment.
   861  * @return bool True on success, false on failure.
   861  * @return int|bool Meta ID if the `_wp_attached_file` key didn't exist for the attachment.
       
   862  *                  True on successful update, false on failure or if the `$file` value passed
       
   863  *                  to the function is the same as the one that is already in the database.
   862  */
   864  */
   863 function update_attached_file( $attachment_id, $file ) {
   865 function update_attached_file( $attachment_id, $file ) {
   864 	if ( ! get_post( $attachment_id ) ) {
   866 	if ( ! get_post( $attachment_id ) ) {
   865 		return false;
   867 		return false;
   866 	}
   868 	}
  1133  * @return int[] Array of ancestor IDs or empty array if there are none.
  1135  * @return int[] Array of ancestor IDs or empty array if there are none.
  1134  */
  1136  */
  1135 function get_post_ancestors( $post ) {
  1137 function get_post_ancestors( $post ) {
  1136 	$post = get_post( $post );
  1138 	$post = get_post( $post );
  1137 
  1139 
  1138 	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
  1140 	if ( ! $post || empty( $post->post_parent ) || $post->post_parent === $post->ID ) {
  1139 		return array();
  1141 		return array();
  1140 	}
  1142 	}
  1141 
  1143 
  1142 	$ancestors = array();
  1144 	$ancestors = array();
  1143 
  1145 
  1144 	$id          = $post->post_parent;
  1146 	$id          = $post->post_parent;
  1145 	$ancestors[] = $id;
  1147 	$ancestors[] = $id;
  1146 
  1148 
  1147 	while ( $ancestor = get_post( $id ) ) {
  1149 	while ( $ancestor = get_post( $id ) ) {
  1148 		// Loop detection: If the ancestor has been seen before, break.
  1150 		// Loop detection: If the ancestor has been seen before, break.
  1149 		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) {
  1151 		if ( empty( $ancestor->post_parent ) || $ancestor->post_parent === $post->ID
       
  1152 			|| in_array( $ancestor->post_parent, $ancestors, true )
       
  1153 		) {
  1150 			break;
  1154 			break;
  1151 		}
  1155 		}
  1152 
  1156 
  1153 		$id          = $ancestor->post_parent;
  1157 		$id          = $ancestor->post_parent;
  1154 		$ancestors[] = $id;
  1158 		$ancestors[] = $id;
  2020  * Accepted keys of the label array in the post type object:
  2024  * Accepted keys of the label array in the post type object:
  2021  *
  2025  *
  2022  * - `name` - General name for the post type, usually plural. The same and overridden
  2026  * - `name` - General name for the post type, usually plural. The same and overridden
  2023  *          by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
  2027  *          by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
  2024  * - `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
  2028  * - `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
  2025  * - `add_new` - Label for adding a new item. Default is 'Add New Post' / 'Add New Page'.
  2029  * - `add_new` - Label for adding a new item. Default is 'Add Post' / 'Add Page'.
  2026  * - `add_new_item` - Label for adding a new singular item. Default is 'Add New Post' / 'Add New Page'.
  2030  * - `add_new_item` - Label for adding a new singular item. Default is 'Add Post' / 'Add Page'.
  2027  * - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
  2031  * - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
  2028  * - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
  2032  * - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
  2029  * - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
  2033  * - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
  2030  * - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
  2034  * - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
  2031  * - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
  2035  * - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
  2082  * @since 5.8.0 Added the `item_link` and `item_link_description` labels.
  2086  * @since 5.8.0 Added the `item_link` and `item_link_description` labels.
  2083  * @since 6.3.0 Added the `item_trashed` label.
  2087  * @since 6.3.0 Added the `item_trashed` label.
  2084  * @since 6.4.0 Changed default values for the `add_new` label to include the type of content.
  2088  * @since 6.4.0 Changed default values for the `add_new` label to include the type of content.
  2085  *              This matches `add_new_item` and provides more context for better accessibility.
  2089  *              This matches `add_new_item` and provides more context for better accessibility.
  2086  * @since 6.6.0 Added the `template_name` label.
  2090  * @since 6.6.0 Added the `template_name` label.
       
  2091  * @since 6.7.0 Restored pre-6.4.0 defaults for the `add_new` label and updated documentation.
       
  2092  *              Updated core usage to reference `add_new_item`.
  2087  *
  2093  *
  2088  * @access private
  2094  * @access private
  2089  *
  2095  *
  2090  * @param object|WP_Post_Type $post_type_object Post type object.
  2096  * @param object|WP_Post_Type $post_type_object Post type object.
  2091  * @return object Object with all the labels as member variables.
  2097  * @return object Object with all the labels as member variables.
  2465 
  2471 
  2466 	$post_type   = get_post_type( $post );
  2472 	$post_type   = get_post_type( $post );
  2467 	$post_status = get_post_status( $post );
  2473 	$post_status = get_post_status( $post );
  2468 
  2474 
  2469 	return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
  2475 	return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
       
  2476 }
       
  2477 
       
  2478 /**
       
  2479  * Determines whether a post is embeddable.
       
  2480  *
       
  2481  * @since 6.8.0
       
  2482  *
       
  2483  * @param int|WP_Post|null $post Optional. Post ID or `WP_Post` object. Defaults to global $post.
       
  2484  * @return bool Whether the post should be considered embeddable.
       
  2485  */
       
  2486 function is_post_embeddable( $post = null ) {
       
  2487 	$post = get_post( $post );
       
  2488 
       
  2489 	if ( ! $post ) {
       
  2490 		return false;
       
  2491 	}
       
  2492 
       
  2493 	$post_type = get_post_type_object( $post->post_type );
       
  2494 
       
  2495 	if ( ! $post_type ) {
       
  2496 		return false;
       
  2497 	}
       
  2498 
       
  2499 	$is_embeddable = $post_type->embeddable;
       
  2500 
       
  2501 	/**
       
  2502 	 * Filter whether a post is embeddable.
       
  2503 	 *
       
  2504 	 * @since 6.8.0
       
  2505 	 *
       
  2506 	 * @param bool    $is_embeddable Whether the post is embeddable.
       
  2507 	 * @param WP_Post $post          Post object.
       
  2508 	 */
       
  2509 	return apply_filters( 'is_post_embeddable', $is_embeddable, $post );
  2470 }
  2510 }
  2471 
  2511 
  2472 /**
  2512 /**
  2473  * Retrieves an array of the latest posts, or posts matching the given criteria.
  2513  * Retrieves an array of the latest posts, or posts matching the given criteria.
  2474  *
  2514  *
  2550  *
  2590  *
  2551  * @since 1.5.0
  2591  * @since 1.5.0
  2552  *
  2592  *
  2553  * @param int    $post_id    Post ID.
  2593  * @param int    $post_id    Post ID.
  2554  * @param string $meta_key   Metadata name.
  2594  * @param string $meta_key   Metadata name.
  2555  * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
  2595  * @param mixed  $meta_value Metadata value. Arrays and objects are stored as serialized data and
       
  2596  *                           will be returned as the same type when retrieved. Other data types will
       
  2597  *                           be stored as strings in the database:
       
  2598  *                           - false is stored and retrieved as an empty string ('')
       
  2599  *                           - true is stored and retrieved as '1'
       
  2600  *                           - numbers (both integer and float) are stored and retrieved as strings
       
  2601  *                           Must be serializable if non-scalar.
  2556  * @param bool   $unique     Optional. Whether the same key should not be added.
  2602  * @param bool   $unique     Optional. Whether the same key should not be added.
  2557  *                           Default false.
  2603  *                           Default false.
  2558  * @return int|false Meta ID on success, false on failure.
  2604  * @return int|false Meta ID on success, false on failure.
  2559  */
  2605  */
  2560 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
  2606 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
  2605  *                        This parameter has no effect if `$key` is not specified.
  2651  *                        This parameter has no effect if `$key` is not specified.
  2606  *                        Default false.
  2652  *                        Default false.
  2607  * @return mixed An array of values if `$single` is false.
  2653  * @return mixed An array of values if `$single` is false.
  2608  *               The value of the meta field if `$single` is true.
  2654  *               The value of the meta field if `$single` is true.
  2609  *               False for an invalid `$post_id` (non-numeric, zero, or negative value).
  2655  *               False for an invalid `$post_id` (non-numeric, zero, or negative value).
  2610  *               An empty string if a valid but non-existing post ID is passed.
  2656  *               An empty array if a valid but non-existing post ID is passed and `$single` is false.
       
  2657  *               An empty string if a valid but non-existing post ID is passed and `$single` is true.
       
  2658  *               Note: Non-serialized values are returned as strings:
       
  2659  *               - false values are returned as empty strings ('')
       
  2660  *               - true values are returned as '1'
       
  2661  *               - numbers (both integer and float) are returned as strings
       
  2662  *               Arrays and objects retain their original type.
  2611  */
  2663  */
  2612 function get_post_meta( $post_id, $key = '', $single = false ) {
  2664 function get_post_meta( $post_id, $key = '', $single = false ) {
  2613 	return get_metadata( 'post', $post_id, $key, $single );
  2665 	return get_metadata( 'post', $post_id, $key, $single );
  2614 }
  2666 }
  2615 
  2667 
  2818  *                              same type as `$post`).
  2870  *                              same type as `$post`).
  2819  */
  2871  */
  2820 function sanitize_post( $post, $context = 'display' ) {
  2872 function sanitize_post( $post, $context = 'display' ) {
  2821 	if ( is_object( $post ) ) {
  2873 	if ( is_object( $post ) ) {
  2822 		// Check if post already filtered for this context.
  2874 		// Check if post already filtered for this context.
  2823 		if ( isset( $post->filter ) && $context == $post->filter ) {
  2875 		if ( isset( $post->filter ) && $context === $post->filter ) {
  2824 			return $post;
  2876 			return $post;
  2825 		}
  2877 		}
  2826 		if ( ! isset( $post->ID ) ) {
  2878 		if ( ! isset( $post->ID ) ) {
  2827 			$post->ID = 0;
  2879 			$post->ID = 0;
  2828 		}
  2880 		}
  2830 			$post->$field = sanitize_post_field( $field, $post->$field, $post->ID, $context );
  2882 			$post->$field = sanitize_post_field( $field, $post->$field, $post->ID, $context );
  2831 		}
  2883 		}
  2832 		$post->filter = $context;
  2884 		$post->filter = $context;
  2833 	} elseif ( is_array( $post ) ) {
  2885 	} elseif ( is_array( $post ) ) {
  2834 		// Check if post already filtered for this context.
  2886 		// Check if post already filtered for this context.
  2835 		if ( isset( $post['filter'] ) && $context == $post['filter'] ) {
  2887 		if ( isset( $post['filter'] ) && $context === $post['filter'] ) {
  2836 			return $post;
  2888 			return $post;
  2837 		}
  2889 		}
  2838 		if ( ! isset( $post['ID'] ) ) {
  2890 		if ( ! isset( $post['ID'] ) ) {
  2839 			$post['ID'] = 0;
  2891 			$post['ID'] = 0;
  2840 		}
  2892 		}
  2893 
  2945 
  2894 			/**
  2946 			/**
  2895 			 * Filters the value of a specific post field to edit.
  2947 			 * Filters the value of a specific post field to edit.
  2896 			 *
  2948 			 *
  2897 			 * The dynamic portion of the hook name, `$field`, refers to the post
  2949 			 * The dynamic portion of the hook name, `$field`, refers to the post
  2898 			 * field name.
  2950 			 * field name. Possible filter names include:
       
  2951 			 *
       
  2952 			 *  - `edit_post_author`
       
  2953 			 *  - `edit_post_date`
       
  2954 			 *  - `edit_post_date_gmt`
       
  2955 			 *  - `edit_post_content`
       
  2956 			 *  - `edit_post_title`
       
  2957 			 *  - `edit_post_excerpt`
       
  2958 			 *  - `edit_post_status`
       
  2959 			 *  - `edit_post_password`
       
  2960 			 *  - `edit_post_name`
       
  2961 			 *  - `edit_post_modified`
       
  2962 			 *  - `edit_post_modified_gmt`
       
  2963 			 *  - `edit_post_content_filtered`
       
  2964 			 *  - `edit_post_parent`
       
  2965 			 *  - `edit_post_type`
       
  2966 			 *  - `edit_post_mime_type`
  2899 			 *
  2967 			 *
  2900 			 * @since 2.3.0
  2968 			 * @since 2.3.0
  2901 			 *
  2969 			 *
  2902 			 * @param mixed $value   Value of the post field.
  2970 			 * @param mixed $value   Value of the post field.
  2903 			 * @param int   $post_id Post ID.
  2971 			 * @param int   $post_id Post ID.
  2905 			$value = apply_filters( "edit_{$field}", $value, $post_id );
  2973 			$value = apply_filters( "edit_{$field}", $value, $post_id );
  2906 
  2974 
  2907 			/**
  2975 			/**
  2908 			 * Filters the value of a specific post field to edit.
  2976 			 * Filters the value of a specific post field to edit.
  2909 			 *
  2977 			 *
  2910 			 * The dynamic portion of the hook name, `$field_no_prefix`, refers to
  2978 			 * Only applied to post fields with a name which is prefixed with `post_`.
  2911 			 * the post field name.
  2979 			 *
       
  2980 			 * The dynamic portion of the hook name, `$field_no_prefix`, refers to the
       
  2981 			 * post field name minus the `post_` prefix. Possible filter names include:
       
  2982 			 *
       
  2983 			 *  - `author_edit_pre`
       
  2984 			 *  - `date_edit_pre`
       
  2985 			 *  - `date_gmt_edit_pre`
       
  2986 			 *  - `content_edit_pre`
       
  2987 			 *  - `title_edit_pre`
       
  2988 			 *  - `excerpt_edit_pre`
       
  2989 			 *  - `status_edit_pre`
       
  2990 			 *  - `password_edit_pre`
       
  2991 			 *  - `name_edit_pre`
       
  2992 			 *  - `modified_edit_pre`
       
  2993 			 *  - `modified_gmt_edit_pre`
       
  2994 			 *  - `content_filtered_edit_pre`
       
  2995 			 *  - `parent_edit_pre`
       
  2996 			 *  - `type_edit_pre`
       
  2997 			 *  - `mime_type_edit_pre`
  2912 			 *
  2998 			 *
  2913 			 * @since 2.3.0
  2999 			 * @since 2.3.0
  2914 			 *
  3000 			 *
  2915 			 * @param mixed $value   Value of the post field.
  3001 			 * @param mixed $value   Value of the post field.
  2916 			 * @param int   $post_id Post ID.
  3002 			 * @param int   $post_id Post ID.
  2917 			 */
  3003 			 */
  2918 			$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );
  3004 			$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );
  2919 		} else {
  3005 		} else {
       
  3006 			/**
       
  3007 			 * Filters the value of a specific post field to edit.
       
  3008 			 *
       
  3009 			 * Only applied to post fields not prefixed with `post_`.
       
  3010 			 *
       
  3011 			 * The dynamic portion of the hook name, `$field`, refers to the
       
  3012 			 * post field name. Possible filter names include:
       
  3013 			 *
       
  3014 			 *  - `edit_post_ID`
       
  3015 			 *  - `edit_post_ping_status`
       
  3016 			 *  - `edit_post_pinged`
       
  3017 			 *  - `edit_post_to_ping`
       
  3018 			 *  - `edit_post_comment_count`
       
  3019 			 *  - `edit_post_comment_status`
       
  3020 			 *  - `edit_post_guid`
       
  3021 			 *  - `edit_post_menu_order`
       
  3022 			 *
       
  3023 			 * @since 2.3.0
       
  3024 			 *
       
  3025 			 * @param mixed $value   Value of the post field.
       
  3026 			 * @param int   $post_id Post ID.
       
  3027 			 */
  2920 			$value = apply_filters( "edit_post_{$field}", $value, $post_id );
  3028 			$value = apply_filters( "edit_post_{$field}", $value, $post_id );
  2921 		}
  3029 		}
  2922 
  3030 
  2923 		if ( in_array( $field, $format_to_edit, true ) ) {
  3031 		if ( in_array( $field, $format_to_edit, true ) ) {
  2924 			if ( 'post_content' === $field ) {
  3032 			if ( 'post_content' === $field ) {
  2933 		if ( $prefixed ) {
  3041 		if ( $prefixed ) {
  2934 
  3042 
  2935 			/**
  3043 			/**
  2936 			 * Filters the value of a specific post field before saving.
  3044 			 * Filters the value of a specific post field before saving.
  2937 			 *
  3045 			 *
       
  3046 			 * Only applied to post fields with a name which is prefixed with `post_`.
       
  3047 			 *
  2938 			 * The dynamic portion of the hook name, `$field`, refers to the post
  3048 			 * The dynamic portion of the hook name, `$field`, refers to the post
  2939 			 * field name.
  3049 			 * field name. Possible filter names include:
       
  3050 			 *
       
  3051 			 *  - `pre_post_author`
       
  3052 			 *  - `pre_post_date`
       
  3053 			 *  - `pre_post_date_gmt`
       
  3054 			 *  - `pre_post_content`
       
  3055 			 *  - `pre_post_title`
       
  3056 			 *  - `pre_post_excerpt`
       
  3057 			 *  - `pre_post_status`
       
  3058 			 *  - `pre_post_password`
       
  3059 			 *  - `pre_post_name`
       
  3060 			 *  - `pre_post_modified`
       
  3061 			 *  - `pre_post_modified_gmt`
       
  3062 			 *  - `pre_post_content_filtered`
       
  3063 			 *  - `pre_post_parent`
       
  3064 			 *  - `pre_post_type`
       
  3065 			 *  - `pre_post_mime_type`
  2940 			 *
  3066 			 *
  2941 			 * @since 2.3.0
  3067 			 * @since 2.3.0
  2942 			 *
  3068 			 *
  2943 			 * @param mixed $value Value of the post field.
  3069 			 * @param mixed $value Value of the post field.
  2944 			 */
  3070 			 */
  2945 			$value = apply_filters( "pre_{$field}", $value );
  3071 			$value = apply_filters( "pre_{$field}", $value );
  2946 
  3072 
  2947 			/**
  3073 			/**
  2948 			 * Filters the value of a specific field before saving.
  3074 			 * Filters the value of a specific field before saving.
  2949 			 *
  3075 			 *
  2950 			 * The dynamic portion of the hook name, `$field_no_prefix`, refers
  3076 			 * Only applied to post fields with a name which is prefixed with `post_`.
  2951 			 * to the post field name.
  3077 			 *
       
  3078 			 * The dynamic portion of the hook name, `$field_no_prefix`, refers to the
       
  3079 			 * post field name minus the `post_` prefix. Possible filter names include:
       
  3080 			 *
       
  3081 			 *  - `author_save_pre`
       
  3082 			 *  - `date_save_pre`
       
  3083 			 *  - `date_gmt_save_pre`
       
  3084 			 *  - `content_save_pre`
       
  3085 			 *  - `title_save_pre`
       
  3086 			 *  - `excerpt_save_pre`
       
  3087 			 *  - `status_save_pre`
       
  3088 			 *  - `password_save_pre`
       
  3089 			 *  - `name_save_pre`
       
  3090 			 *  - `modified_save_pre`
       
  3091 			 *  - `modified_gmt_save_pre`
       
  3092 			 *  - `content_filtered_save_pre`
       
  3093 			 *  - `parent_save_pre`
       
  3094 			 *  - `type_save_pre`
       
  3095 			 *  - `mime_type_save_pre`
  2952 			 *
  3096 			 *
  2953 			 * @since 2.3.0
  3097 			 * @since 2.3.0
  2954 			 *
  3098 			 *
  2955 			 * @param mixed $value Value of the post field.
  3099 			 * @param mixed $value Value of the post field.
  2956 			 */
  3100 			 */
  2957 			$value = apply_filters( "{$field_no_prefix}_save_pre", $value );
  3101 			$value = apply_filters( "{$field_no_prefix}_save_pre", $value );
  2958 		} else {
  3102 		} else {
       
  3103 			/**
       
  3104 			 * Filters the value of a specific field before saving.
       
  3105 			 *
       
  3106 			 * Only applied to post fields with a name which is prefixed with `post_`.
       
  3107 			 *
       
  3108 			 * The dynamic portion of the hook name, `$field_no_prefix`, refers to the
       
  3109 			 * post field name minus the `post_` prefix. Possible filter names include:
       
  3110 			 *
       
  3111 			 *  - `pre_post_ID`
       
  3112 			 *  - `pre_post_comment_status`
       
  3113 			 *  - `pre_post_ping_status`
       
  3114 			 *  - `pre_post_to_ping`
       
  3115 			 *  - `pre_post_pinged`
       
  3116 			 *  - `pre_post_guid`
       
  3117 			 *  - `pre_post_menu_order`
       
  3118 			 *  - `pre_post_comment_count`
       
  3119 			 *
       
  3120 			 * @since 2.3.0
       
  3121 			 *
       
  3122 			 * @param mixed $value Value of the post field.
       
  3123 			 */
  2959 			$value = apply_filters( "pre_post_{$field}", $value );
  3124 			$value = apply_filters( "pre_post_{$field}", $value );
  2960 
  3125 
  2961 			/**
  3126 			/**
  2962 			 * Filters the value of a specific post field before saving.
  3127 			 * Filters the value of a specific post field before saving.
  2963 			 *
  3128 			 *
       
  3129 			 * Only applied to post fields with a name which is *not* prefixed with `post_`.
       
  3130 			 *
  2964 			 * The dynamic portion of the hook name, `$field`, refers to the post
  3131 			 * The dynamic portion of the hook name, `$field`, refers to the post
  2965 			 * field name.
  3132 			 * field name. Possible filter names include:
       
  3133 			 *
       
  3134 			 *  - `ID_pre`
       
  3135 			 *  - `comment_status_pre`
       
  3136 			 *  - `ping_status_pre`
       
  3137 			 *  - `to_ping_pre`
       
  3138 			 *  - `pinged_pre`
       
  3139 			 *  - `guid_pre`
       
  3140 			 *  - `menu_order_pre`
       
  3141 			 *  - `comment_count_pre`
  2966 			 *
  3142 			 *
  2967 			 * @since 2.3.0
  3143 			 * @since 2.3.0
  2968 			 *
  3144 			 *
  2969 			 * @param mixed $value Value of the post field.
  3145 			 * @param mixed $value Value of the post field.
  2970 			 */
  3146 			 */
  2976 		if ( $prefixed ) {
  3152 		if ( $prefixed ) {
  2977 
  3153 
  2978 			/**
  3154 			/**
  2979 			 * Filters the value of a specific post field for display.
  3155 			 * Filters the value of a specific post field for display.
  2980 			 *
  3156 			 *
       
  3157 			 * Only applied to post fields with a name which is prefixed with `post_`.
       
  3158 			 *
  2981 			 * The dynamic portion of the hook name, `$field`, refers to the post
  3159 			 * The dynamic portion of the hook name, `$field`, refers to the post
  2982 			 * field name.
  3160 			 * field name. Possible filter names include:
       
  3161 			 *
       
  3162 			 *  - `post_author`
       
  3163 			 *  - `post_date`
       
  3164 			 *  - `post_date_gmt`
       
  3165 			 *  - `post_content`
       
  3166 			 *  - `post_title`
       
  3167 			 *  - `post_excerpt`
       
  3168 			 *  - `post_status`
       
  3169 			 *  - `post_password`
       
  3170 			 *  - `post_name`
       
  3171 			 *  - `post_modified`
       
  3172 			 *  - `post_modified_gmt`
       
  3173 			 *  - `post_content_filtered`
       
  3174 			 *  - `post_parent`
       
  3175 			 *  - `post_type`
       
  3176 			 *  - `post_mime_type`
  2983 			 *
  3177 			 *
  2984 			 * @since 2.3.0
  3178 			 * @since 2.3.0
  2985 			 *
  3179 			 *
  2986 			 * @param mixed  $value   Value of the prefixed post field.
  3180 			 * @param mixed  $value   Value of the prefixed post field.
  2987 			 * @param int    $post_id Post ID.
  3181 			 * @param int    $post_id Post ID.
  2989 			 *                        Accepts 'raw', 'edit', 'db', 'display',
  3183 			 *                        Accepts 'raw', 'edit', 'db', 'display',
  2990 			 *                        'attribute', or 'js'. Default 'display'.
  3184 			 *                        'attribute', or 'js'. Default 'display'.
  2991 			 */
  3185 			 */
  2992 			$value = apply_filters( "{$field}", $value, $post_id, $context );
  3186 			$value = apply_filters( "{$field}", $value, $post_id, $context );
  2993 		} else {
  3187 		} else {
       
  3188 			/**
       
  3189 			 * Filters the value of a specific post field for display.
       
  3190 			 *
       
  3191 			 * Only applied to post fields name which is *not* prefixed with `post_`.
       
  3192 			 *
       
  3193 			 * The dynamic portion of the hook name, `$field`, refers to the post
       
  3194 			 * field name. Possible filter names include:
       
  3195 			 *
       
  3196 			 *  - `post_ID`
       
  3197 			 *  - `post_comment_status`
       
  3198 			 *  - `post_ping_status`
       
  3199 			 *  - `post_to_ping`
       
  3200 			 *  - `post_pinged`
       
  3201 			 *  - `post_guid`
       
  3202 			 *  - `post_menu_order`
       
  3203 			 *  - `post_comment_count`
       
  3204 			 *
       
  3205 			 * @since 2.3.0
       
  3206 			 *
       
  3207 			 * @param mixed  $value   Value of the unprefixed post field.
       
  3208 			 * @param int    $post_id Post ID
       
  3209 			 * @param string $context Context for how to sanitize the field.
       
  3210 			 *                        Accepts 'raw', 'edit', 'db', 'display',
       
  3211 			 *                        'attribute', or 'js'. Default 'display'.
       
  3212 			 */
  2994 			$value = apply_filters( "post_{$field}", $value, $post_id, $context );
  3213 			$value = apply_filters( "post_{$field}", $value, $post_id, $context );
  2995 		}
  3214 		}
  2996 
  3215 
  2997 		if ( 'attribute' === $context ) {
  3216 		if ( 'attribute' === $context ) {
  2998 			$value = esc_attr( $value );
  3217 			$value = esc_attr( $value );
  3003 
  3222 
  3004 	// Restore the type for integer fields after esc_attr().
  3223 	// Restore the type for integer fields after esc_attr().
  3005 	if ( in_array( $field, $int_fields, true ) ) {
  3224 	if ( in_array( $field, $int_fields, true ) ) {
  3006 		$value = (int) $value;
  3225 		$value = (int) $value;
  3007 	}
  3226 	}
  3008 
       
  3009 	return $value;
  3227 	return $value;
  3010 }
  3228 }
  3011 
  3229 
  3012 /**
  3230 /**
  3013  * Makes a post sticky.
  3231  * Makes a post sticky.
  3217 		'attachments%s',
  3435 		'attachments%s',
  3218 		! empty( $mime_type ) ? ':' . str_replace( '/', '_', implode( '-', (array) $mime_type ) ) : ''
  3436 		! empty( $mime_type ) ? ':' . str_replace( '/', '_', implode( '-', (array) $mime_type ) ) : ''
  3219 	);
  3437 	);
  3220 
  3438 
  3221 	$counts = wp_cache_get( $cache_key, 'counts' );
  3439 	$counts = wp_cache_get( $cache_key, 'counts' );
  3222 	if ( false == $counts ) {
  3440 
       
  3441 	if ( false === $counts ) {
  3223 		$and   = wp_post_mime_type_where( $mime_type );
  3442 		$and   = wp_post_mime_type_where( $mime_type );
  3224 		$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
  3443 		$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
  3225 
  3444 
  3226 		$counts = array();
  3445 		$counts = array();
  3227 		foreach ( (array) $count as $row ) {
  3446 		foreach ( (array) $count as $row ) {
  3685 	if ( 'page' === $post->post_type ) {
  3904 	if ( 'page' === $post->post_type ) {
  3686 		/*
  3905 		/*
  3687 		 * If the page is defined in option page_on_front or post_for_posts,
  3906 		 * If the page is defined in option page_on_front or post_for_posts,
  3688 		 * adjust the corresponding options.
  3907 		 * adjust the corresponding options.
  3689 		 */
  3908 		 */
  3690 		if ( get_option( 'page_on_front' ) == $post->ID ) {
  3909 		if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
  3691 			update_option( 'show_on_front', 'posts' );
  3910 			update_option( 'show_on_front', 'posts' );
  3692 			update_option( 'page_on_front', 0 );
  3911 			update_option( 'page_on_front', 0 );
  3693 		}
  3912 		}
  3694 		if ( get_option( 'page_for_posts' ) == $post->ID ) {
  3913 		if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
  3695 			update_option( 'page_for_posts', 0 );
  3914 			update_option( 'page_for_posts', 0 );
  3696 		}
  3915 		}
  3697 	}
  3916 	}
  3698 
  3917 
  3699 	unstick_post( $post->ID );
  3918 	unstick_post( $post->ID );
  5887 
  6106 
  5888 	$pages = $wpdb->get_results( $sql, OBJECT_K );
  6107 	$pages = $wpdb->get_results( $sql, OBJECT_K );
  5889 
  6108 
  5890 	$revparts = array_reverse( $parts );
  6109 	$revparts = array_reverse( $parts );
  5891 
  6110 
  5892 	$foundid = 0;
  6111 	$found_id = 0;
  5893 	foreach ( (array) $pages as $page ) {
  6112 	foreach ( (array) $pages as $page ) {
  5894 		if ( $page->post_name == $revparts[0] ) {
  6113 		if ( $page->post_name === $revparts[0] ) {
  5895 			$count = 0;
  6114 			$count = 0;
  5896 			$p     = $page;
  6115 			$p     = $page;
  5897 
  6116 
  5898 			/*
  6117 			/*
  5899 			 * Loop through the given path parts from right to left,
  6118 			 * Loop through the given path parts from right to left,
  5900 			 * ensuring each matches the post ancestry.
  6119 			 * ensuring each matches the post ancestry.
  5901 			 */
  6120 			 */
  5902 			while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
  6121 			while ( 0 !== (int) $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
  5903 				++$count;
  6122 				++$count;
  5904 				$parent = $pages[ $p->post_parent ];
  6123 				$parent = $pages[ $p->post_parent ];
  5905 				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
  6124 				if ( ! isset( $revparts[ $count ] ) || $parent->post_name !== $revparts[ $count ] ) {
  5906 					break;
  6125 					break;
  5907 				}
  6126 				}
  5908 				$p = $parent;
  6127 				$p = $parent;
  5909 			}
  6128 			}
  5910 
  6129 
  5911 			if ( 0 == $p->post_parent && count( $revparts ) === $count + 1 && $p->post_name == $revparts[ $count ] ) {
  6130 			if ( 0 === (int) $p->post_parent
  5912 				$foundid = $page->ID;
  6131 				&& count( $revparts ) === $count + 1
  5913 				if ( $page->post_type == $post_type ) {
  6132 				&& $p->post_name === $revparts[ $count ]
       
  6133 			) {
       
  6134 				$found_id = $page->ID;
       
  6135 				if ( $page->post_type === $post_type ) {
  5914 					break;
  6136 					break;
  5915 				}
  6137 				}
  5916 			}
  6138 			}
  5917 		}
  6139 		}
  5918 	}
  6140 	}
  5919 
  6141 
  5920 	// We cache misses as well as hits.
  6142 	// We cache misses as well as hits.
  5921 	wp_cache_set( $cache_key, $foundid, 'post-queries' );
  6143 	wp_cache_set( $cache_key, $found_id, 'post-queries' );
  5922 
  6144 
  5923 	if ( $foundid ) {
  6145 	if ( $found_id ) {
  5924 		return get_post( $foundid, $output );
  6146 		return get_post( $found_id, $output );
  5925 	}
  6147 	}
  5926 
  6148 
  5927 	return null;
  6149 	return null;
  5928 }
  6150 }
  5929 
  6151 
  6180 
  6402 
  6181 		if ( ! empty( $post_authors ) ) {
  6403 		if ( ! empty( $post_authors ) ) {
  6182 			$query_args['author__in'] = array();
  6404 			$query_args['author__in'] = array();
  6183 			foreach ( $post_authors as $post_author ) {
  6405 			foreach ( $post_authors as $post_author ) {
  6184 				// Do we have an author id or an author login?
  6406 				// Do we have an author id or an author login?
  6185 				if ( 0 == (int) $post_author ) {
  6407 				if ( 0 === (int) $post_author ) {
  6186 					$post_author = get_user_by( 'login', $post_author );
  6408 					$post_author = get_user_by( 'login', $post_author );
  6187 					if ( empty( $post_author ) ) {
  6409 					if ( empty( $post_author ) ) {
  6188 						continue;
  6410 						continue;
  6189 					}
  6411 					}
  6190 					if ( empty( $post_author->ID ) ) {
  6412 					if ( empty( $post_author->ID ) ) {
  6827 		return $type === $ext;
  7049 		return $type === $ext;
  6828 	}
  7050 	}
  6829 
  7051 
  6830 	switch ( $type ) {
  7052 	switch ( $type ) {
  6831 		case 'image':
  7053 		case 'image':
  6832 			$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'avif' );
  7054 			$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'avif', 'heic' );
  6833 			return in_array( $ext, $image_exts, true );
  7055 			return in_array( $ext, $image_exts, true );
  6834 
  7056 
  6835 		case 'audio':
  7057 		case 'audio':
  6836 			return in_array( $ext, wp_get_audio_extensions(), true );
  7058 			return in_array( $ext, wp_get_audio_extensions(), true );
  6837 
  7059 
  7033  * @param WP_Post $post        The post object.
  7255  * @param WP_Post $post        The post object.
  7034  * @param WP_Post $post_before The previous post object.
  7256  * @param WP_Post $post_before The previous post object.
  7035  */
  7257  */
  7036 function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
  7258 function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
  7037 	// Don't bother if it hasn't changed.
  7259 	// Don't bother if it hasn't changed.
  7038 	if ( $post->post_name == $post_before->post_name ) {
  7260 	if ( $post->post_name === $post_before->post_name ) {
  7039 		return;
  7261 		return;
  7040 	}
  7262 	}
  7041 
  7263 
  7042 	// We're only concerned with published, non-hierarchical objects.
  7264 	// We're only concerned with published, non-hierarchical objects.
  7043 	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
  7265 	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === $post->post_type && 'inherit' === $post->post_status ) )
       
  7266 		|| is_post_type_hierarchical( $post->post_type )
       
  7267 	) {
  7044 		return;
  7268 		return;
  7045 	}
  7269 	}
  7046 
  7270 
  7047 	$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
  7271 	$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
  7048 
  7272 
  7079 function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
  7303 function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
  7080 	$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
  7304 	$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
  7081 	$new_date      = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
  7305 	$new_date      = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
  7082 
  7306 
  7083 	// Don't bother if it hasn't changed.
  7307 	// Don't bother if it hasn't changed.
  7084 	if ( $new_date == $previous_date ) {
  7308 	if ( $new_date === $previous_date ) {
  7085 		return;
  7309 		return;
  7086 	}
  7310 	}
  7087 
  7311 
  7088 	// We're only concerned with published, non-hierarchical objects.
  7312 	// We're only concerned with published, non-hierarchical objects.
  7089 	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
  7313 	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === $post->post_type && 'inherit' === $post->post_status ) )
       
  7314 		|| is_post_type_hierarchical( $post->post_type )
       
  7315 	) {
  7090 		return;
  7316 		return;
  7091 	}
  7317 	}
  7092 
  7318 
  7093 	$old_dates = (array) get_post_meta( $post_id, '_wp_old_date' );
  7319 	$old_dates = (array) get_post_meta( $post_id, '_wp_old_date' );
  7094 
  7320 
  7180 			} elseif ( is_user_logged_in() ) {
  7406 			} elseif ( is_user_logged_in() ) {
  7181 				// Users can view their own private posts.
  7407 				// Users can view their own private posts.
  7182 				$id = get_current_user_id();
  7408 				$id = get_current_user_id();
  7183 				if ( null === $post_author || ! $full ) {
  7409 				if ( null === $post_author || ! $full ) {
  7184 					$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
  7410 					$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
  7185 				} elseif ( $id == (int) $post_author ) {
  7411 				} elseif ( $id === (int) $post_author ) {
  7186 					$post_status_sql .= " OR post_status = 'private'";
  7412 					$post_status_sql .= " OR post_status = 'private'";
  7187 				} // Else none.
  7413 				} // Else none.
  7188 			} // Else none.
  7414 			} // Else none.
  7189 		}
  7415 		}
  7190 
  7416 
  7756 	if ( ! $post_id ) {
  7982 	if ( ! $post_id ) {
  7757 		return $post_parent;
  7983 		return $post_parent;
  7758 	}
  7984 	}
  7759 
  7985 
  7760 	// Can't be its own parent.
  7986 	// Can't be its own parent.
  7761 	if ( $post_parent == $post_id ) {
  7987 	if ( $post_parent === $post_id ) {
  7762 		return 0;
  7988 		return 0;
  7763 	}
  7989 	}
  7764 
  7990 
  7765 	// Now look for larger loops.
  7991 	// Now look for larger loops.
  7766 	$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_id, $post_parent );
  7992 	$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_id, $post_parent );
  7791  *
  8017  *
  7792  * @since 3.1.0
  8018  * @since 3.1.0
  7793  *
  8019  *
  7794  * @param int|WP_Post $post         Post ID or post object where thumbnail should be attached.
  8020  * @param int|WP_Post $post         Post ID or post object where thumbnail should be attached.
  7795  * @param int         $thumbnail_id Thumbnail to attach.
  8021  * @param int         $thumbnail_id Thumbnail to attach.
  7796  * @return int|bool True on success, false on failure.
  8022  * @return int|bool Post meta ID if the key didn't exist (ie. this is the first time that
       
  8023  *                  a thumbnail has been saved for the post), true on successful update,
       
  8024  *                  false on failure or if the value passed is the same as the one that
       
  8025  *                  is already in the database.
  7797  */
  8026  */
  7798 function set_post_thumbnail( $post, $thumbnail_id ) {
  8027 function set_post_thumbnail( $post, $thumbnail_id ) {
  7799 	$post         = get_post( $post );
  8028 	$post         = get_post( $post );
  7800 	$thumbnail_id = absint( $thumbnail_id );
  8029 	$thumbnail_id = absint( $thumbnail_id );
  7801 	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
  8030 	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {