Make WordPress Core


Ignore:
Timestamp:
07/24/2020 12:17:54 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Correct documentation for wp_insert_term().

The function is used for adding a new term, not updating an existing one.

Props audrasjb, bmartinent.
Fixes #50753.

File:
1 edited

Legend:

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

    r48599 r48600  
    21592159 * @since 2.3.0
    21602160 *
    2161  * @param string       $term     The term name to add or update.
     2161 * @param string       $term     The term name to add.
    21622162 * @param string       $taxonomy The taxonomy to which to add the term.
    21632163 * @param array|string $args {
     
    21852185     * @since 3.0.0
    21862186     *
    2187      * @param string|WP_Error $term     The term name to add or update, or a WP_Error object if there's an error.
     2187     * @param string|WP_Error $term     The term name to add, or a WP_Error object if there's an error.
    21882188     * @param string          $taxonomy Taxonomy slug.
    21892189     */
    21902190    $term = apply_filters( 'pre_insert_term', $term, $taxonomy );
     2191
    21912192    if ( is_wp_error( $term ) ) {
    21922193        return $term;
    21932194    }
     2195
    21942196    if ( is_int( $term ) && 0 === $term ) {
    21952197        return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) );
    21962198    }
     2199
    21972200    if ( '' === trim( $term ) ) {
    21982201        return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
    21992202    }
     2203
    22002204    $defaults = array(
    22012205        'alias_of'    => '',
Note: See TracChangeset for help on using the changeset viewer.