Make WordPress Core

Ticket #35949: 35949.patch

File 35949.patch, 1.2 KB (added by sebastian.pisula, 9 years ago)
  • wp-includes/post.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    506506 * @param int|WP_Post $post    Optional. Post ID or post object. Defaults to current post.
    507507 * @param string      $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db',
    508508 *                             or 'display'. Default 'display'.
     509 * @param string      $default Optional. Default value return. Default empty string.
    509510 * @return string The value of the post field on success, empty string on failure.
    510511 */
    511 function get_post_field( $field, $post = null, $context = 'display' ) {
     512function get_post_field( $field, $post = null, $context = 'display', $default = '' ) {
    512513        $post = get_post( $post );
    513514
    514         if ( !$post )
    515                 return '';
    516 
    517         if ( !isset($post->$field) )
    518                 return '';
     515        if ( !$post || !isset($post->$field)){
     516                return $default;
     517        }
    519518
    520519        return sanitize_post_field($field, $post->$field, $post->ID, $context);
    521520}