WordPress.org

Make WordPress Core

Ticket #33045: 33045.2.patch

File 33045.2.patch, 967 bytes (added by ramiy, 6 years ago)
  • wp-includes/post-template.php

     
    387387}
    388388
    389389/**
     390 * Whether the post has a parent post.
     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
     413        /**
     414         * Filter the retrieved post parent id.
     415         *
     416         * @since 4.3.0
     417         *
     418         * @param string $post_parent The post parent id.
     419         */
     420        return apply_filters( 'get_parent', $post->post_parent );
     421}
     422
     423/**
    390424 * Display the classes for the post div.
    391425 *
    392426 * @since 2.7.0