mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Posts, Post Types: Rename the new post parent conditional tag functions for clarity.
* `get_parent_post()` becomes `get_post_parent()` * `has_parent_post()` becomes `has_post_parent()` Props johnjamesjacoby, SergeyBiryukov, lukecarbis, peterwilsoncc Fixes #33045 git-svn-id: https://develop.svn.wordpress.org/trunk@50396 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1972,7 +1972,7 @@ function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
|
||||
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
|
||||
* @return WP_Post|null Parent post object, or null if there isn't one.
|
||||
*/
|
||||
function get_parent_post( $post = null ) {
|
||||
function get_post_parent( $post = null ) {
|
||||
$wp_post = get_post( $post );
|
||||
return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null;
|
||||
}
|
||||
@@ -1985,6 +1985,6 @@ function get_parent_post( $post = null ) {
|
||||
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
|
||||
* @return bool Whether the post has a parent post.
|
||||
*/
|
||||
function has_parent_post( $post = null ) {
|
||||
return (bool) get_parent_post( $post );
|
||||
function has_post_parent( $post = null ) {
|
||||
return (bool) get_post_parent( $post );
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ NO;
|
||||
$child_id = self::factory()->post->create( $post );
|
||||
|
||||
// Test if child get_parent_post() post returns Null by default.
|
||||
$parent = get_parent_post( $child_id );
|
||||
$parent = get_post_parent( $child_id );
|
||||
$this->assertNull( $parent );
|
||||
|
||||
// Update child post with a parent.
|
||||
@@ -479,7 +479,7 @@ NO;
|
||||
);
|
||||
|
||||
// Test if child get_parent_post() post returns the parent object.
|
||||
$parent = get_parent_post( $child_id );
|
||||
$parent = get_post_parent( $child_id );
|
||||
$this->assertNotNull( $parent );
|
||||
$this->assertSame( $parent_id, $parent->ID );
|
||||
}
|
||||
@@ -498,7 +498,7 @@ NO;
|
||||
$child_id = self::factory()->post->create( $post );
|
||||
|
||||
// Test if child has_parent_post() post returns False by default.
|
||||
$parent = has_parent_post( $child_id );
|
||||
$parent = has_post_parent( $child_id );
|
||||
$this->assertFalse( $parent );
|
||||
|
||||
// Update child post with a parent.
|
||||
@@ -510,7 +510,7 @@ NO;
|
||||
);
|
||||
|
||||
// Test if child has_parent_post() returns True.
|
||||
$parent = has_parent_post( $child_id );
|
||||
$parent = has_post_parent( $child_id );
|
||||
$this->assertTrue( $parent );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user