Make WordPress Core


Ignore:
Timestamp:
06/18/2017 10:39:12 AM (7 years ago)
Author:
boonebgorges
Message:

Add term meta support to XML-RPC addTerm and editTerm endpoints.

This changeset also includes the new function has_term_meta(), a
counterpart to has_meta() (for posts).

Props enrico.sorcinelli.
Fixes #35991.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php

    r40417 r40916  
    7070
    7171        $term = get_term( self::$term_id, 'category', ARRAY_A );
     72        $term['custom_fields'] = array();
    7273
    7374        $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
     
    9697        $this->assertEquals( $term['description'], $result['description'] );
    9798    }
     99
     100    /**
     101     * @ticket 35991
     102     */
     103    public function test_get_term_meta() {
     104        $this->make_user_by_role( 'editor' );
     105
     106        // Add term meta to test wp.getTerm.
     107        add_term_meta( self::$term_id, 'foo', 'bar' );
     108
     109        $term = get_term( self::$term_id, 'category', ARRAY_A );
     110
     111        $result = $this->myxmlrpcserver->wp_getTerm( array(
     112            1,
     113            'editor',
     114            'editor',
     115            'category',
     116            self::$term_id,
     117        ) );
     118        $this->assertNotIXRError( $result );
     119
     120        $this->assertInternalType( 'array', $result['custom_fields'] );
     121        $term_meta = get_term_meta( self::$term_id, '', true );
     122        $this->assertEquals( $term_meta['foo'][0], $result['custom_fields'][0]['value'] );
     123    }
    98124}
Note: See TracChangeset for help on using the changeset viewer.