Make WordPress Core


Ignore:
Timestamp:
09/05/2015 07:49:53 PM (9 years ago)
Author:
wonderboymusic
Message:

Allow wp_insert_post() to accept a meta_input argument. Devs should use register_meta() to ensure that specific values specified by key are sanitized properly.

Adds unit test.

Props CoenJacobs, swissspidy.
Fixes #20451.

File:
1 edited

Legend:

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

    r33776 r33910  
    27762776 * @since 1.0.0
    27772777 * @since 4.2.0 Support was added for encoding emoji in the post title, content, and excerpt.
     2778 * @since 4.4.0 A 'meta_input' array can now be passed to $postarr to add post meta data.
    27782779 *
    27792780 * @see sanitize_post()
     
    31733174    }
    31743175
     3176    if ( ! empty( $postarr['meta_input'] ) ) {
     3177        foreach ( $postarr['meta_input'] as $field => $value ) {
     3178            update_post_meta( $post_ID, $field, $value );
     3179        }
     3180    }
     3181
    31753182    $current_guid = get_post_field( 'guid', $post_ID );
    31763183
Note: See TracChangeset for help on using the changeset viewer.