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/tests/phpunit/tests/post.php

    r33630 r33910  
    454454
    455455    /**
     456     * @ticket 20451
     457     */
     458    public function test_wp_insert_post_with_meta_input() {
     459        $post_id = wp_insert_post( array(
     460            'post_title'   => '',
     461            'post_content' => 'test',
     462            'post_status'  => 'publish',
     463            'post_type'    => 'post',
     464            'meta_input'   => array(
     465                'hello' => 'world',
     466                'foo'   => 'bar'
     467            )
     468        ) );
     469
     470        $this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) );
     471        $this->assertEquals( 'bar', get_post_meta( $post_id, 'foo', true ) );
     472    }
     473
     474    /**
    456475     * @ticket 5364
    457476     */
Note: See TracChangeset for help on using the changeset viewer.