Changeset 32813 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 06/17/2015 01:47:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r32709 r32813 4189 4189 * @ignore 4190 4190 * @since 4.2.0 4191 * @since 4.3.0 Introduced `$record` parameter. `$term_id` and `$term_taxonomy_id` can now accept objects. 4191 4192 * 4192 4193 * @global wpdb $wpdb 4193 4194 * 4194 * @param int $term_id ID of the shared term. 4195 * @param int $term_taxonomy_id ID of the term_taxonomy item to receive a new term. 4195 * @param int|object $term_id ID of the shared term, or the shared term object. 4196 * @param int|object $term_taxonomy_id ID of the term_taxonomy item to receive a new term, or the term_taxonomy object 4197 * (corresponding to a row from the term_taxonomy table). 4198 * @param bool $record Whether to record data about the split term in the options table. The recording 4199 * process has the potential to be resource-intensive, so during batch operations 4200 * it can be beneficial to skip inline recording and do it just once, after the 4201 * batch is processed. Only set this to `false` if you know what you are doing. 4202 * Default: true. 4196 4203 * @return int|WP_Error When the current term does not need to be split (or cannot be split on the current 4197 4204 * database schema), `$term_id` is returned. When the term is successfully split, the 4198 4205 * new term_id is returned. A WP_Error is returned for miscellaneous errors. 4199 4206 */ 4200 function _split_shared_term( $term_id, $term_taxonomy_id ) {4207 function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) { 4201 4208 global $wpdb; 4209 4210 if ( is_object( $term_id ) ) { 4211 $shared_term = $term_id; 4212 $term_id = intval( $shared_term->term_id ); 4213 } 4214 4215 if ( is_object( $term_taxonomy_id ) ) { 4216 $term_taxonomy = $term_taxonomy_id; 4217 $term_taxonomy_id = intval( $term_taxonomy->term_taxonomy_id ); 4218 } 4202 4219 4203 4220 // Don't try to split terms if database schema does not support shared slugs. … … 4209 4226 // If there are no shared term_taxonomy rows, there's nothing to do here. 4210 4227 $shared_tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id ) ); 4228 4211 4229 if ( ! $shared_tt_count ) { 4212 4230 return $term_id; … … 4214 4232 4215 4233 // Pull up data about the currently shared slug, which we'll use to populate the new one. 4216 $shared_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id ) ); 4234 if ( empty( $shared_term ) ) { 4235 $shared_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id ) ); 4236 } 4217 4237 4218 4238 $new_term_data = array( … … 4235 4255 4236 4256 // Reassign child terms to the new parent. 4237 $term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); 4238 $children_tt_ids = $wpdb->get_col( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = %s AND parent = %d", $term_taxonomy->taxonomy, $term_id ) ); 4239 4257 if ( empty( $term_taxonomy ) ) { 4258 $term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); 4259 } 4260 4261 $children_tt_ids = $wpdb->get_col( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = %s", $term_id, $term_taxonomy->taxonomy ) ); 4240 4262 if ( ! empty( $children_tt_ids ) ) { 4241 4263 foreach ( $children_tt_ids as $child_tt_id ) { … … 4260 4282 4261 4283 // Keep a record of term_ids that have been split, keyed by old term_id. See {@see wp_get_split_term()}. 4262 $split_term_data = get_option( '_split_terms', array() ); 4263 if ( ! isset( $split_term_data[ $term_id ] ) ) { 4264 $split_term_data[ $term_id ] = array(); 4265 } 4266 4267 $split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id; 4268 4269 update_option( '_split_terms', $split_term_data ); 4284 if ( $record ) { 4285 $split_term_data = get_option( '_split_terms', array() ); 4286 if ( ! isset( $split_term_data[ $term_id ] ) ) { 4287 $split_term_data[ $term_id ] = array(); 4288 } 4289 4290 $split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id; 4291 update_option( '_split_terms', $split_term_data ); 4292 } 4270 4293 4271 4294 /**
Note: See TracChangeset
for help on using the changeset viewer.