Changeset 29862 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 10/09/2014 02:31:35 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r29859 r29862 2449 2449 $term_group = 0; 2450 2450 if ( $args['alias_of'] ) { 2451 $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $args['alias_of'] ));2452 if ( $alias->term_group) {2451 $alias = get_term_by( 'slug', $args['alias_of'], $taxonomy ); 2452 if ( ! empty( $alias->term_group ) ) { 2453 2453 // The alias we want is already in a group, so let's use that one. 2454 2454 $term_group = $alias->term_group; 2455 } else { 2456 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 2455 } else if ( ! empty( $alias->term_id ) ) { 2456 /* 2457 * The alias is not in a group, so we create a new one 2458 * and add the alias to it. 2459 */ 2457 2460 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 2458 2461 2459 /** 2460 * Fires immediately before the given terms are edited. 2461 * 2462 * @since 2.9.0 2463 * 2464 * @param int $term_id Term ID. 2465 * @param string $taxonomy Taxonomy slug. 2466 */ 2467 do_action( 'edit_terms', $alias->term_id, $taxonomy ); 2468 $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); 2469 2470 /** 2471 * Fires immediately after the given terms are edited. 2472 * 2473 * @since 2.9.0 2474 * 2475 * @param int $term_id Term ID 2476 * @param string $taxonomy Taxonomy slug. 2477 */ 2478 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2462 wp_update_term( $alias->term_id, $taxonomy, array( 2463 'term_group' => $term_group, 2464 ) ); 2479 2465 } 2480 2466 } … … 2961 2947 $term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0; 2962 2948 if ( $args['alias_of'] ) { 2963 $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $args['alias_of'] ));2964 if ( $alias->term_group) {2949 $alias = get_term_by( 'slug', $args['alias_of'], $taxonomy ); 2950 if ( ! empty( $alias->term_group ) ) { 2965 2951 // The alias we want is already in a group, so let's use that one. 2966 2952 $term_group = $alias->term_group; 2967 } else { 2968 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 2953 } else if ( ! empty( $alias->term_id ) ) { 2954 /* 2955 * The alias is not in a group, so we create a new one 2956 * and add the alias to it. 2957 */ 2969 2958 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 2970 2959 2971 /** This action is documented in wp-includes/taxonomy.php */ 2972 do_action( 'edit_terms', $alias->term_id, $taxonomy ); 2973 $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); 2974 2975 /** This action is documented in wp-includes/taxonomy.php */ 2976 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2960 wp_update_term( $alias->term_id, $taxonomy, array( 2961 'term_group' => $term_group, 2962 ) ); 2977 2963 } 2978 2964 … … 3006 2992 } 3007 2993 3008 /** This action is documented in wp-includes/taxonomy.php */ 2994 /** 2995 * Fires immediately before the given terms are edited. 2996 * 2997 * @since 2.9.0 2998 * 2999 * @param int $term_id Term ID. 3000 * @param string $taxonomy Taxonomy slug. 3001 */ 3009 3002 do_action( 'edit_terms', $term_id, $taxonomy ); 3010 3003 $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); … … 3014 3007 } 3015 3008 3016 /** This action is documented in wp-includes/taxonomy.php */ 3009 /** 3010 * Fires immediately after the given terms are edited. 3011 * 3012 * @since 2.9.0 3013 * 3014 * @param int $term_id Term ID 3015 * @param string $taxonomy Taxonomy slug. 3016 */ 3017 3017 do_action( 'edited_terms', $term_id, $taxonomy ); 3018 3018
Note: See TracChangeset
for help on using the changeset viewer.