Make WordPress Core


Ignore:
Timestamp:
10/09/2014 02:48:47 AM (11 years ago)
Author:
boonebgorges
Message:

Fix term_exists() for parent = 0.

Passing a 0 (or '0') as the 'parent' param of term_exists() should limit
results to terms with no parent.

Adds unit test.

Fixes #29851.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r29862 r29863  
    16561656 * @param int|string $term The term to check
    16571657 * @param string $taxonomy The taxonomy name to use
    1658  * @param int $parent ID of parent term under which to confine the exists search.
     1658 * @param int $parent Optional. ID of parent term under which to confine the exists search.
    16591659 * @return mixed Returns 0 if the term does not exist. Returns the term ID if no taxonomy is specified
    16601660 *               and the term ID exists. Returns an array of the term ID and the term taxonomy ID
    16611661 *               if the taxonomy is specified and the pairing exists.
    16621662 */
    1663 function term_exists($term, $taxonomy = '', $parent = 0) {
     1663function term_exists( $term, $taxonomy = '', $parent = null ) {
    16641664    global $wpdb;
    16651665
     
    16871687    $else_where_fields = array($term);
    16881688    if ( !empty($taxonomy) ) {
    1689         $parent = (int) $parent;
    1690         if ( $parent > 0 ) {
     1689        if ( is_numeric( $parent ) ) {
     1690            $parent = (int) $parent;
    16911691            $where_fields[] = $parent;
    16921692            $else_where_fields[] = $parent;
Note: See TracChangeset for help on using the changeset viewer.