From ab78f7561a5369e0f39a3e3e4e27f7c5af422d81 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 17 Nov 2021 03:25:06 +0000 Subject: [PATCH] Posts, Post Types: Use global post as the default for `wp_get_post_parent_id()`. Convert the `$post` parameter of `wp_get_post_parent_id()` to optional, defaulting to the current global post object when called within the loop. Props danielpost, davidbaumwald, SergeyBiryukov, birgire, audrasjb, hellofromTonya, TimothyBlynJacobs. Fixes #48358. Built from https://develop.svn.wordpress.org/trunk@52194 git-svn-id: http://core.svn.wordpress.org/trunk@51786 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 5 +++-- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 286ad8ccf6..5a0671ac46 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -7642,12 +7642,13 @@ function _publish_post_hook( $post_id ) { * Returns the ID of the post's parent. * * @since 3.1.0 + * @since 5.9.0 The `$post` parameter was made optional. * - * @param int|WP_Post $post Post ID or post object. + * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. * @return int|false Post parent ID (which can be 0 if there is no parent), * or false if the post does not exist. */ -function wp_get_post_parent_id( $post ) { +function wp_get_post_parent_id( $post = null ) { $post = get_post( $post ); if ( ! $post || is_wp_error( $post ) ) { return false; diff --git a/wp-includes/version.php b/wp-includes/version.php index ee990fb251..e49aadf12b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52193'; +$wp_version = '5.9-alpha-52194'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.