<!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>[48840] trunk: Taxonomy: Allow for `wp_count_terms( $args )` signature, making passing a taxonomy optional.</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 { white-space: pre-line; 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/48840">48840</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/48840","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-08-21 22:30:06 +0000 (Fri, 21 Aug 2020)</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: Allow for `wp_count_terms( $args )` signature, making passing a taxonomy optional.

This brings `wp_count_terms()` in line with other taxonomy functions such as `get_terms()` which technically no longer require a taxonomy. Similar to the previously modified functions, no deprecation warning is triggered when using the legacy signature.

Fixes <a href="https://core.trac.wordpress.org/ticket/36399">#36399</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswptermslisttablephp">trunk/src/wp-admin/includes/class-wp-terms-list-table.php</a></li>
<li><a href="#trunksrcwpadminincludesnavmenuphp">trunk/src/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswpresttermscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php</a></li>
<li><a href="#trunksrcwpincludessitemapsprovidersclasswpsitemapstaxonomiesphp">trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php</a></li>
<li><a href="#trunksrcwpincludestaxonomyphp">trunk/src/wp-includes/taxonomy.php</a></li>
<li><a href="#trunktestsphpunittestsimportimportphp">trunk/tests/phpunit/tests/import/import.php</a></li>
<li><a href="#trunktestsphpunitteststermwpInsertTermphp">trunk/tests/phpunit/tests/term/wpInsertTerm.php</a></li>
<li><a href="#trunktestsphpunitteststermphp">trunk/tests/phpunit/tests/term.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<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 2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/src/wp-admin/includes/class-wp-terms-list-table.php   2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,7 +129,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->set_pagination_args(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'total_items' => wp_count_terms(
+                                       array(
+                                               'taxonomy' => $this->screen->taxonomy,
+                                               'search'   => $search,
+                                       )
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'per_page'    => $tags_per_page,
</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="trunksrcwpadminincludesnavmenuphp"></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/nav-menu.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/nav-menu.php  2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/src/wp-admin/includes/nav-menu.php    2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -725,7 +725,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $num_pages = ceil(
</span><span class="cx" style="display: block; padding: 0 10px">                wp_count_terms(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $taxonomy_name,
</del><span class="cx" style="display: block; padding: 0 10px">                         array_merge(
</span><span class="cx" style="display: block; padding: 0 10px">                                $args,
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswpresttermscontrollerphp"></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/rest-api/endpoints/class-wp-rest-terms-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php       2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php 2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,7 +263,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                unset( $count_args['number'], $count_args['offset'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $total_terms = wp_count_terms( $this->taxonomy, $count_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $total_terms = wp_count_terms( $count_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // wp_count_terms() can return a falsey value when the term has no children.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! $total_terms ) {
</span></span></pre></div>
<a id="trunksrcwpincludessitemapsprovidersclasswpsitemapstaxonomiesphp"></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/sitemaps/providers/class-wp-sitemaps-taxonomies.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php 2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php   2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,7 +150,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return $max_num_pages;
</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">-                $term_count = wp_count_terms( $taxonomy, $this->get_taxonomies_query_args( $taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
</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        2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/src/wp-includes/taxonomy.php  2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1730,19 +1730,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true).
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.3.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.6.0 Changed the function signature so that the `$args` array can be provided as the first parameter.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string       $taxonomy Taxonomy name.
- * @param array|string $args     Optional. Array of arguments that get passed to get_terms().
- *                               Default empty array.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array|string $args       Optional. Array of arguments that get passed to get_terms().
+ *                                 Default empty array.
+ * @param array|string $deprecated Taxonomy name.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wp_count_terms( $taxonomy, $args = array() ) {
-       $defaults = array(
-               'taxonomy'   => $taxonomy,
-               'hide_empty' => false,
-       );
-       $args     = wp_parse_args( $args, $defaults );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_count_terms( $args = array(), $deprecated = array() ) {
+       // Check whether function is used with legacy signature `$taxonomy` and `$args`.
+       $use_legacy_args = $args && ( is_string( $args ) && taxonomy_exists( $args ) || is_array( $args ) && wp_is_numeric_array( $args ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $defaults = array( 'hide_empty' => false );
+       if ( $use_legacy_args ) {
+               $defaults['taxonomy'] = $args;
+               $args                 = $deprecated;
+       }
+
+       $args = wp_parse_args( $args, $defaults );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         // Backward compatibility.
</span><span class="cx" style="display: block; padding: 0 10px">        if ( isset( $args['ignore_empty'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $args['hide_empty'] = $args['ignore_empty'];
</span></span></pre></div>
<a id="trunktestsphpunittestsimportimportphp"></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/import/import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/import/import.php       2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/tests/phpunit/tests/import/import.php 2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -65,8 +65,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'author@example.org', $author->user_email );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Check that terms were imported correctly.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 30, wp_count_terms( 'category' ) );
-               $this->assertEquals( 3, wp_count_terms( 'post_tag' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( 30, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
+               $this->assertEquals( 3, wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $foo = get_term_by( 'slug', 'foo', 'category' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 0, $foo->parent );
</span><span class="cx" style="display: block; padding: 0 10px">                $bar     = get_term_by( 'slug', 'bar', 'category' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,8 +230,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'author', $author->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'author@example.org', $author->user_email );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 30, wp_count_terms( 'category' ) );
-               $this->assertEquals( 3, wp_count_terms( 'post_tag' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( 30, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
+               $this->assertEquals( 3, wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $foo = get_term_by( 'slug', 'foo', 'category' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 0, $foo->parent );
</span><span class="cx" style="display: block; padding: 0 10px">                $bar     = get_term_by( 'slug', 'bar', 'category' );
</span></span></pre></div>
<a id="trunktestsphpunitteststermwpInsertTermphp"></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/wpInsertTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/wpInsertTerm.php   2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/tests/phpunit/tests/term/wpInsertTerm.php     2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,7 +24,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $term = 'term';
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( term_exists( $term ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $initial_count = wp_count_terms( $taxonomy );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $initial_count = wp_count_terms( array( 'taxonomy' => $taxonomy ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $t = wp_insert_term( $term, $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertInternalType( 'array', $t );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,7 +31,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotWPError( $t );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $t['term_id'] > 0 );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $t['term_taxonomy_id'] > 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $initial_count + 1, wp_count_terms( $taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => $taxonomy ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Make sure the term exists.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( term_exists( $term ) > 0 );
</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">                remove_filter( 'delete_term', array( $this, 'deleted_term_cb' ), 10, 5 );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( term_exists( $term ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( term_exists( $t['term_id'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $initial_count, wp_count_terms( $taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $initial_count, wp_count_terms( array( 'taxonomy' => $taxonomy ) ) );
</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">        public function test_wp_insert_term_taxonomy_does_not_exist() {
</span></span></pre></div>
<a id="trunktestsphpunitteststermphp"></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.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term.php        2020-08-21 21:49:02 UTC (rev 48839)
+++ trunk/tests/phpunit/tests/term.php  2020-08-21 22:30:06 UTC (rev 48840)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -65,12 +65,35 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 15919
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        function test_wp_count_terms() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $count = wp_count_terms( 'category', array( 'hide_empty' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $count = wp_count_terms(
+                       array(
+                               'hide_empty' => true,
+                               'taxonomy'   => 'category',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">                 // There are 5 posts, all Uncategorized.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 1, $count );
</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">+         * @ticket 36399
+        */
+       function test_wp_count_terms_legacy_interoperability() {
+               self::factory()->tag->create_many( 5 );
+
+               // Counts all terms (1 default category, 5 tags).
+               $count = wp_count_terms();
+               $this->assertEquals( 6, $count );
+
+               // Counts only tags (5), with both current and legacy signature.
+               // Legacy usage should not trigger deprecated notice.
+               $count        = wp_count_terms( array( 'taxonomy' => 'post_tag' ) );
+               $legacy_count = wp_count_terms( 'post_tag' );
+               $this->assertEquals( 5, $count );
+               $this->assertEquals( $count, $legacy_count );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @ticket 15475
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        function test_wp_add_remove_object_terms() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,13 +150,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $term = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( category_exists( $term ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $initial_count = wp_count_terms( 'category' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $initial_count = wp_count_terms( array( 'taxonomy' => 'category' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $t = wp_insert_category( array( 'cat_name' => $term ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( is_numeric( $t ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotWPError( $t );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $t > 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $initial_count + 1, wp_count_terms( 'category' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Make sure the term exists.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( term_exists( $term ) > 0 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,7 +166,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( wp_delete_category( $t ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( term_exists( $term ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( term_exists( $t ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $initial_count, wp_count_terms( 'category' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $initial_count, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
</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>