wp/wp-admin/includes/taxonomy.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    63  *
    63  *
    64  * @since 2.0.0
    64  * @since 2.0.0
    65  *
    65  *
    66  * @param array $categories List of categories to create.
    66  * @param array $categories List of categories to create.
    67  * @param int   $post_id    Optional. The post ID. Default empty.
    67  * @param int   $post_id    Optional. The post ID. Default empty.
    68  * @return List of categories to create for the given post.
    68  * @return array List of categories to create for the given post.
    69  */
    69  */
    70 function wp_create_categories( $categories, $post_id = '' ) {
    70 function wp_create_categories( $categories, $post_id = '' ) {
    71 	$cat_ids = array ();
    71 	$cat_ids = array ();
    72 	foreach ( $categories as $category ) {
    72 	foreach ( $categories as $category ) {
    73 		if ( $id = category_exists( $category ) ) {
    73 		if ( $id = category_exists( $category ) ) {
    91  * @since 3.0.0 The 'taxonomy' argument was added.
    91  * @since 3.0.0 The 'taxonomy' argument was added.
    92  *
    92  *
    93  * @param array $catarr {
    93  * @param array $catarr {
    94  *     Array of arguments for inserting a new category.
    94  *     Array of arguments for inserting a new category.
    95  *
    95  *
    96  *     @type int        $cat_ID               Categoriy ID. A non-zero value updates an existing category.
    96  *     @type int        $cat_ID               Category ID. A non-zero value updates an existing category.
    97  *                                            Default 0.
    97  *                                            Default 0.
    98  *     @type string     $taxonomy             Taxonomy slug. Defualt 'category'.
    98  *     @type string     $taxonomy             Taxonomy slug. Default 'category'.
    99  *     @type string     $cat_nam              Category name. Default empty.
    99  *     @type string     $cat_name             Category name. Default empty.
   100  *     @type string     $category_description Category description. Default empty.
   100  *     @type string     $category_description Category description. Default empty.
   101  *     @type string     $category_nicename    Category nice (display) name. Default empty.
   101  *     @type string     $category_nicename    Category nice (display) name. Default empty.
   102  *     @type int|string $category_parent      Category parent ID. Default empty.
   102  *     @type int|string $category_parent      Category parent ID. Default empty.
   103  * }
   103  * }
   104  * @param bool  $wp_error Optional. Default false.
   104  * @param bool  $wp_error Optional. Default false.
   240 		return false;
   240 		return false;
   241 
   241 
   242 	$terms = get_object_term_cache( $post_id, $taxonomy );
   242 	$terms = get_object_term_cache( $post_id, $taxonomy );
   243 	if ( false === $terms ) {
   243 	if ( false === $terms ) {
   244 		$terms = wp_get_object_terms( $post_id, $taxonomy );
   244 		$terms = wp_get_object_terms( $post_id, $taxonomy );
   245 		wp_cache_add( $post_id, $terms, $taxonomy . '_relationships' );
   245 		wp_cache_add( $post_id, wp_list_pluck( $terms, 'term_id' ), $taxonomy . '_relationships' );
   246 	}
   246 	}
   247 
   247 
   248 	if ( ! $terms ) {
   248 	if ( ! $terms ) {
   249 		return false;
   249 		return false;
   250 	}
   250 	}
   257 	}
   257 	}
   258 
   258 
   259 	$terms_to_edit = esc_attr( join( ',', $term_names ) );
   259 	$terms_to_edit = esc_attr( join( ',', $term_names ) );
   260 
   260 
   261 	/**
   261 	/**
   262 	 * Filter the comma-separated list of terms available to edit.
   262 	 * Filters the comma-separated list of terms available to edit.
   263 	 *
   263 	 *
   264 	 * @since 2.8.0
   264 	 * @since 2.8.0
   265 	 *
   265 	 *
   266 	 * @see get_terms_to_edit()
   266 	 * @see get_terms_to_edit()
   267 	 *
   267 	 *