Make WordPress Core

Ticket #33045: 33045.8.diff

File 33045.8.diff, 979 bytes (added by xkon, 4 years ago)
  • src/wp-includes/post-template.php

    diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
    index 0ad352c328..d5b6aa3f5b 100644
    a b function wp_list_post_revisions( $post_id = 0, $type = 'all' ) { 
    19631963        echo $rows;
    19641964        echo '</ul>';
    19651965}
     1966
     1967/**
     1968 * Retrieve the parent post object.
     1969 *
     1970 * @since 5.7.0
     1971 *
     1972 * @param int|WP_Post|null $post Optional. Post ID or post object.
     1973 *
     1974 * @return WP_Post Parent post object.
     1975 */
     1976function get_post_parent( $post = null ) {
     1977        $wp_post = get_post( $post );
     1978        return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null;
     1979}
     1980
     1981/**
     1982 * Whether the post has a parent post.
     1983 *
     1984 * @since 5.7.0
     1985 *
     1986 * @param int|WP_Post|null $post Optional. Post ID or post object.
     1987 *
     1988 * @return bool True is the post has a parent post, false otherwise.
     1989 */
     1990function has_post_parent( $post = null ) {
     1991        return (bool) get_post_parent( $post );
     1992}