当前位置: 首页>>代码示例>>PHP>>正文


PHP is_taxonomy函数代码示例

本文整理汇总了PHP中is_taxonomy函数的典型用法代码示例。如果您正苦于以下问题:PHP is_taxonomy函数的具体用法?PHP is_taxonomy怎么用?PHP is_taxonomy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_taxonomy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: spg_clean_data

function spg_clean_data()
{
    $easymedia_values = get_option('easy_media_opt');
    if (is_array($easymedia_values) && array_key_exists($name, $easymedia_values)) {
        $keepornot = $easymedia_values['easymedia_disen_databk'];
    }
    if ($keepornot != '1') {
        //$wpdb->query("DELETE FROM `wp_options` WHERE `option_name` LIKE 'emediagallery_%'");
        delete_option('easy_media_opt');
        // Remove plugin-specific custom post type entries.
        $posts = get_posts(array('numberposts' => -1, 'post_type' => 'easymediagallery', 'post_status' => 'any'));
        foreach ($posts as $post) {
            wp_delete_post($post->ID, true);
        }
        // Remove plugin-specific custom taxonomies and terms.
        $tax = 'emediagallery';
        if (is_taxonomy($tax)) {
            foreach ($tax as $taxonomy) {
                $terms = get_terms($taxonomy, array('get ' => 'all'));
                foreach ($terms as $term) {
                    wp_delete_term($term->term_id, $taxonomy);
                }
                unset($wp_taxonomies[$taxonomy]);
            }
        }
    } else {
    }
}
开发者ID:10Dimensional,项目名称:InspOrg,代码行数:28,代码来源:uninstall.php

示例2: p2_body_class

function p2_body_class()
{
    if (is_taxonomy('mentions')) {
        return body_class('mentions');
    }
    return body_class();
}
开发者ID:alx,项目名称:pressmark,代码行数:7,代码来源:template-tags.php

示例3: __construct

 function __construct()
 {
     global $pagenow;
     // Load plugin options
     $this->load_options();
     // Register new taxonomy so that we can store all our authors
     if (!is_taxonomy($this->coauthor_taxonomy)) {
         register_taxonomy($this->coauthor_taxonomy, 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => false, 'query_var' => false, 'rewrite' => false, 'sort' => true));
     }
     // Modify SQL queries to include coauthors
     add_filter('posts_where', array(&$this, 'posts_where_filter'));
     add_filter('posts_join', array(&$this, 'posts_join_filter'));
     add_filter('posts_groupby', array(&$this, 'posts_groupby_filter'));
     // Hooks to add additional coauthors to author column to Edit Posts page
     if ($pagenow == 'edit.php') {
         add_filter('manage_posts_columns', array(&$this, '_filter_manage_posts_columns'));
         add_action('manage_posts_custom_column', array(&$this, '_filter_manage_posts_custom_column'));
     }
     // Action to set users when a post is saved
     //add_action('edit_post', array(&$this, 'coauthors_update_post'));
     add_action('save_post', array(&$this, 'coauthors_update_post'));
     // Action to reassign posts when a user is deleted
     add_action('delete_user', array(&$this, 'delete_user_action'));
     // Action to set up author auto-suggest
     add_action('wp_ajax_coauthors_ajax_suggest', array(&$this, 'ajax_suggest'));
     // Filter to allow coauthors to edit posts
     add_filter('user_has_cap', array(&$this, 'add_coauthor_cap'), 10, 3);
     add_filter('comment_notification_headers', array(&$this, 'notify_coauthors'), 10, 3);
     // Add the main JS script and CSS file
     if (get_bloginfo('version') >= 2.8) {
         // Using WordPress 2.8, are we?
         add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
     } else {
         // Pfft, you're old school
         add_action('admin_print_scripts', array(&$this, 'enqueue_scripts_legacy'));
     }
     // Add necessary JS variables
     add_action('admin_print_scripts', array(&$this, 'js_vars'));
 }
开发者ID:jayfresh,项目名称:SweetSpot,代码行数:39,代码来源:co-authors.php

示例4: spg_clean_data

function spg_clean_data()
{
    if (easy_gt_option('easymedia_disen_databk') != '1') {
        delete_option('easy_media_opt');
        // Remove plugin-specific custom post type entries.
        $posts = get_posts(array('numberposts' => -1, 'post_type' => 'easymediagallery', 'post_status' => 'any'));
        foreach ($posts as $post) {
            wp_delete_post($post->ID, true);
        }
        // Remove plugin-specific custom taxonomies and terms ( not work ).
        $tax = 'emediagallery';
        if (is_taxonomy($tax)) {
            foreach ($tax as $taxonomy) {
                $terms = get_terms($taxonomy, array('get ' => 'all'));
                foreach ($terms as $term) {
                    wp_delete_term($term->term_id, $taxonomy);
                }
                unset($wp_taxonomies[$taxonomy]);
            }
        }
        delete_option('easy_media_opt');
    }
}
开发者ID:paulcherrypipka,项目名称:wptest,代码行数:23,代码来源:uninstall.php

示例5: tFeedLink

/**
 * Universal Feed Link Generator
 * @see     wp-includes/rewrite.php, wp-includes/taxonomy.php, wp-includes/feed.php
 * @see     wp-includes/link-template.php: get_category_feed_link
 * @uses    get_term_by, is_taxonomy, get_default_feed, get_option, add_query_arg, 
 *          get_category_permastruct, get_tag_permastruct, get_category_parents
 *          user_trailingslashit, trailingslashit
 * @param   string          custom feed name or taxonomy
 * @param   int             only needed for some feeds
 * @global  object          url rewriter
 * @return  string          full url
 */
function tFeedLink($feed = '', $id = false)
{
    $taxonomy = '';
    $term = '';
    if ($id && is_taxonomy($feed)) {
        $taxonomy = $feed;
        $term = get_term_by('id', $id, $taxonomy);
    }
    global $wp_rewrite;
    if (empty($feed)) {
        $feed = get_default_feed();
    }
    if (get_option('permalink_structure') == '') {
        # no wp-rewrite
        $link = add_query_arg(array('feed' => $feed, $taxonomy => $term), get_bloginfo('url'));
    } elseif ($feed == 'category' || $feed == 'tag') {
        if (!empty($term)) {
            $link = $taxonomy == 'category' ? $wp_rewrite->get_category_permastruct() : $wp_rewrite->get_tag_permastruct();
            $slug = $term->slug;
            if ($taxonomy == 'category') {
                if ($term->parent != 0) {
                    $slug = get_category_parents($term->parent, false, '/', true) . $slug;
                }
                $link = str_replace('%category%', $slug, $link);
            } elseif ($taxonomy == 'post_tag') {
                $link = str_replace('%tag%', $slug, $link);
            }
            $feed = user_trailingslashit('feed' . ($feed != get_default_feed() && $feed != $taxonomy ? '/' . $feed : ''), 'feed');
            $link = trailingslashit(get_bloginfo('url') . $link) . $feed;
        }
    } elseif ($feed == 'work' || $feed == 'writing') {
    } elseif ($feed == 'comments') {
    }
    $link = apply_filters('t_term__link', $link, $feed);
    return $link;
}
开发者ID:hlfcoding,项目名称:hlf-wordpress,代码行数:48,代码来源:functions.wp-add-feed.php

示例6: query_content

function query_content($args = array())
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_filter('before_query_content', $args);
    hook_action('query_content');
    if (!is_array($args)) {
        parse_str($args, $args);
    }
    /** Lọc theo content_key */
    if (isset($args['content_key'])) {
        /** Nếu yêu cầu content key thì lấy các id có key như query yêu cầu */
        $content_key = $args['content_key'];
        /** Nếu content key là một mảng */
        if (is_array($content_key)) {
            $where_key = '';
            $i = 0;
            foreach ($content_key as $key) {
                if ($i == 0) {
                    $where_key .= " `key` = '" . $key . "' ";
                } else {
                    $where_key .= " OR `key` = '" . $key . "' ";
                }
                $i++;
            }
            $where_content_key = "WHERE " . $where_key;
        } else {
            $where_content_key = "WHERE `key` = '" . $content_key . "'";
        }
    } else {
        /** Không yêu cầu content key, kiểm tra xem có đang ở template taxonomy không */
        if (is_taxonomy() == TRUE) {
            $taxonomy_id = get_id();
            $content_key = taxonomy_get_content_key($taxonomy_id);
            if ($content_key != FALSE) {
                $where_content_key = "WHERE `key` = '" . $content_key . "'";
            }
        } else {
            $where_content_key = '';
        }
    }
    $hmdb->Release();
    $query_content_key = "SELECT `id` FROM `" . DB_PREFIX . "content` " . $where_content_key;
    /** Lọc theo taxonomy */
    $where_taxonomy = '';
    if (isset($args['taxonomy'])) {
        /** Nếu yêu cầu trong một taxonomy nhất định thì lấy các object_id có relationship như query yêu cầu */
        $taxonomy_id = $args['taxonomy'];
        /** Nếu taxonomy là một mảng */
        if (is_array($taxonomy_id)) {
            $implode = implode($taxonomy_id, ',');
            if ($implode != '') {
                $where_taxonomy = ' WHERE `target_id` IN (' . $implode . ') ';
            }
        } else {
            $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id;
        }
    } else {
        /** Không yêu cầu taxonomy nhất định, kiểm tra xem có đang ở template taxonomy không */
        if (is_taxonomy() == TRUE) {
            $taxonomy_id = get_id();
            $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id;
        }
    }
    if ($where_taxonomy != '') {
        $hmdb->Release();
        $query_in_taxonomy = "SELECT `object_id` FROM `" . DB_PREFIX . "relationship` " . $where_taxonomy . " AND `relationship` = 'contax'";
    }
    /** Lọc theo field */
    if (isset($args['field_query'])) {
        $field_query = $args['field_query'];
    } else {
        $field_query = array(array('field' => 'status', 'compare' => '=', 'value' => 'public'), array('field' => 'public_time', 'compare' => '<=', 'value' => time()));
    }
    $all_field_query = array();
    foreach ($field_query as $item) {
        /** check đủ điều kiện tạo field query */
        if (isset($item['field']) and isset($item['compare']) and isset($item['value'])) {
            $field = $item['field'];
            $compare = $item['compare'];
            $value = $item['value'];
            $numerically = FALSE;
            /** build query */
            if (is_numeric($value)) {
                $value_query = $value;
            } else {
                $value_query = "'{$value}'";
            }
            if ($compare == 'like%') {
                $all_field_query[$field] = " ( `name` = '{$field}' AND `val` LIKE '%{$value}%' )";
            } else {
                $all_field_query[$field] = " ( `name` = '{$field}' AND `val` {$compare} {$value_query} )";
            }
        }
    }
    /** nếu size của mảng chứa các kết quả của các field query >= 2 */
    $size = sizeof($all_field_query);
    $query_field = "SELECT `object_id` FROM `" . DB_PREFIX . "field` WHERE";
    if ($size > 1) {
        if (isset($args['field_query_relation'])) {
//.........这里部分代码省略.........
开发者ID:hoamaisoft,项目名称:hoamai-cms-beta-1.0,代码行数:101,代码来源:content.php

示例7: getTerms

 /**
  * Extended get_terms function support
  *  - Limit category
  *  - Limit days
  *  - Selection restrict
  *  - Min usage
  *
  * @param string|array $taxonomies
  * @param string $args
  * @return array
  */
 function getTerms($taxonomies, $args = '', $skip_cache = false)
 {
     global $wpdb;
     $single_taxonomy = false;
     if (!is_array($taxonomies)) {
         $single_taxonomy = true;
         $taxonomies = array($taxonomies);
     }
     foreach ((array) $taxonomies as $taxonomy) {
         if (!is_taxonomy($taxonomy)) {
             return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
         }
     }
     $in_taxonomies = "'" . implode("', '", $taxonomies) . "'";
     $defaults = array('cloud_selection' => 'count-desc', 'hide_empty' => true, 'exclude' => '', 'include' => '', 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'st_name_like' => '', 'pad_counts' => false, 'limit_days' => 0, 'category' => 0, 'min_usage' => 0);
     $args = wp_parse_args($args, $defaults);
     if (!$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) || '' != $args['parent']) {
         $args['child_of'] = 0;
         $args['hierarchical'] = false;
         $args['pad_counts'] = false;
     }
     if ('all' == $args['get']) {
         $args['child_of'] = 0;
         $args['hide_empty'] = 0;
         $args['hierarchical'] = false;
         $args['pad_counts'] = false;
     }
     extract($args, EXTR_SKIP);
     if ($child_of) {
         $hierarchy = _get_term_hierarchy($taxonomies[0]);
         if (!isset($hierarchy[$child_of])) {
             return array();
         }
     }
     if ($parent) {
         $hierarchy = _get_term_hierarchy($taxonomies[0]);
         if (!isset($hierarchy[$parent])) {
             return array();
         }
     }
     if ($skip_cache != true) {
         // Get cache if exist
         $key = md5(serialize($args) . serialize($taxonomies));
         if ($cache = wp_cache_get('get_terms', 'terms')) {
             if (isset($cache[$key])) {
                 return apply_filters('get_terms', $cache[$key], $taxonomies, $args);
             }
         }
     }
     // Restrict category
     $category_sql = '';
     if (!empty($category) && $category != '0') {
         $incategories = preg_split('/[\\s,]+/', $category);
         $objects_id = get_objects_in_term($incategories, 'category');
         $objects_id = array_unique($objects_id);
         // to be sure haven't duplicates
         if (empty($objects_id)) {
             // No posts for this category = no tags for this category
             return array();
         }
         foreach ((array) $objects_id as $object_id) {
             $category_sql .= "'" . $object_id . "', ";
         }
         $category_sql = substr($category_sql, 0, strlen($category_sql) - 2);
         // Remove latest ", "
         $category_sql = 'AND p.ID IN (' . $category_sql . ')';
     }
     // count-asc/count-desc/name-asc/name-desc/random
     $cloud_selection = strtolower($cloud_selection);
     switch ($cloud_selection) {
         case 'count-asc':
             $order_by = 'tt.count ASC';
             break;
         case 'random':
             $order_by = 'RAND()';
             break;
         case 'name-asc':
             $order_by = 't.name ASC';
             break;
         case 'name-desc':
             $order_by = 't.name DESC';
             break;
         default:
             // count-desc
             $order_by = 'tt.count DESC';
             break;
     }
     // Min usage
     $restict_usage = '';
//.........这里部分代码省略.........
开发者ID:nurpax,项目名称:saastafi,代码行数:101,代码来源:simple-tags.php

示例8:

   <!--/#navigation--><!--menu-end-here-->
<!--------------------------
Added for New Header end
--------------------------->


<!--Added for Breadcum Start -->
<?php 
if (!is_page('home')) {
    ?>
<div class="container">
  <!--breadcrumb-start-->
  <div class="well gap30">
  <div class="row">
  <div class="<?php 
    if (is_taxonomy('product_cat')) {
        ?>
col-md-7<?php 
    } else {
        ?>
col-md-12<?php 
    }
    ?>
"> <ol class="breadcrumb">
  
  <li typeof="v:Breadcrumb"><a href="<?php 
    echo get_option('siteurl');
    ?>
" title="Go to ." property="v:title" rel="v:url">Home</a></li>
    <?php 
    if (function_exists('bcn_display')) {
开发者ID:venkateshphp,项目名称:intellitraining,代码行数:31,代码来源:header.php

示例9: __

<?php

/**
 * Edit Tags Administration Panel.
 *
 * @package WordPress
 * @subpackage Administration
 */
/** WordPress Administration Bootstrap */
require_once 'admin.php';
$title = __('Tags');
wp_reset_vars(array('action', 'tag', 'taxonomy'));
if (empty($taxonomy)) {
    $taxonomy = 'post_tag';
}
if (!is_taxonomy($taxonomy)) {
    wp_die(__('Invalid taxonomy'));
}
$parent_file = 'edit.php';
$submenu_file = "edit-tags.php?taxonomy={$taxonomy}";
if (isset($_GET['action']) && isset($_GET['delete_tags']) && ('delete' == $_GET['action'] || 'delete' == $_GET['action2'])) {
    $action = 'bulk-delete';
}
switch ($action) {
    case 'add-tag':
        check_admin_referer('add-tag');
        if (!current_user_can('manage_categories')) {
            wp_die(__('Cheatin&#8217; uh?'));
        }
        $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
        if ($ret && !is_wp_error($ret)) {
开发者ID:ericandrewlewis,项目名称:wordpress-mu,代码行数:31,代码来源:edit-tags.php

示例10: getTerms

	/**
	 * Extended get_terms function support
	 * - Limit category
	 * - Limit days
	 * - Selection restrict
	 * - Min usage
	 *
	 * @param string|array $taxonomies
	 * @param string $args
	 * @return array
	 */
	function getTerms( $taxonomies, $args = '', $skip_cache = false, $internal_st = false ) {
		global $wpdb;
		$empty_array = array();

		$single_taxonomy = false;
		if ( !is_array($taxonomies) ) {
			$single_taxonomy = true;
			$taxonomies = array($taxonomies);
		}

		foreach ( $taxonomies as $taxonomy ) {
			if ( ! is_taxonomy($taxonomy) ) {
				return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
			}
		}

		$in_taxonomies = "'" . implode("', '", $taxonomies) . "'";

		$defaults = array(
			'orderby' => 'name',
			'order' => 'ASC',
			'cloud_selection' => 'count-desc',
			'hide_empty' => true,
			'exclude' => '',
			'include' => '',
			'number' => '',
			'fields' => 'all',
			'slug' => '',
			'parent' => '',
			'hierarchical' => true,
			'child_of' => 0,
			'get' => '',
			'name__like' => '',
			'st_name_like' => '',
			'pad_counts' => false,
			'offset' => '',
			'search' => '',
			'limit_days' => 0,
			'category' => 0,
			'min_usage' => 0
		);

		$args = wp_parse_args( $args, $defaults );
		if ( $internal_st != true ) { // Allow limit :)
			$args['number'] = absint( $args['number'] );
		}
		$args['offset'] = absint( $args['offset'] );
		if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) || '' != $args['parent'] ) {
			$args['child_of'] = 0;
			$args['hierarchical'] = false;
			$args['pad_counts'] = false;
		}

		if ( 'all' == $args['get'] ) {
			$args['child_of'] = 0;
			$args['hide_empty'] = 0;
			$args['hierarchical'] = false;
			$args['pad_counts'] = false;
		}
		extract($args, EXTR_SKIP);

		if ( $child_of ) {
			$hierarchy = _get_term_hierarchy($taxonomies[0]);
			if ( !isset($hierarchy[$child_of]) )
				return $empty_array;
		}

		if ( $parent ) {
			$hierarchy = _get_term_hierarchy($taxonomies[0]);
			if ( !isset($hierarchy[$parent]) )
				return $empty_array;
		}
		
		if ( $skip_cache != true ) {
			// $args can be whatever, only use the args defined in defaults to compute the key
			$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
			$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
			$last_changed = wp_cache_get('last_changed', 'terms');
			if ( !$last_changed ) {
			    $last_changed = time();
			    wp_cache_set('last_changed', $last_changed, 'terms');
			}
			$cache_key = "get_terms:$key:$last_changed";
			
			if ( $cache = wp_cache_get( $cache_key, 'terms' ) ) {
			    $terms = apply_filters('get_terms', $cache, $taxonomies, $args);
			    return $terms;
			}
		}
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:101,代码来源:simple-tags.client.php

示例11: cwp_post_row


//.........这里部分代码省略.........
                if ($pending_comments) {
                    echo '</strong>';
                }
                ?>
		</div></td>
		<?php 
                break;
            case 'author':
                ?>
		<td <?php 
                echo $attributes;
                ?>
><a href="edit.php?author=<?php 
                the_author_meta('ID');
                ?>
"><?php 
                the_author();
                ?>
</a></td>
		<?php 
                break;
            case 'control_view':
                ?>
		<td><a href="<?php 
                the_permalink();
                ?>
" rel="permalink" class="view"><?php 
                _e('View');
                ?>
</a></td>
		<?php 
                break;
            case 'control_edit':
                ?>
		<td><?php 
                if (current_user_can('edit_post', $post->ID)) {
                    echo "<a href='{$edit_link}' class='edit'>" . __('Edit') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case 'control_delete':
                ?>
		<td><?php 
                if (current_user_can('delete_post', $post->ID)) {
                    echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post={$id}", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case is_taxonomy($column_name):
                ?>
			<td <?php 
                echo $attributes;
                ?>
><?php 
                $tags = wp_get_object_terms($post->ID, $column_name);
                if (!empty($tags)) {
                    $out = array();
                    foreach ($tags as $c) {
                        $out[] = "<a href=\"" . $page->get_edit_term_link($column_name, $c) . '">' . $c->name . "</a>";
                    }
                    echo join(', ', $out);
                } else {
                    _e('No ' . $column_display_name);
                }
                ?>
</td>
			<?php 
                break;
            case function_exists($column_name):
                ?>
			
			<td>
			<?php 
                echo call_user_func_array($column_name, array($post));
                ?>
			</td>
			<?php 
                break;
            default:
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                do_action('manage_posts_custom_column', $column_name, $post->ID);
                ?>
</td>
		<?php 
                break;
        }
    }
    ?>
	</tr>
	<?php 
    $post = $global_post;
}
开发者ID:adamcarlile,项目名称:Alex-Goy,代码行数:101,代码来源:cwp.page.manage.php

示例12: elseif

">RSS</a>

			<?php 
} elseif (is_author()) {
    ?>
				
				<?php 
    printf(_c('Updates from %s|name', 'p2'), p2_get_archive_author());
    ?>
				<a class="rss" href="<?php 
    p2_author_feed_link();
    ?>
">RSS</a>
				
			<?php 
} elseif (is_taxonomy('mentions')) {
    ?>

				<?php 
    printf(_c('Posts Mentioning %s|name', 'p2'), p2_get_mention_name());
    ?>
				<a class="rss" href="<?php 
    p2_author_feed_link();
    ?>
">RSS</a>
		
			<?php 
} else {
    ?>
		
				<?php 
开发者ID:alx,项目名称:pressmark,代码行数:31,代码来源:index.php

示例13: taxonomy_exists

 /**
  * Compatibility wrapper for WordPress taxonomy lookup.
  */
 function taxonomy_exists($taxonomy)
 {
     if (function_exists('taxonomy_exists')) {
         // 3.0 or later
         return taxonomy_exists($taxonomy);
     } else {
         return is_taxonomy($taxonomy);
     }
 }
开发者ID:joaosigno,项目名称:dazake-job,代码行数:12,代码来源:csv_importer.php

示例14: wp_update_term

function wp_update_term($term, $taxonomy, $args = array())
{
    global $wpdb;
    if (!is_taxonomy($taxonomy)) {
        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
    }
    $term_id = (int) $term;
    // First, get all of the original args
    $term = get_term($term_id, $taxonomy, ARRAY_A);
    // Escape data pulled from DB.
    $term = add_magic_quotes($term);
    // Merge old and new args with new args overwriting old ones.
    $args = array_merge($term, $args);
    $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
    $args = wp_parse_args($args, $defaults);
    $args = sanitize_term($args, $taxonomy, 'db');
    extract($args, EXTR_SKIP);
    $empty_slug = false;
    if (empty($slug)) {
        $empty_slug = true;
        $slug = sanitize_title($name);
    }
    if ($alias_of) {
        $alias = $wpdb->fetch_row("SELECT term_id, term_group FROM {$wpdb->terms} WHERE slug = '{$alias_of}'");
        if ($alias->term_group) {
            // The alias we want is already in a group, so let's use that one.
            $term_group = $alias->term_group;
        } else {
            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
            $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM {$wpdb->terms} GROUP BY term_group") + 1;
            $wpdb->query("UPDATE {$wpdb->terms} SET term_group = {$term_group} WHERE term_id = {$alias->term_id}");
        }
    }
    // Check for duplicate slug
    $id = $wpdb->get_var("SELECT term_id FROM {$wpdb->terms} WHERE slug = '{$slug}'");
    if ($id && $id != $term_id) {
        // If an empty slug was passed, reset the slug to something unique.
        // Otherwise, bail.
        if ($empty_slug) {
            $slug = wp_unique_term_slug($slug, (object) $args);
        } else {
            return new WP_Error('duplicate_term_slug', sprintf(__('The slug "%s" is already in use by another term'), $slug));
        }
    }
    $wpdb->query("UPDATE {$wpdb->terms} SET name = '{$name}', slug = '{$slug}', term_group = '{$term_group}' WHERE term_id = '{$term_id}'");
    if (empty($slug)) {
        $slug = sanitize_title($name, $term_id);
        $wpdb->query("UPDATE {$wpdb->terms} SET slug = '{$slug}' WHERE term_id = '{$term_id}'");
    }
    $tt_id = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM {$wpdb->term_taxonomy} AS tt INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = '{$taxonomy}' AND t.term_id = {$term_id}");
    $wpdb->query("UPDATE {$wpdb->term_taxonomy} SET term_id = '{$term_id}', taxonomy = '{$taxonomy}', description = '{$description}', parent = '{$parent}' WHERE term_taxonomy_id = '{$tt_id}'");
    do_action("edit_term", $term_id, $tt_id);
    do_action("edit_{$taxonomy}", $term_id, $tt_id);
    $term_id = apply_filters('term_id_filter', $term_id, $tt_id);
    clean_term_cache($term_id, $taxonomy);
    do_action("edited_term", $term_id, $tt_id);
    do_action("edited_{$taxonomy}", $term_id, $tt_id);
    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:59,代码来源:taxonomy.php

示例15: wp_list_categories

/**
 * Display or retrieve the HTML list of categories.
 *
 * The list of arguments is below:
 *     'show_option_all' (string) - Text to display for showing all categories.
 *     'orderby' (string) default is 'ID' - What column to use for ordering the
 * categories.
 *     'order' (string) default is 'ASC' - What direction to order categories.
 *     'show_last_update' (bool|int) default is 0 - See {@link
 * walk_category_dropdown_tree()}
 *     'show_count' (bool|int) default is 0 - Whether to show how many posts are
 * in the category.
 *     'hide_empty' (bool|int) default is 1 - Whether to hide categories that
 * don't have any posts attached to them.
 *     'use_desc_for_title' (bool|int) default is 1 - Whether to use the
 * description instead of the category title.
 *     'feed' - See {@link get_categories()}.
 *     'feed_type' - See {@link get_categories()}.
 *     'feed_image' - See {@link get_categories()}.
 *     'child_of' (int) default is 0 - See {@link get_categories()}.
 *     'exclude' (string) - See {@link get_categories()}.
 *     'exclude_tree' (string) - See {@link get_categories()}.
 *     'echo' (bool|int) default is 1 - Whether to display or retrieve content.
 *     'current_category' (int) - See {@link get_categories()}.
 *     'hierarchical' (bool) - See {@link get_categories()}.
 *     'title_li' (string) - See {@link get_categories()}.
 *     'depth' (int) - The max depth.
 *
 * @since 2.1.0
 *
 * @param string|array $args Optional. Override default arguments.
 * @return string HTML content only if 'echo' argument is 0.
 */
function wp_list_categories($args = '')
{
    $defaults = array('show_option_all' => '', 'show_option_none' => __('No categories'), 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0, 'hierarchical' => true, 'title_li' => __('Categories'), 'echo' => 1, 'depth' => 0, 'taxonomy' => 'category');
    $r = wp_parse_args($args, $defaults);
    if (!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
        $r['pad_counts'] = true;
    }
    if (isset($r['show_date'])) {
        $r['include_last_update_time'] = $r['show_date'];
    }
    if (true == $r['hierarchical']) {
        $r['exclude_tree'] = $r['exclude'];
        $r['exclude'] = '';
    }
    if (!isset($r['class'])) {
        $r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
    }
    extract($r);
    if (!is_taxonomy($taxonomy)) {
        return false;
    }
    $categories = get_categories($r);
    $output = '';
    if ($title_li && 'list' == $style) {
        $output = '<li class="' . $class . '">' . $title_li . '<ul>';
    }
    if (empty($categories)) {
        if (!empty($show_option_none)) {
            if ('list' == $style) {
                $output .= '<li>' . $show_option_none . '</li>';
            } else {
                $output .= $show_option_none;
            }
        }
    } else {
        global $wp_query;
        if (!empty($show_option_all)) {
            if ('list' == $style) {
                $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>';
            } else {
                $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>';
            }
        }
        if (empty($r['current_category']) && (is_category() || is_tax())) {
            $r['current_category'] = $wp_query->get_queried_object_id();
        }
        if ($hierarchical) {
            $depth = $r['depth'];
        } else {
            $depth = -1;
        }
        // Flat.
        $output .= walk_category_tree($categories, $depth, $r);
    }
    if ($title_li && 'list' == $style) {
        $output .= '</ul></li>';
    }
    $output = apply_filters('wp_list_categories', $output);
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:beaucollins,项目名称:wp,代码行数:97,代码来源:category-template.php


注:本文中的is_taxonomy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。