<!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>[38698] trunk: Taxonomy: Introduce more fine grained capabilities for managing taxonomy terms.</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/38698">38698</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/38698","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-09-30 22:39:32 +0000 (Fri, 30 Sep 2016)</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'>Taxonomy: Introduce more fine grained capabilities for managing taxonomy terms.
This introduces the singular `edit_term`, `delete_term`, and `assign_term` meta capabilities for terms, and switches the base capability name for tags from `manage_categories` to `manage_post_tags` and the corresponding `edit_post_tags`, `delete_post_tags`, and `assign_post_tags`.
All of these capabilities ultimately map to `manage_categories` so by default there is no change in the behaviour of the capabilities for categories, tags, or custom taxonomies. The `map_meta_cap` filter and the `capabilities` argument when registering a taxonomy now allow for control over editing, deleting, and assigning individual terms, as well as a separation of capabilities for tags from those of categories.
Fixes <a href="https://core.trac.wordpress.org/ticket/35614">#35614</a>
Props johnjamesjacoby for feedback</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminedittagsphp">trunk/src/wp-admin/edit-tags.php</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswptermslisttablephp">trunk/src/wp-admin/includes/class-wp-terms-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesmetaboxesphp">trunk/src/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunksrcwpadmintermphp">trunk/src/wp-admin/term.php</a></li>
<li><a href="#trunksrcwpincludesadminbarphp">trunk/src/wp-includes/admin-bar.php</a></li>
<li><a href="#trunksrcwpincludescapabilitiesphp">trunk/src/wp-includes/capabilities.php</a></li>
<li><a href="#trunksrcwpincludesclasswpxmlrpcserverphp">trunk/src/wp-includes/class-wp-xmlrpc-server.php</a></li>
<li><a href="#trunksrcwpincludeslinktemplatephp">trunk/src/wp-includes/link-template.php</a></li>
<li><a href="#trunksrcwpincludestaxonomyphp">trunk/src/wp-includes/taxonomy.php</a></li>
<li><a href="#trunktestsphpunittestsusercapabilitiesphp">trunk/tests/phpunit/tests/user/capabilities.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpdeleteTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminedittagsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/edit-tags.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/edit-tags.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-admin/edit-tags.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,7 +108,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tag_ID = (int) $_REQUEST['tag_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'delete-tag_' . $tag_ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $tax->cap->delete_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'delete_term', $tag_ID ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die(
</span><span class="cx" style="display: block; padding: 0 10px"> '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
</span><span class="cx" style="display: block; padding: 0 10px"> '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,7 +168,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tag_ID = (int) $_POST['tag_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'update-tag_' . $tag_ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $tax->cap->edit_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'edit_term', $tag_ID ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die(
</span><span class="cx" style="display: block; padding: 0 10px"> '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
</span><span class="cx" style="display: block; padding: 0 10px"> '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -314,14 +314,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> require_once( ABSPATH . 'wp-admin/admin-header.php' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( ! current_user_can( $tax->cap->edit_terms ) ) {
- wp_die(
- '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
- '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
- 403
- );
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> /** Also used by the Edit Tag form */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -594,12 +594,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tag_id = (int) $_POST['tag_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "delete-tag_$tag_id" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
- $tax = get_taxonomy($taxonomy);
-
- if ( !current_user_can( $tax->cap->delete_terms ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'delete_term', $tag_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
</ins><span class="cx" style="display: block; padding: 0 10px"> $tag = get_term( $tag_id, $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$tag || is_wp_error( $tag ) )
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -796,8 +795,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) )
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'add-link-category';
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( $action );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !current_user_can( 'manage_categories' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tax = get_taxonomy( 'link_category' );
+ if ( ! current_user_can( $tax->cap->manage_terms ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $names = explode(',', wp_unslash( $_POST['newcat'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $x = new WP_Ajax_Response();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $names as $cat_name ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1703,14 +1704,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tax )
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $tax->cap->edit_terms ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'edit_term', $id ) ) {
+ wp_die( -1 );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
- wp_die( -1 );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $tag = get_term( $id, $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['description'] = $tag->description;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswptermslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-terms-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-terms-list-table.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-admin/includes/class-wp-terms-list-table.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,8 +151,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_bulk_actions() {
</span><span class="cx" style="display: block; padding: 0 10px"> $actions = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $actions['delete'] = __( 'Delete' );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) {
+ $actions['delete'] = __( 'Delete' );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $actions;
</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">@@ -332,11 +335,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function column_cb( $tag ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $default_term = get_option( 'default_' . $this->screen->taxonomy );
-
- if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( current_user_can( 'delete_term', $tag->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>'
</span><span class="cx" style="display: block; padding: 0 10px"> . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return ' ';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,8 +425,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = $this->screen->taxonomy;
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $default_term = get_option( 'default_' . $taxonomy );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $edit_link = add_query_arg(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -434,7 +434,7 @@
</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"> $actions = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( current_user_can( $tax->cap->edit_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( current_user_can( 'edit_term', $tag->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $actions['edit'] = sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<a href="%s" aria-label="%s">%s</a>',
</span><span class="cx" style="display: block; padding: 0 10px"> esc_url( $edit_link ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -449,7 +449,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> __( 'Quick Edit' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( current_user_can( 'delete_term', $tag->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $actions['delete'] = sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',
</span><span class="cx" style="display: block; padding: 0 10px"> wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ),
</span></span></pre></div>
<a id="trunksrcwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/meta-boxes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/meta-boxes.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-admin/includes/meta-boxes.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -434,6 +434,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php elseif ( empty( $terms_to_edit ) ): ?>
+ <p><?php echo $taxonomy->labels->no_terms; ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="tagchecklist"></div>
</span></span></pre></div>
<a id="trunksrcwpadmintermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/term.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/term.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-admin/term.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,11 +31,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $title = $tax->labels->edit_item;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ! current_user_can( $tax->cap->manage_terms )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ! current_user_can( 'edit_term', $tag->term_id )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die(
</span><span class="cx" style="display: block; padding: 0 10px"> '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- '<p>' . __( 'Sorry, you are not allowed to manage this item.' ) . '</p>',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
</ins><span class="cx" style="display: block; padding: 0 10px"> 403
</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="trunksrcwpincludesadminbarphp"></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/admin-bar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/admin-bar.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-includes/admin-bar.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -635,7 +635,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $current_object->taxonomy )
</span><span class="cx" style="display: block; padding: 0 10px"> && ( $tax = get_taxonomy( $current_object->taxonomy ) )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- && current_user_can( $tax->cap->edit_terms )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ && current_user_can( 'edit_term', $current_object->term_id )
</ins><span class="cx" style="display: block; padding: 0 10px"> && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) )
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span></span></pre></div>
<a id="trunksrcwpincludescapabilitiesphp"></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/capabilities.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/capabilities.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-includes/capabilities.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,6 +402,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'delete_site':
</span><span class="cx" style="display: block; padding: 0 10px"> $caps[] = 'manage_options';
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'edit_term':
+ case 'delete_term':
+ case 'assign_term':
+ $term_id = $args[0];
+ $term = get_term( $term_id );
+ if ( ! $term || is_wp_error( $term ) ) {
+ $caps[] = 'do_not_allow';
+ break;
+ }
+
+ $tax = get_taxonomy( $term->taxonomy );
+ if ( ! $tax ) {
+ $caps[] = 'do_not_allow';
+ break;
+ }
+
+ if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
+ $caps[] = 'do_not_allow';
+ break;
+ }
+
+ $taxo_cap = $cap . 's';
+
+ $caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
+
+ break;
+ case 'manage_post_tags':
+ case 'edit_categories':
+ case 'edit_post_tags':
+ case 'delete_categories':
+ case 'delete_post_tags':
+ $caps[] = 'manage_categories';
+ break;
+ case 'assign_categories':
+ case 'assign_post_tags':
+ $caps[] = 'edit_posts';
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'create_sites':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'delete_sites':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'manage_network':
</span></span></pre></div>
<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 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-includes/class-wp-xmlrpc-server.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1886,8 +1886,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $taxonomy->cap->manage_terms ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = (array) $taxonomy;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1973,9 +1974,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $taxonomy->cap->edit_terms ) )
- return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = (array) $taxonomy;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // hold the data of the term
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1989,6 +1987,10 @@
</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( 404, __( 'Invalid term ID.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'edit_term', $term_id ) ) {
+ return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this term.' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $content_struct['name'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $term_data['name'] = trim( $content_struct['name'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2068,10 +2070,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = get_taxonomy( $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( ! current_user_can( $taxonomy->cap->delete_terms ) )
- return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete terms in this taxonomy.' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $term_id, $taxonomy->name );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $term ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2080,6 +2078,10 @@
</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( 404, __( 'Invalid term ID.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'delete_term', $term_id ) ) {
+ return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this term.' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $result = wp_delete_term( $term_id, $taxonomy->name );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2140,9 +2142,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = get_taxonomy( $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
- return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $term_id , $taxonomy->name, ARRAY_A );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $term ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2151,6 +2150,10 @@
</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( 404, __( 'Invalid term ID.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'assign_term', $term_id ) ) {
+ return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign this term.' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->_prepare_term( $term );
</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="trunksrcwpincludeslinktemplatephp"></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/link-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/link-template.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-includes/link-template.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -930,7 +930,7 @@
</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"> $tax = get_taxonomy( $term->taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $tax || ! current_user_can( 'edit_term', $term->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</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">@@ -984,7 +984,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $term->taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( $tax->cap->edit_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</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 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/src/wp-includes/taxonomy.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,6 +61,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_ui' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_admin_column' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> '_builtin' => true,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'capabilities' => array(
+ 'manage_terms' => 'manage_categories',
+ 'edit_terms' => 'edit_categories',
+ 'delete_terms' => 'delete_categories',
+ 'assign_terms' => 'assign_categories',
+ ),
</ins><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"> register_taxonomy( 'post_tag', 'post', array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,6 +77,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_ui' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_admin_column' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> '_builtin' => true,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'capabilities' => array(
+ 'manage_terms' => 'manage_post_tags',
+ 'edit_terms' => 'edit_post_tags',
+ 'delete_terms' => 'delete_post_tags',
+ 'assign_terms' => 'assign_post_tags',
+ ),
</ins><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"> register_taxonomy( 'nav_menu', 'nav_menu_item', array(
</span></span></pre></div>
<a id="trunktestsphpunittestsusercapabilitiesphp"></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/user/capabilities.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/capabilities.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/tests/phpunit/tests/user/capabilities.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -223,6 +223,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'customize' => array( 'administrator' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'delete_site' => array( 'administrator' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'add_users' => array( 'administrator' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ 'edit_categories' => array( 'administrator', 'editor' ),
+ 'delete_categories' => array( 'administrator', 'editor' ),
+ 'manage_post_tags' => array( 'administrator', 'editor' ),
+ 'edit_post_tags' => array( 'administrator', 'editor' ),
+ 'delete_post_tags' => array( 'administrator', 'editor' ),
+
+ 'assign_categories' => array( 'administrator', 'editor', 'author', 'contributor' ),
+ 'assign_post_tags' => array( 'administrator', 'editor', 'author', 'contributor' ),
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,6 +251,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'customize' => array( 'administrator' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'delete_site' => array( 'administrator' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'add_users' => array( 'administrator' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ 'edit_categories' => array( 'administrator', 'editor' ),
+ 'delete_categories' => array( 'administrator', 'editor' ),
+ 'manage_post_tags' => array( 'administrator', 'editor' ),
+ 'edit_post_tags' => array( 'administrator', 'editor' ),
+ 'delete_post_tags' => array( 'administrator', 'editor' ),
+
+ 'assign_categories' => array( 'administrator', 'editor', 'author', 'contributor' ),
+ 'assign_post_tags' => array( 'administrator', 'editor', 'author', 'contributor' ),
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -399,6 +417,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected['delete_post_meta'],
</span><span class="cx" style="display: block; padding: 0 10px"> $expected['add_post_meta'],
</span><span class="cx" style="display: block; padding: 0 10px"> $expected['edit_comment'],
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected['edit_term'],
+ $expected['delete_term'],
+ $expected['assign_term'],
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected['delete_user']
</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">@@ -1078,6 +1099,63 @@
</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">+ /**
+ * @dataProvider dataTaxonomies
+ *
+ * @ticket 35614
+ */
+ public function test_default_taxonomy_term_cannot_be_deleted( $taxonomy ) {
+ if ( ! taxonomy_exists( $taxonomy ) ) {
+ register_taxonomy( $taxonomy, 'post' );
+ }
+
+ $tax = get_taxonomy( $taxonomy );
+ $user = self::$users['administrator'];
+ $term = self::factory()->term->create_and_get( array(
+ 'taxonomy' => $taxonomy,
+ ) );
+
+ update_option( "default_{$taxonomy}", $term->term_id );
+
+ $this->assertTrue( user_can( $user->ID, $tax->cap->delete_terms ) );
+ $this->assertFalse( user_can( $user->ID, 'delete_term', $term->term_id ) );
+ }
+
+ /**
+ * @dataProvider dataTaxonomies
+ *
+ * @ticket 35614
+ */
+ public function test_taxonomy_caps_map_correctly_to_their_meta_cap( $taxonomy ) {
+ if ( ! taxonomy_exists( $taxonomy ) ) {
+ register_taxonomy( $taxonomy, 'post' );
+ }
+
+ $tax = get_taxonomy( $taxonomy );
+ $term = self::factory()->term->create_and_get( array(
+ 'taxonomy' => $taxonomy,
+ ) );
+
+ foreach ( self::$users as $role => $user ) {
+ $this->assertSame(
+ user_can( $user->ID, 'edit_term', $term->term_id ),
+ user_can( $user->ID, $tax->cap->edit_terms ),
+ "Role: {$role}"
+ );
+ $this->assertSame(
+ user_can( $user->ID, 'delete_term', $term->term_id ),
+ user_can( $user->ID, $tax->cap->delete_terms ),
+ "Role: {$role}"
+ );
+ $this->assertSame(
+ user_can( $user->ID, 'assign_term', $term->term_id ),
+ user_can( $user->ID, $tax->cap->assign_terms ),
+ "Role: {$role}"
+ );
+ }
+
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function dataTaxonomies() {
</span><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpdeleteTermphp"></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/deleteTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,7 +43,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( __( 'Sorry, you are not allowed to delete terms in this taxonomy.' ), $result->message );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message );
</ins><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"> function test_empty_term() {
</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 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,7 +49,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'category' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), $result->message );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message );
</ins><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"> function test_term_not_exists() {
</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 2016-09-30 22:11:47 UTC (rev 38697)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php 2016-09-30 22:39:32 UTC (rev 38698)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,7 +43,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message );
</ins><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></span></pre>
</div>
</div>
</body>
</html>