Changeset 35515 for trunk/src/wp-includes/taxonomy-functions.php
- Timestamp:
- 11/04/2015 09:23:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r35504 r35515 1579 1579 * @param bool $unique Optional. Whether to bail if an entry with the same key is found for the term. 1580 1580 * Default false. 1581 * @return int|bool Meta ID on success, false on failure. 1581 * @return int|WP_Error|bool Meta ID on success. WP_Error when term_id is ambiguous between taxonomies. 1582 * False on failure. 1582 1583 */ 1583 1584 function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { … … 1585 1586 if ( get_option( 'db_version' ) < 34370 ) { 1586 1587 return false; 1588 } 1589 1590 if ( wp_term_is_shared( $term_id ) ) { 1591 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); 1587 1592 } 1588 1593 … … 1656 1661 * @param mixed $meta_value Metadata value. 1657 1662 * @param mixed $prev_value Optional. Previous value to check before removing. 1658 * @return int|bool Meta ID if the key didn't previously exist. True on successful update. False on failure. 1663 * @return int|WP_Error|bool Meta ID if the key didn't previously exist. True on successful update. 1664 * WP_Error when term_id is ambiguous between taxonomies. False on failure. 1659 1665 */ 1660 1666 function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { … … 1662 1668 if ( get_option( 'db_version' ) < 34370 ) { 1663 1669 return false; 1670 } 1671 1672 if ( wp_term_is_shared( $term_id ) ) { 1673 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); 1664 1674 } 1665 1675 … … 4008 4018 } 4009 4019 4020 // If we've just split the final shared term, set the "finished" flag. 4021 $shared_terms_exist = $wpdb->get_results( 4022 "SELECT tt.term_id, t.*, count(*) as term_tt_count FROM {$wpdb->term_taxonomy} tt 4023 LEFT JOIN {$wpdb->terms} t ON t.term_id = tt.term_id 4024 GROUP BY t.term_id 4025 HAVING term_tt_count > 1 4026 LIMIT 1" 4027 ); 4028 if ( ! $shared_terms_exist ) { 4029 update_option( 'finished_splitting_shared_terms', true ); 4030 } 4031 4010 4032 /** 4011 4033 * Fires after a previously shared taxonomy term is split into two separate terms. … … 4253 4275 4254 4276 return $term_id; 4277 } 4278 4279 /** 4280 * Determine whether a term is shared between multiple taxonomies. 4281 * 4282 * Shared taxonomy terms began to be split in 4.3, but failed cron tasks or other delays in upgrade routines may cause 4283 * shared terms to remain. 4284 * 4285 * @since 4.4.0 4286 * 4287 * @param int $term_id 4288 * @return bool 4289 */ 4290 function wp_term_is_shared( $term_id ) { 4291 global $wpdb; 4292 4293 if ( get_option( 'finished_splitting_shared_terms' ) ) { 4294 return false; 4295 } 4296 4297 $tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) ); 4298 4299 return $tt_count > 1; 4255 4300 } 4256 4301
Note: See TracChangeset
for help on using the changeset viewer.