Make WordPress Core

Ticket #38310: 38310-2.patch

File 38310-2.patch, 2.7 KB (added by ruud@…, 8 years ago)
  • wp-includes/taxonomy.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    25282528 * Update term based on arguments provided.
    25292529 *
    25302530 * The $args will indiscriminately override all values with the same field name.
    2531  * Care must be taken to not override important information need to update or
    2532  * update will fail (or perhaps create a new term, neither would be acceptable).
    25332531 *
     2532 * To overcome possible data corruption 'term_id' will be removed from $args.
     2533 *
    25342534 * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
    25352535 * defined in $args already.
    25362536 *
     
    25422542 * a WP_Error will be passed back. If you don't pass any slug, then a unique one
    25432543 * will be created for you.
    25442544 *
    2545  * For what can be overrode in `$args`, check the term scheme can contain and stay
    2546  * away from the term keys.
    2547  *
    25482545 * @since 2.3.0
    25492546 *
    25502547 * @global wpdb $wpdb WordPress database abstraction object.
    25512548 *
    25522549 * @param int          $term_id  The ID of the term
    25532550 * @param string       $taxonomy The context in which to relate the term to the object.
    2554  * @param array|string $args     Optional. Array of get_terms() arguments. Default empty array.
     2551 * @param array|string $args     Optional. Array of term data to be merged with term. Default empty array.
    25552552 * @return array|WP_Error Returns Term ID and Taxonomy Term ID
    25562553 */
    25572554function wp_update_term( $term_id, $taxonomy, $args = array() ) {
     
    25782575
    25792576        // Escape data pulled from DB.
    25802577        $term = wp_slash( $term );
     2578
     2579        // Unsetting 'term_id' to overcome possible data corruption.
     2580        unset( $args['term_id'] );
    25812581
    25822582        // Merge old and new args with new args overwriting old ones.
    2583         $args = array_merge($term, $args);
     2583        $args = array_merge( $term, $args );
    25842584
    2585         $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
    2586         $args = wp_parse_args($args, $defaults);
    2587         $args = sanitize_term($args, $taxonomy, 'db');
     2585        $defaults    = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '' );
     2586        $args        = wp_parse_args( $args, $defaults );
     2587        $args        = sanitize_term( $args, $taxonomy, 'db' );
    25882588        $parsed_args = $args;
    25892589
    25902590        // expected_slashed ($name)
     
    26922692        $data = apply_filters( 'wp_update_term_data', $data, $term_id, $taxonomy, $args );
    26932693
    26942694        $wpdb->update( $wpdb->terms, $data, compact( 'term_id' ) );
    2695         if ( empty($slug) ) {
    2696                 $slug = sanitize_title($name, $term_id);
     2695        if ( empty( $slug ) ) {
     2696                $slug = sanitize_title( $name, $term_id );
    26972697                $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
    26982698        }
    26992699