Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r15220 r14934  
    4646        'show_ui' => false,
    4747        '_builtin' => true,
    48         'show_in_nav_menus' => false,
    4948    ) ) ;
    5049
     
    143142 *
    144143 * @uses $wp_taxonomies
    145  * @uses taxonomy_exists() Checks whether taxonomy exists
     144 * @uses is_taxonomy() Checks whether taxonomy exists
    146145 *
    147146 * @param string $taxonomy Name of taxonomy object to return
     
    151150    global $wp_taxonomies;
    152151
    153     if ( ! taxonomy_exists( $taxonomy ) )
     152    if ( ! is_taxonomy($taxonomy) )
    154153        return false;
    155154
     
    160159 * Checks that the taxonomy name exists.
    161160 *
    162  * Formerly is_taxonomy(), introduced in 2.3.0.
    163  *
    164  * @package WordPress
    165  * @subpackage Taxonomy
    166  * @since 3.0.0
     161 * @package WordPress
     162 * @subpackage Taxonomy
     163 * @since 2.3.0
    167164 *
    168165 * @uses $wp_taxonomies
     
    171168 * @return bool Whether the taxonomy exists.
    172169 */
    173 function taxonomy_exists( $taxonomy ) {
     170function is_taxonomy( $taxonomy ) {
    174171    global $wp_taxonomies;
    175172
    176     return isset( $wp_taxonomies[$taxonomy] );
     173    return isset($wp_taxonomies[$taxonomy]);
    177174}
    178175
     
    189186 * @since 2.3.0
    190187 *
    191  * @uses taxonomy_exists() Checks whether taxonomy exists
     188 * @uses is_taxonomy() Checks whether taxonomy exists
    192189 * @uses get_taxonomy() Used to get the taxonomy object
    193190 *
     
    196193 */
    197194function is_taxonomy_hierarchical($taxonomy) {
    198     if ( ! taxonomy_exists($taxonomy) )
     195    if ( ! is_taxonomy($taxonomy) )
    199196        return false;
    200197
     
    211208 * the object type.
    212209 *
    213  * Nothing is returned, so expect error maybe or use taxonomy_exists() to check
     210 * Nothing is returned, so expect error maybe or use is_taxonomy() to check
    214211 * whether taxonomy exists.
    215212 *
     
    235232 * show_ui - If the WordPress UI admin tags UI should apply to this taxonomy;
    236233 * defaults to public.
    237  *
    238  * show_in_nav_menus - true makes this taxonomy available for selection in navigation menus.
    239  * Defaults to public.
    240234 *
    241235 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
     
    271265                        'labels' => array(),
    272266                        'capabilities' => array(),
    273                         'show_in_nav_menus' => null,
    274267                    );
    275268    $args = wp_parse_args($args, $defaults);
     
    293286    if ( is_null($args['show_ui']) )
    294287        $args['show_ui'] = $args['public'];
    295 
    296     // Whether to show this type in nav-menus.php. Defaults to the setting for public.
    297     if ( null === $args['show_in_nav_menus'] )
    298         $args['show_in_nav_menus'] = $args['public'];
    299288
    300289    if ( is_null($args['show_tagcloud']) )
     
    329318 * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category
    330319 * - search_items - Default is Search Tags/Search Categories
    331  * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
     320 * - popular_items - Default is Popular Tags/Popular Categories
    332321 * - all_items - Default is All Tags/All Categories
    333322 * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category
     
    337326 * - add_new_item - Default is Add New Tag/Add New Category
    338327 * - new_item_name - Default is New Tag Name/New Category Name
    339  * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas," used in the meta box.
    340  * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags," used in the meta box when JavaScript is disabled.
    341  * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags," used in the meta box.
    342328 *
    343329 * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.)
     
    349335
    350336function get_taxonomy_labels( $tax ) {
    351     if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
    352         $tax->labels['separate_items_with_commas'] = $tax->helps;
    353 
    354337    $nohier_vs_hier_defaults = array(
    355338        'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
    356339        'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
    357340        'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
    358         'popular_items' => array( __( 'Popular Tags' ), null ),
     341        'popular_items' => array( __( 'Popular Tags' ), __( 'Popular Category' ) ),
    359342        'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
    360343        'parent_item' => array( null, __( 'Parent Category' ) ),
     
    364347        'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
    365348        'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
    366         'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
    367         'add_or_remove_items' => array( __( 'Add or remove tags' ), null ),
    368         'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
    369349    );
    370350
     
    440420
    441421    foreach ( (array) $taxonomies as $taxonomy ) {
    442         if ( ! taxonomy_exists( $taxonomy ) )
     422        if ( ! is_taxonomy( $taxonomy ) )
    443423            return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
    444424    }
     
    512492    }
    513493
    514     if ( ! taxonomy_exists($taxonomy) ) {
     494    if ( ! is_taxonomy($taxonomy) ) {
    515495        $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    516496        return $error;
     
    579559    global $wpdb;
    580560
    581     if ( ! taxonomy_exists($taxonomy) )
     561    if ( ! is_taxonomy($taxonomy) )
    582562        return false;
    583563
     
    637617 */
    638618function get_term_children( $term_id, $taxonomy ) {
    639     if ( ! taxonomy_exists($taxonomy) )
     619    if ( ! is_taxonomy($taxonomy) )
    640620        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    641621
     
    822802
    823803    foreach ( (array) $taxonomies as $taxonomy ) {
    824         if ( ! taxonomy_exists($taxonomy) ) {
     804        if ( ! is_taxonomy($taxonomy) ) {
    825805            $error = & new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    826806            return $error;
     
    10741054 * Returns the index of a defined term, or 0 (false) if the term doesn't exist.
    10751055 *
    1076  * Formerly is_term(), introduced in 2.3.0.
    1077  *
    1078  * @package WordPress
    1079  * @subpackage Taxonomy
    1080  * @since 3.0.0
     1056 * @package WordPress
     1057 * @subpackage Taxonomy
     1058 * @since 2.3.0
    10811059 *
    10821060 * @uses $wpdb
     
    10871065 * @return mixed Get the term id or Term Object, if exists.
    10881066 */
    1089 function term_exists($term, $taxonomy = '', $parent = 0) {
     1067function is_term($term, $taxonomy = '', $parent = 0) {
    10901068    global $wpdb;
    10911069
     
    13481326    $term = (int) $term;
    13491327
    1350     if ( ! $ids = term_exists($term, $taxonomy) )
     1328    if ( ! $ids = is_term($term, $taxonomy) )
    13511329        return false;
    13521330    if ( is_wp_error( $ids ) )
     
    13611339    if ( isset($default) ) {
    13621340        $default = (int) $default;
    1363         if ( ! term_exists($default, $taxonomy) )
     1341        if ( ! is_term($default, $taxonomy) )
    13641342            unset($default);
    13651343    }
     
    14481426
    14491427    foreach ( (array) $taxonomies as $taxonomy ) {
    1450         if ( ! taxonomy_exists($taxonomy) )
     1428        if ( ! is_taxonomy($taxonomy) )
    14511429            return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    14521430    }
     
    15861564    global $wpdb;
    15871565
    1588     if ( ! taxonomy_exists($taxonomy) )
     1566    if ( ! is_taxonomy($taxonomy) )
    15891567        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
    15901568
     
    16281606    }
    16291607
    1630     if ( $term_id = term_exists($slug) ) {
     1608    if ( $term_id = is_term($slug) ) {
    16311609        $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
    16321610        // We've got an existing term in the same taxonomy, which matches the name of the new term:
    1633         if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && term_exists( (int) $term_id, $taxonomy ) ) {
     1611        if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && is_term( (int) $term_id, $taxonomy ) ) {
    16341612            // Hierarchical, and it matches an existing term, Do not allow same "name" in the same level.
    16351613            $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) );
     
    16481626                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
    16491627            $term_id = (int) $wpdb->insert_id;
    1650         } elseif ( term_exists( (int) $term_id, $taxonomy ) )  {
     1628        } elseif ( is_term( (int) $term_id, $taxonomy ) )  {
    16511629            // Same name, same slug.
    16521630            return new WP_Error('term_exists', __('A term with the name provided already exists.'));
     
    17171695    $object_id = (int) $object_id;
    17181696
    1719     if ( ! taxonomy_exists($taxonomy) )
     1697    if ( ! is_taxonomy($taxonomy) )
    17201698        return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    17211699
     
    17351713            continue;
    17361714
    1737         if ( !$term_info = term_exists($term, $taxonomy) ) {
     1715        if ( !$term_info = is_term($term, $taxonomy) ) {
    17381716            // Skip if a non-existent term ID is passed.
    17391717            if ( is_int($term) )
     
    18101788    global $wpdb;
    18111789
    1812     if ( ! term_exists( $slug ) )
     1790    if ( ! is_term( $slug ) )
    18131791        return $slug;
    18141792
     
    18221800                break;
    18231801            $slug .= '-' . $parent_term->slug;
    1824             if ( ! term_exists( $slug ) )
     1802            if ( ! is_term( $slug ) )
    18251803                return $slug;
    18261804
     
    18881866    global $wpdb;
    18891867
    1890     if ( ! taxonomy_exists($taxonomy) )
     1868    if ( ! is_taxonomy($taxonomy) )
    18911869        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
    18921870
     
    24072385
    24082386    // Get the object and term ids and stick them in a lookup table
    2409     $tax_obj = get_taxonomy($taxonomy);
    2410     $object_types = esc_sql($tax_obj->object_type);
    2411     $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'");
     2387    $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type = 'post' AND post_status = 'publish'");
    24122388    foreach ( $results as $row ) {
    24132389        $id = $term_ids[$row->term_taxonomy_id];
Note: See TracChangeset for help on using the changeset viewer.