mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
No more TAXONOMY bit fiels. see #4189
git-svn-id: http://svn.automattic.com/wordpress/trunk@5534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6251eb3ca6
commit
76d2530a7e
@ -162,16 +162,8 @@ function wp_delete_category($cat_ID) {
|
|||||||
function wp_create_category($cat_name) {
|
function wp_create_category($cat_name) {
|
||||||
if ( $id = category_exists($cat_name) )
|
if ( $id = category_exists($cat_name) )
|
||||||
return $id;
|
return $id;
|
||||||
$cat_array = array('cat_name' => $cat_name, 'type' => TAXONOMY_CATEGORY);
|
|
||||||
|
|
||||||
if ( $id = category_object_exists($cat_name) ) {
|
return wp_insert_category( array('cat_name' => $cat_name) );
|
||||||
$category = get_category($id);
|
|
||||||
$cat_array['type'] = $category->type | $cat_array['type'];
|
|
||||||
$cat_array['cat_ID'] = $id;
|
|
||||||
return wp_update_category($cat_array);
|
|
||||||
} else {
|
|
||||||
return wp_insert_category($cat_array);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_create_categories($categories, $post_id = '') {
|
function wp_create_categories($categories, $post_id = '') {
|
||||||
@ -190,20 +182,8 @@ function wp_create_categories($categories, $post_id = '') {
|
|||||||
return $cat_ids;
|
return $cat_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function category_object_exists($cat_name) {
|
|
||||||
global $wpdb;
|
|
||||||
if (!$category_nicename = sanitize_title($cat_name))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
|
|
||||||
}
|
|
||||||
|
|
||||||
function category_exists($cat_name) {
|
function category_exists($cat_name) {
|
||||||
global $wpdb;
|
return is_term($cat_name, 'category');
|
||||||
if (!$category_nicename = sanitize_title($cat_name))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' AND ( type & " . TAXONOMY_CATEGORY . " != 0 )");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function tag_exists($tag_name) {
|
function tag_exists($tag_name) {
|
||||||
@ -214,7 +194,7 @@ function wp_create_tag($tag_name) {
|
|||||||
if ( $id = tag_exists($tag_name) )
|
if ( $id = tag_exists($tag_name) )
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
$tag_id = wp_insert_term($tag_name, 'post_tag');
|
return wp_insert_term($tag_name, 'post_tag');
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_delete_user($id, $reassign = 'novalue') {
|
function wp_delete_user($id, $reassign = 'novalue') {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('TAXONOMY_CATEGORY', 1);
|
|
||||||
define('TAXONOMY_TAG', 2);
|
|
||||||
|
|
||||||
function get_all_category_ids() {
|
function get_all_category_ids() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user