WordPress.org

Make WordPress Core

Ticket #33045: 33045.patch

File 33045.patch, 993 bytes (added by ramiy, 6 years ago)
  • post-template.php

     
    387387}
    388388
    389389/**
     390 * Whether the post has parent.
     391 *
     392 * @since 4.3.0
     393 *
     394 * @param int|WP_Post $id Optional. Post ID or post object.
     395 * @return bool
     396 */
     397function has_parent( $id = 0 ) {
     398        $post = get_post( $id );
     399        return ( $post->post_parent > 0 );
     400}
     401
     402/**
     403 * Retrieve the parent post ID.
     404 *
     405 * @since 4.3.0
     406 *
     407 * @param int|WP_Post $id Optional. Post ID or post object.
     408 * @return int
     409 */
     410function get_parent( $id = 0 ) {
     411        $post = get_post( $id );
     412        if ( empty( $post ) || ( $post->post_parent <= 0 ) ) {
     413                return '';
     414        }
     415
     416        /**
     417         * Filter the retrieved post parent.
     418         *
     419         * @since 4.3.0
     420         *
     421         * @param string $post_parent The post parent.
     422         */
     423        return apply_filters( 'get_parent', $post->post_parent );
     424}
     425
     426/**
    390427 * Display the classes for the post div.
    391428 *
    392429 * @since 2.7.0