IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
2528 | 2528 | * Update term based on arguments provided. |
2529 | 2529 | * |
2530 | 2530 | * 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). |
2533 | 2531 | * |
| 2532 | * To overcome possible data corruption 'term_id' will be removed from $args. |
| 2533 | * |
2534 | 2534 | * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not |
2535 | 2535 | * defined in $args already. |
2536 | 2536 | * |
… |
… |
|
2542 | 2542 | * a WP_Error will be passed back. If you don't pass any slug, then a unique one |
2543 | 2543 | * will be created for you. |
2544 | 2544 | * |
2545 | | * For what can be overrode in `$args`, check the term scheme can contain and stay |
2546 | | * away from the term keys. |
2547 | | * |
2548 | 2545 | * @since 2.3.0 |
2549 | 2546 | * |
2550 | 2547 | * @global wpdb $wpdb WordPress database abstraction object. |
2551 | 2548 | * |
2552 | 2549 | * @param int $term_id The ID of the term |
2553 | 2550 | * @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. |
2555 | 2552 | * @return array|WP_Error Returns Term ID and Taxonomy Term ID |
2556 | 2553 | */ |
2557 | 2554 | function wp_update_term( $term_id, $taxonomy, $args = array() ) { |
… |
… |
|
2578 | 2575 | |
2579 | 2576 | // Escape data pulled from DB. |
2580 | 2577 | $term = wp_slash( $term ); |
| 2578 | |
| 2579 | // Unsetting 'term_id' to overcome possible data corruption. |
| 2580 | unset( $args['term_id'] ); |
2581 | 2581 | |
2582 | 2582 | // Merge old and new args with new args overwriting old ones. |
2583 | | $args = array_merge($term, $args); |
| 2583 | $args = array_merge( $term, $args ); |
2584 | 2584 | |
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' ); |
2588 | 2588 | $parsed_args = $args; |
2589 | 2589 | |
2590 | 2590 | // expected_slashed ($name) |
… |
… |
|
2692 | 2692 | $data = apply_filters( 'wp_update_term_data', $data, $term_id, $taxonomy, $args ); |
2693 | 2693 | |
2694 | 2694 | $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 ); |
2697 | 2697 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
2698 | 2698 | } |
2699 | 2699 | |