Changeset 15220 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 06/11/2010 03:53:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r15190 r15220 143 143 * 144 144 * @uses $wp_taxonomies 145 * @uses is_taxonomy() Checks whether taxonomy exists145 * @uses taxonomy_exists() Checks whether taxonomy exists 146 146 * 147 147 * @param string $taxonomy Name of taxonomy object to return … … 151 151 global $wp_taxonomies; 152 152 153 if ( ! is_taxonomy($taxonomy) )153 if ( ! taxonomy_exists( $taxonomy ) ) 154 154 return false; 155 155 … … 160 160 * Checks that the taxonomy name exists. 161 161 * 162 * @package WordPress 163 * @subpackage Taxonomy 164 * @since 2.3.0 162 * Formerly is_taxonomy(), introduced in 2.3.0. 163 * 164 * @package WordPress 165 * @subpackage Taxonomy 166 * @since 3.0.0 165 167 * 166 168 * @uses $wp_taxonomies … … 169 171 * @return bool Whether the taxonomy exists. 170 172 */ 171 function is_taxonomy( $taxonomy ) {173 function taxonomy_exists( $taxonomy ) { 172 174 global $wp_taxonomies; 173 175 174 return isset( $wp_taxonomies[$taxonomy]);176 return isset( $wp_taxonomies[$taxonomy] ); 175 177 } 176 178 … … 187 189 * @since 2.3.0 188 190 * 189 * @uses is_taxonomy() Checks whether taxonomy exists191 * @uses taxonomy_exists() Checks whether taxonomy exists 190 192 * @uses get_taxonomy() Used to get the taxonomy object 191 193 * … … 194 196 */ 195 197 function is_taxonomy_hierarchical($taxonomy) { 196 if ( ! is_taxonomy($taxonomy) )198 if ( ! taxonomy_exists($taxonomy) ) 197 199 return false; 198 200 … … 209 211 * the object type. 210 212 * 211 * Nothing is returned, so expect error maybe or use is_taxonomy() to check213 * Nothing is returned, so expect error maybe or use taxonomy_exists() to check 212 214 * whether taxonomy exists. 213 215 * … … 438 440 439 441 foreach ( (array) $taxonomies as $taxonomy ) { 440 if ( ! is_taxonomy( $taxonomy ) )442 if ( ! taxonomy_exists( $taxonomy ) ) 441 443 return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) ); 442 444 } … … 510 512 } 511 513 512 if ( ! is_taxonomy($taxonomy) ) {514 if ( ! taxonomy_exists($taxonomy) ) { 513 515 $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 514 516 return $error; … … 577 579 global $wpdb; 578 580 579 if ( ! is_taxonomy($taxonomy) )581 if ( ! taxonomy_exists($taxonomy) ) 580 582 return false; 581 583 … … 635 637 */ 636 638 function get_term_children( $term_id, $taxonomy ) { 637 if ( ! is_taxonomy($taxonomy) )639 if ( ! taxonomy_exists($taxonomy) ) 638 640 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 639 641 … … 820 822 821 823 foreach ( (array) $taxonomies as $taxonomy ) { 822 if ( ! is_taxonomy($taxonomy) ) {824 if ( ! taxonomy_exists($taxonomy) ) { 823 825 $error = & new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 824 826 return $error; … … 1072 1074 * Returns the index of a defined term, or 0 (false) if the term doesn't exist. 1073 1075 * 1074 * @package WordPress 1075 * @subpackage Taxonomy 1076 * @since 2.3.0 1076 * Formerly is_term(), introduced in 2.3.0. 1077 * 1078 * @package WordPress 1079 * @subpackage Taxonomy 1080 * @since 3.0.0 1077 1081 * 1078 1082 * @uses $wpdb … … 1083 1087 * @return mixed Get the term id or Term Object, if exists. 1084 1088 */ 1085 function is_term($term, $taxonomy = '', $parent = 0) {1089 function term_exists($term, $taxonomy = '', $parent = 0) { 1086 1090 global $wpdb; 1087 1091 … … 1344 1348 $term = (int) $term; 1345 1349 1346 if ( ! $ids = is_term($term, $taxonomy) )1350 if ( ! $ids = term_exists($term, $taxonomy) ) 1347 1351 return false; 1348 1352 if ( is_wp_error( $ids ) ) … … 1357 1361 if ( isset($default) ) { 1358 1362 $default = (int) $default; 1359 if ( ! is_term($default, $taxonomy) )1363 if ( ! term_exists($default, $taxonomy) ) 1360 1364 unset($default); 1361 1365 } … … 1444 1448 1445 1449 foreach ( (array) $taxonomies as $taxonomy ) { 1446 if ( ! is_taxonomy($taxonomy) )1450 if ( ! taxonomy_exists($taxonomy) ) 1447 1451 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 1448 1452 } … … 1582 1586 global $wpdb; 1583 1587 1584 if ( ! is_taxonomy($taxonomy) )1588 if ( ! taxonomy_exists($taxonomy) ) 1585 1589 return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); 1586 1590 … … 1624 1628 } 1625 1629 1626 if ( $term_id = is_term($slug) ) {1630 if ( $term_id = term_exists($slug) ) { 1627 1631 $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); 1628 1632 // We've got an existing term in the same taxonomy, which matches the name of the new term: 1629 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && is_term( (int) $term_id, $taxonomy ) ) {1633 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && term_exists( (int) $term_id, $taxonomy ) ) { 1630 1634 // Hierarchical, and it matches an existing term, Do not allow same "name" in the same level. 1631 1635 $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) ); … … 1644 1648 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1645 1649 $term_id = (int) $wpdb->insert_id; 1646 } elseif ( is_term( (int) $term_id, $taxonomy ) ) {1650 } elseif ( term_exists( (int) $term_id, $taxonomy ) ) { 1647 1651 // Same name, same slug. 1648 1652 return new WP_Error('term_exists', __('A term with the name provided already exists.')); … … 1713 1717 $object_id = (int) $object_id; 1714 1718 1715 if ( ! is_taxonomy($taxonomy) )1719 if ( ! taxonomy_exists($taxonomy) ) 1716 1720 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 1717 1721 … … 1731 1735 continue; 1732 1736 1733 if ( !$term_info = is_term($term, $taxonomy) ) {1737 if ( !$term_info = term_exists($term, $taxonomy) ) { 1734 1738 // Skip if a non-existent term ID is passed. 1735 1739 if ( is_int($term) ) … … 1806 1810 global $wpdb; 1807 1811 1808 if ( ! is_term( $slug ) )1812 if ( ! term_exists( $slug ) ) 1809 1813 return $slug; 1810 1814 … … 1818 1822 break; 1819 1823 $slug .= '-' . $parent_term->slug; 1820 if ( ! is_term( $slug ) )1824 if ( ! term_exists( $slug ) ) 1821 1825 return $slug; 1822 1826 … … 1884 1888 global $wpdb; 1885 1889 1886 if ( ! is_taxonomy($taxonomy) )1890 if ( ! taxonomy_exists($taxonomy) ) 1887 1891 return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); 1888 1892
Note: See TracChangeset
for help on using the changeset viewer.