WordPress.org

Make WordPress Core

Changeset 36481


Ignore:
Timestamp:
02/05/2016 06:57:09 PM (6 years ago)
Author:
boonebgorges
Message:

Make the $post param optional in get_post_field().

When $post is null, the current post object will be returned.

Props sebastian.pisula.
Fixes #35683.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r36402 r36481  
    495495 *
    496496 * @since 2.3.0
     497 * @since 4.5.0 The `$post` parameter was made optional.
    497498 *
    498499 * @see sanitize_post_field()
    499500 *
    500501 * @param string      $field   Post field name.
    501  * @param int|WP_Post $post    Post ID or post object.
     502 * @param int|WP_Post $post    Optional. Post ID or post object. Defaults to current post.
    502503 * @param string      $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db',
    503504 *                             or 'display'. Default 'display'.
    504505 * @return string The value of the post field on success, empty string on failure.
    505506 */
    506 function get_post_field( $field, $post, $context = 'display' ) {
     507function get_post_field( $field, $post = null, $context = 'display' ) {
    507508    $post = get_post( $post );
    508509
Note: See TracChangeset for help on using the changeset viewer.