<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[40916] trunk: Add term meta support to XML-RPC `addTerm` and `editTerm` endpoints.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/40916">40916</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/40916","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-06-18 10:39:12 +0000 (Sun, 18 Jun 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/35991">#35991</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpxmlrpcserverphp">trunk/src/wp-includes/class-wp-xmlrpc-server.php</a></li>
<li><a href="#trunksrcwpincludestaxonomyphp">trunk/src/wp-includes/taxonomy.php</a></li>
<li><a href="#trunktestsphpunitteststermmetaphp">trunk/tests/phpunit/tests/term/meta.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpeditTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetTermsphp">trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpnewTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpxmlrpcserverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-xmlrpc-server.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-xmlrpc-server.php  2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/src/wp-includes/class-wp-xmlrpc-server.php    2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -404,6 +404,68 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Retrieve custom fields for a term.
+        *
+        * @since 4.9.0
+        *
+        * @param int $post_id Post ID.
+        * @return array Array of custom fields, if they exist.
+        */
+       public function get_term_custom_fields( $term_id ) {
+               $term_id = (int) $term_id;
+
+               $custom_fields = array();
+
+               foreach ( (array) has_term_meta( $term_id ) as $meta ) {
+
+                       if ( ! current_user_can( 'edit_term_meta', $term_id ) ) {
+                               continue;
+                       }
+
+                       $custom_fields[] = array(
+                               'id'    => $meta['meta_id'],
+                               'key'   => $meta['meta_key'],
+                               'value' => $meta['meta_value'],
+                       );
+               }
+
+               return $custom_fields;
+       }
+
+       /**
+        * Set custom fields for a term.
+        *
+        * @since 4.9.0
+        *
+        * @param int $post_id Post ID.
+        * @param array $fields Custom fields.
+        */
+       public function set_term_custom_fields( $term_id, $fields ) {
+               $term_id = (int) $term_id;
+
+               foreach ( (array) $fields as $meta ) {
+                       if ( isset( $meta['id'] ) ) {
+                               $meta['id'] = (int) $meta['id'];
+                               $pmeta = get_metadata_by_mid( 'term', $meta['id'] );
+                               if ( isset( $meta['key'] ) ) {
+                                       $meta['key'] = wp_unslash( $meta['key'] );
+                                       if ( $meta['key'] !== $pmeta->meta_key ) {
+                                               continue;
+                                       }
+                                       $meta['value'] = wp_unslash( $meta['value'] );
+                                       if ( current_user_can( 'edit_term_meta', $term_id ) ) {
+                                               update_metadata_by_mid( 'term', $meta['id'], $meta['value'] );
+                                       }
+                               } elseif ( current_user_can( 'delete_term_meta', $term_id ) ) {
+                                       delete_metadata_by_mid( 'term', $meta['id'] );
+                               }
+                       } elseif ( current_user_can( 'add_term_meta', $term_id ) ) {
+                               add_term_meta( $term_id, $meta['key'], $meta['value'] );
+                       }
+               }
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Set up blog options property.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Passes property through {@see 'xmlrpc_blog_options'} filter.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -742,6 +804,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Count we are happy to return as an integer because people really shouldn't use terms that much.
</span><span class="cx" style="display: block; padding: 0 10px">                $_term['count'] = intval( $_term['count'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Get term meta.
+               $_term['custom_fields'] = $this->get_term_custom_fields( $_term['term_id'] );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Filters XML-RPC-prepared data for the given term.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1943,6 +2008,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! $term )
</span><span class="cx" style="display: block; padding: 0 10px">                        return new IXR_Error( 500, __( 'Sorry, your term could not be created.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Add term meta.
+               if ( isset( $content_struct['custom_fields'] ) ) {
+                       $this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return strval( $term['term_id'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2042,6 +2112,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! $term )
</span><span class="cx" style="display: block; padding: 0 10px">                        return new IXR_Error( 500, __( 'Sorry, editing the term failed.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Update term meta.
+               if ( isset( $content_struct['custom_fields'] ) ) {
+                       $this->set_term_custom_fields( $term_id, $content_struct['custom_fields'] );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return true;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludestaxonomyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/taxonomy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/taxonomy.php        2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/src/wp-includes/taxonomy.php  2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1241,6 +1241,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Get all meta data, including meta IDs, for the given term ID.
+ *
+ * @since 4.9.0
+ *
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
+ * @param int $term_id
+ * @return array|false
+ */
+function has_term_meta( $term_id ) {
+       // Bail if term meta table is not installed.
+       if ( get_option( 'db_version' ) < 34370 ) {
+               return false;
+       }
+
+       global $wpdb;
+
+       return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, term_id FROM $wpdb->termmeta WHERE term_id = %d ORDER BY meta_key,meta_id", $term_id ), ARRAY_A );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Check if Term exists.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Formerly is_term(), introduced in 2.3.0.
</span></span></pre></div>
<a id="trunktestsphpunitteststermmetaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/meta.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/meta.php   2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/tests/phpunit/tests/term/meta.php     2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -404,6 +404,40 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( '', get_term_meta( $t, 'foo1', true ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * @ticket 35991
+        */
+       public function test_has_term_meta() {
+               $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
+
+               $term_meta_id = add_term_meta( $t, 'foo', 'bar' );
+               $meta = has_term_meta( $t );
+
+               $this->assertSame( 1, count( $meta ) );
+
+               $expected = array(
+                       'meta_key' => 'foo',
+                       'meta_value' => 'bar',
+                       'meta_id' => $term_meta_id,
+                       'term_id' => $t,
+               );
+
+               $found = $meta[0];
+
+               $this->assertEquals( $expected, $found );
+       }
+
+       /**
+        * @ticket 35991
+        */
+       public function test_has_term_meta_empty_results() {
+               $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
+
+               $meta = has_term_meta( $t );
+
+               $this->assertSame( array(), $meta );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         public static function set_cache_results( $q ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $q->set( 'cache_results', true );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpeditTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php  2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php    2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,4 +145,74 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotIXRError( $result );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertInternalType( 'boolean', $result );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket 35991
+        */
+       public function test_update_term_meta() {
+               register_taxonomy( 'wptests_tax', 'post' );
+
+               $t = self::factory()->term->create( array(
+                       'taxonomy' => 'wptests_tax',
+               ) );
+               $meta_id = add_term_meta( $t, 'foo', 'bar' );
+
+               $this->make_user_by_role( 'editor' );
+
+               $result = $this->myxmlrpcserver->wp_editTerm( array(
+                       1,
+                       'editor',
+                       'editor',
+                       $t,
+                       array(
+                               'taxonomy' => 'wptests_tax',
+                               'custom_fields' => array(
+                                       array(
+                                               'id' => $meta_id,
+                                               'key' => 'foo',
+                                               'value' => 'baz',
+                                       ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertNotIXRError( $result );
+
+               $found = get_term_meta( $t, 'foo', true );
+               $this->assertSame( 'baz', $found );
+       }
+
+       /**
+        * @ticket 35991
+        */
+       public function test_delete_term_meta() {
+               register_taxonomy( 'wptests_tax', 'post' );
+
+               $t = self::factory()->term->create( array(
+                       'taxonomy' => 'wptests_tax',
+               ) );
+               $meta_id = add_term_meta( $t, 'foo', 'bar' );
+
+               $this->make_user_by_role( 'editor' );
+
+               $result = $this->myxmlrpcserver->wp_editTerm( array(
+                       1,
+                       'editor',
+                       'editor',
+                       $t,
+                       array(
+                               'taxonomy' => 'wptests_tax',
+                               'custom_fields' => array(
+                                       array(
+                                               'id' => $meta_id,
+                                       ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertNotIXRError( $result );
+
+               $found = get_term_meta( $t, 'foo' );
+               $this->assertSame( array(), $found );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php   2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php     2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,6 +69,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $term = get_term( self::$term_id, 'category', ARRAY_A );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $term['custom_fields'] = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,4 +96,29 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'category', $result['taxonomy'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( $term['description'], $result['description'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket 35991
+        */
+       public function test_get_term_meta() {
+               $this->make_user_by_role( 'editor' );
+
+               // Add term meta to test wp.getTerm.
+               add_term_meta( self::$term_id, 'foo', 'bar' );
+
+               $term = get_term( self::$term_id, 'category', ARRAY_A );
+
+               $result = $this->myxmlrpcserver->wp_getTerm( array(
+                       1,
+                       'editor',
+                       'editor',
+                       'category',
+                       self::$term_id,
+               ) );
+               $this->assertNotIXRError( $result );
+
+               $this->assertInternalType( 'array', $result['custom_fields'] );
+               $term_meta = get_term_meta( self::$term_id, '', true );
+               $this->assertEquals( $term_meta['foo'][0], $result['custom_fields'][0]['value'] );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetTermsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php  2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php    2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,6 +50,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                foreach( $results as $term ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->assertInternalType( 'int', $term['count'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Check custom term meta
+                       $this->assertInternalType( 'array', $term['custom_fields'] );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         // We expect all other IDs to be strings not integers so we don't return something larger than an XMLRPC integer can describe.
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->assertStringMatchesFormat( '%d', $term['term_id'] );
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->assertStringMatchesFormat( '%d', $term['term_group'] );
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpnewTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php   2017-06-15 15:36:20 UTC (rev 40915)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php     2017-06-18 10:39:12 UTC (rev 40916)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,4 +106,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotIXRError( $result );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertStringMatchesFormat( '%d', $result );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket 35991
+        */
+       public function test_add_term_meta() {
+               $this->make_user_by_role( 'editor' );
+               $result = $this->myxmlrpcserver->wp_newTerm( array(
+                       1,
+                       'editor',
+                       'editor',
+                       array(
+                               'taxonomy' => 'category',
+                               'name' => 'Test meta',
+                               'custom_fields' => array(
+                                       array(
+                                               'key' => 'key1',
+                                               'value' => 'value1',
+                                       ),
+                               ),
+                       ),
+               ) );
+               $this->assertNotIXRError( $result );
+               $this->assertStringMatchesFormat( '%d', $result );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>