mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 22:45:39 +00:00
Roll tags out of 2.2 -- reverts [5272], [5271], [5257], [5254], [5253], [5251], [5250], [5243], [5235], [5234], [5232], [5231], [5229], [5228], [5217], [5216], [5215], [5213], half of [5210], [5209], [5205], [5203], [5201], [5196], [5184], [5168], [5163], [5162], [5150], [5149], [5148], [5147], [5113], [5112], [5111], and [5110]
git-svn-id: http://svn.automattic.com/wordpress/branches/2.2@5289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bcbe992d05
commit
a9b5bc0f13
@ -121,18 +121,11 @@ function wp_insert_category($catarr) {
|
||||
else
|
||||
$links_private = 0;
|
||||
|
||||
if ( empty($type) )
|
||||
$type = TAXONOMY_CATEGORY;
|
||||
|
||||
// Let's check if we have this category already, if so just do an update
|
||||
if ( !$update && $cat_ID = category_object_exists( $category_nicename ) )
|
||||
$update = true;
|
||||
|
||||
if (!$update) {
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, type) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$type')");
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
|
||||
$cat_ID = (int) $wpdb->insert_id;
|
||||
} else {
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', type = '$type' WHERE cat_ID = '$cat_ID'");
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
|
||||
}
|
||||
|
||||
if ( $category_nicename == '' ) {
|
||||
@ -198,18 +191,15 @@ function wp_delete_category($cat_ID) {
|
||||
|
||||
$parent = $category->category_parent;
|
||||
|
||||
// Delete the category if it is not also a tag.
|
||||
if ( 0 == ($category->type & TAXONOMY_TAG) ) {
|
||||
if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
|
||||
return 0;
|
||||
} else {
|
||||
$wpdb->query("UPDATE $wpdb->categories SET type = type & ~" . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_ID'");
|
||||
}
|
||||
// Delete the category
|
||||
if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
|
||||
return 0;
|
||||
|
||||
// Update children to point to new parent
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
|
||||
|
||||
// Only set posts and links to the default category if they're not in another category already
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID' AND rel_type = 'category'");
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
|
||||
foreach ( (array) $posts as $post_id ) {
|
||||
$cats = wp_get_post_categories($post_id);
|
||||
if ( 1 == count($cats) )
|
||||
@ -235,18 +225,8 @@ function wp_delete_category($cat_ID) {
|
||||
}
|
||||
|
||||
function wp_create_category($cat_name) {
|
||||
if ( $id = category_exists($cat_name) )
|
||||
return $id;
|
||||
$cat_array = array('cat_name' => $cat_name, 'type' => TAXONOMY_CATEGORY);
|
||||
|
||||
if ( $id = category_object_exists($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);
|
||||
}
|
||||
$cat_array = compact('cat_name');
|
||||
return wp_insert_category($cat_array);
|
||||
}
|
||||
|
||||
function wp_create_categories($categories, $post_id = '') {
|
||||
@ -265,44 +245,12 @@ function wp_create_categories($categories, $post_id = '') {
|
||||
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) {
|
||||
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' AND ( type & " . TAXONOMY_CATEGORY . " != 0 )");
|
||||
}
|
||||
|
||||
function tag_exists($tag_name) {
|
||||
global $wpdb;
|
||||
if (! $tag_nicename = sanitize_title($tag_name))
|
||||
return 0;
|
||||
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$tag_nicename' AND ( type & " . TAXONOMY_TAG . " != 0 )");
|
||||
}
|
||||
|
||||
function wp_create_tag($tag_name) {
|
||||
if ( $id = tag_exists($tag_name) )
|
||||
return $id;
|
||||
$tag_array = array('cat_name' => $tag_name, 'type' => TAXONOMY_TAG);
|
||||
|
||||
if ( $id = category_object_exists($tag_name) ) {
|
||||
$category = get_category($id);
|
||||
$tag_array['type'] = $category->type | $tag_array['type'];
|
||||
$tag_array['cat_ID'] = $id;
|
||||
$id = wp_update_category($tag_array);
|
||||
return $id;
|
||||
} else {
|
||||
return wp_insert_category($tag_array);
|
||||
}
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
|
||||
}
|
||||
|
||||
function wp_delete_user($id, $reassign = 'novalue') {
|
||||
|
@ -647,7 +647,7 @@ function checked( $checked, $current) {
|
||||
|
||||
function return_categories_list( $parent = 0 ) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( link_count = 0 OR category_count != 0 ) ORDER BY category_count DESC" );
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" );
|
||||
}
|
||||
|
||||
function sort_cats( $cat1, $cat2 ) {
|
||||
@ -657,29 +657,6 @@ function sort_cats( $cat1, $cat2 ) {
|
||||
return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
|
||||
}
|
||||
|
||||
function get_tags_to_edit( $post_id ) {
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if ( !$post_id )
|
||||
return false;
|
||||
|
||||
$tags = $wpdb->get_results( "
|
||||
SELECT category_id, cat_name
|
||||
FROM $wpdb->categories, $wpdb->post2cat
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_id' AND rel_type = 'tag'
|
||||
" );
|
||||
if ( !$tags )
|
||||
return false;
|
||||
|
||||
foreach ( $tags as $tag )
|
||||
$tag_names[] = $tag->cat_name;
|
||||
$tags_to_edit = join( ', ', $tag_names );
|
||||
$tags_to_edit = attribute_escape( $tags_to_edit );
|
||||
$tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
|
||||
return $tags_to_edit;
|
||||
}
|
||||
|
||||
function get_nested_categories( $default = 0, $parent = 0 ) {
|
||||
global $post_ID, $link_id, $mode, $wpdb;
|
||||
|
||||
@ -687,7 +664,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) {
|
||||
$checked_categories = $wpdb->get_col( "
|
||||
SELECT category_id
|
||||
FROM $wpdb->categories, $wpdb->post2cat
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' AND rel_type = 'category'
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
|
||||
" );
|
||||
|
||||
if ( count( $checked_categories ) == 0 ) {
|
||||
@ -744,7 +721,7 @@ function dropdown_categories( $default = 0 ) {
|
||||
|
||||
function return_link_categories_list( $parent = 0 ) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( category_count = 0 OR link_count != 0 ) ORDER BY link_count DESC" );
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0 OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" );
|
||||
}
|
||||
|
||||
function get_nested_link_categories( $default = 0, $parent = 0 ) {
|
||||
|
@ -118,15 +118,6 @@ cat_rows();
|
||||
</div>
|
||||
|
||||
<?php include('edit-category-form.php'); ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h3><?php _e('Importers & Converters'); ?></h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="admin.php?import=wp-cat2tag"><?php _e('Selectively convert categories to tags'); ?></a></li>
|
||||
<li><a href="admin.php?import=utw"><?php _e('Import Ultimate Tag Warrior tags'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
|
@ -159,10 +159,6 @@ endforeach;
|
||||
<?php echo $form_pingback ?>
|
||||
<?php echo $form_prevstatus ?>
|
||||
|
||||
<fieldset id="tagdiv">
|
||||
<legend><?php _e('Tags (separate multiple tags with commas: cats, pet food, dogs)'); ?></legend>
|
||||
<div><input type="text" name="tags_input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></div>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
<span id="autosave"></span>
|
||||
|
@ -1,270 +0,0 @@
|
||||
<?php
|
||||
|
||||
class UTW_Import {
|
||||
|
||||
function header() {
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2>'.__('Import Ultimate Tag Warrior').'</h2>';
|
||||
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
|
||||
}
|
||||
|
||||
function footer() {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>';
|
||||
echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>';
|
||||
echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
|
||||
echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
|
||||
echo '<form action="admin.php?import=utw&step=1" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
function dispatch () {
|
||||
if ( empty( $_GET['step'] ) ) {
|
||||
$step = 0;
|
||||
} else {
|
||||
$step = (int) $_GET['step'];
|
||||
}
|
||||
|
||||
// load the header
|
||||
$this->header();
|
||||
|
||||
switch ( $step ) {
|
||||
case 0 :
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
$this->import_tags();
|
||||
break;
|
||||
case 2 :
|
||||
$this->import_posts();
|
||||
break;
|
||||
case 3:
|
||||
$this->import_t2p();
|
||||
break;
|
||||
case 4:
|
||||
$this->cleanup_import();
|
||||
break;
|
||||
}
|
||||
|
||||
// load the footer
|
||||
$this->footer();
|
||||
}
|
||||
|
||||
|
||||
function import_tags ( ) {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Reading UTW Tags…').'</h3></p>';
|
||||
|
||||
$tags = $this->get_utw_tags();
|
||||
|
||||
// if we didn't get any tags back, that's all there is folks!
|
||||
if ( !is_array($tags) ) {
|
||||
echo '<p>' . __('No Tags Found!') . '</p>';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
// if there's an existing entry, delete it
|
||||
if ( get_option('utwimp_tags') ) {
|
||||
delete_option('utwimp_tags');
|
||||
}
|
||||
|
||||
add_option('utwimp_tags', $tags);
|
||||
|
||||
|
||||
$count = count($tags);
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
|
||||
echo '<p>' . __('The following tags were found:') . '</p>';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
foreach ( $tags as $tag_id => $tag_name ) {
|
||||
|
||||
echo '<li>' . $tag_name . '</li>';
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<br />';
|
||||
|
||||
echo '<p>' . __('If you don’t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '</p>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=2" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
function import_posts ( ) {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Reading UTW Post Tags…').'</h3></p>';
|
||||
|
||||
// read in all the UTW tag -> post settings
|
||||
$posts = $this->get_utw_posts();
|
||||
|
||||
// if we didn't get any tags back, that's all there is folks!
|
||||
if ( !is_array($posts) ) {
|
||||
echo '<p>' . __('No posts were found to have tags!') . '</p>';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
// if there's an existing entry, delete it
|
||||
if ( get_option('utwimp_posts') ) {
|
||||
delete_option('utwimp_posts');
|
||||
}
|
||||
|
||||
add_option('utwimp_posts', $posts);
|
||||
|
||||
|
||||
$count = count($posts);
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
|
||||
|
||||
}
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=3" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function import_t2p ( ) {
|
||||
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Adding Tags to Posts…').'</h3></p>';
|
||||
|
||||
// run that funky magic!
|
||||
$tags_added = $this->tag2post();
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=4" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_utw_tags ( ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// read in all the tags from the UTW tags table: should be wp_tags
|
||||
$tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags";
|
||||
|
||||
$tags = $wpdb->get_results($tags_query);
|
||||
|
||||
// rearrange these tags into something we can actually use
|
||||
foreach ( $tags as $tag ) {
|
||||
|
||||
$new_tags[$tag->tag_id] = $tag->tag;
|
||||
|
||||
}
|
||||
|
||||
return $new_tags;
|
||||
|
||||
}
|
||||
|
||||
function get_utw_posts ( ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// read in all the posts from the UTW post->tag table: should be wp_post2tag
|
||||
$posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag";
|
||||
|
||||
$posts = $wpdb->get_results($posts_query);
|
||||
|
||||
return $posts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function tag2post ( ) {
|
||||
|
||||
// get the tags and posts we imported in the last 2 steps
|
||||
$tags = get_option('utwimp_tags');
|
||||
$posts = get_option('utwimp_posts');
|
||||
|
||||
// null out our results
|
||||
$tags_added = 0;
|
||||
|
||||
// loop through each post and add its tags to the db
|
||||
foreach ( $posts as $this_post ) {
|
||||
|
||||
$the_post = (int) $this_post->post_id;
|
||||
$the_tag = (int) $this_post->tag_id;
|
||||
|
||||
// what's the tag name for that id?
|
||||
$the_tag = $tags[$the_tag];
|
||||
|
||||
// screw it, just try to add the tag
|
||||
wp_add_post_tags($the_post, $the_tag);
|
||||
|
||||
$tags_added++;
|
||||
|
||||
}
|
||||
|
||||
// that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
|
||||
return $tags_added;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function cleanup_import ( ) {
|
||||
|
||||
delete_option('utwimp_tags');
|
||||
delete_option('utwimp_posts');
|
||||
|
||||
$this->done();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function done ( ) {
|
||||
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Import Complete!').'</h3></p>';
|
||||
|
||||
echo '<p>' . __('OK, so we lied about this being a 5-step program! You’re done!') . '</p>';
|
||||
|
||||
echo '<p>' . __('Now wasn’t that easy?') . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function UTW_Import ( ) {
|
||||
|
||||
// Nothing.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create the import object
|
||||
$utw_import = new UTW_Import();
|
||||
|
||||
// add it to the import page!
|
||||
register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch'));
|
||||
|
||||
?>
|
@ -1,226 +0,0 @@
|
||||
<?php
|
||||
|
||||
class WP_Categories_to_Tags {
|
||||
var $categories_to_convert = array();
|
||||
var $all_categories = array();
|
||||
|
||||
function header() {
|
||||
print '<div class="wrap">';
|
||||
print '<h2>' . __('Convert Categories to Tags') . '</h2>';
|
||||
}
|
||||
|
||||
function footer() {
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function populate_all_categories() {
|
||||
global $wpdb;
|
||||
|
||||
$this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC");
|
||||
}
|
||||
|
||||
function welcome() {
|
||||
$this->populate_all_categories();
|
||||
|
||||
print '<div class="narrow">';
|
||||
|
||||
if (count($this->all_categories) > 0) {
|
||||
print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>';
|
||||
print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>';
|
||||
|
||||
$this->categories_form();
|
||||
} else {
|
||||
print '<p>'.__('You have no categories to convert!').'</p>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function categories_form() {
|
||||
print '<form action="admin.php?import=wp-cat2tag&step=2" method="post">';
|
||||
print '<ul style="list-style:none">';
|
||||
|
||||
$hier = _get_category_hierarchy();
|
||||
|
||||
foreach ($this->all_categories as $category) {
|
||||
if ((int) $category->category_parent == 0) {
|
||||
print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->cat_ID) . '" /> ' . $category->cat_name . ' (' . $category->category_count . ')</label>';
|
||||
|
||||
if (isset($hier[$category->cat_ID])) {
|
||||
$this->_category_children($category, $hier);
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
|
||||
print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert »') . '" /></p>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
function _category_children($parent, $hier) {
|
||||
print '<ul style="list-style:none">';
|
||||
|
||||
foreach ($hier[$parent->cat_ID] as $child_id) {
|
||||
$child =& get_category($child_id);
|
||||
|
||||
print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->cat_ID) . '" /> ' . $child->cat_name . ' (' . $child->category_count . ')</label>';
|
||||
|
||||
if (isset($hier[$child->cat_ID])) {
|
||||
$this->_category_children($child, $hier);
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
}
|
||||
|
||||
function _category_exists($cat_id) {
|
||||
global $wpdb;
|
||||
|
||||
$cat_id = (int) $cat_id;
|
||||
|
||||
$maybe_exists = $wpdb->get_results("SELECT cat_ID from $wpdb->categories WHERE cat_ID = '$cat_id'");
|
||||
|
||||
if (count($maybe_exists) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function convert_them() {
|
||||
global $wpdb;
|
||||
|
||||
if (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) {
|
||||
print '<div class="narrow">';
|
||||
print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$this->categories_to_convert = $_POST['cats_to_convert'];
|
||||
$hier = _get_category_hierarchy();
|
||||
|
||||
print '<ul>';
|
||||
|
||||
foreach ($this->categories_to_convert as $cat_id) {
|
||||
$cat_id = (int) $cat_id;
|
||||
|
||||
print '<li>' . __('Converting category') . ' #' . $cat_id . '... ';
|
||||
|
||||
if (!$this->_category_exists($cat_id)) {
|
||||
_e('Category doesn\'t exist!');
|
||||
} else {
|
||||
$category =& get_category($cat_id);
|
||||
|
||||
if ($category->link_count > 0) {
|
||||
$type = $category->type | TAXONOMY_TAG;
|
||||
} else {
|
||||
$type = TAXONOMY_TAG;
|
||||
}
|
||||
|
||||
// Set the category itself to $type from above
|
||||
$wpdb->query("UPDATE $wpdb->categories SET type = '$type' WHERE cat_ID = '{$category->cat_ID}'");
|
||||
|
||||
// Set relationships in post2cat to 'tag', category_count becomes tag_count
|
||||
$wpdb->query("UPDATE $wpdb->post2cat SET rel_type = 'tag' WHERE category_ID = '{$category->cat_ID}'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET tag_count = '{$category->category_count}', category_count = '0' WHERE cat_ID = '{$category->cat_ID}'");
|
||||
|
||||
// Set all parents to 0 (root-level) if their parent was the converted tag
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_parent = 0 WHERE category_parent = '{$category->cat_ID}'");
|
||||
|
||||
// Clean the cache
|
||||
clean_category_cache($category->cat_ID);
|
||||
|
||||
_e('Converted successfully.');
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
}
|
||||
|
||||
function convert_all_confirm() {
|
||||
print '<div class="narrow">';
|
||||
|
||||
print '<h3>' . __('Confirm') . '</h3>';
|
||||
|
||||
print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>';
|
||||
|
||||
print '<form action="admin.php?import=wp-cat2tag" method="post">';
|
||||
print '<p style="text-align:center" class="submit"><input type="submit" value="' . __('Yes') . '" name="yes_convert_all_cats" /> <input type="submit" value="' . __('No') . '" name="no_dont_do_it" /></p>';
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function convert_all() {
|
||||
global $wpdb;
|
||||
|
||||
$cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0");
|
||||
|
||||
$_POST['cats_to_convert'] = array();
|
||||
|
||||
foreach ($cats as $cat) {
|
||||
$_POST['cats_to_convert'][] = $cat->cat_ID;
|
||||
}
|
||||
|
||||
$this->convert_them();
|
||||
}
|
||||
|
||||
function init() {
|
||||
echo '<!--'; print_r($_POST); print_r($_GET); echo '-->';
|
||||
|
||||
if (isset($_POST['maybe_convert_all_cats'])) {
|
||||
$step = 3;
|
||||
} elseif (isset($_POST['yes_convert_all_cats'])) {
|
||||
$step = 4;
|
||||
} elseif (isset($_POST['no_dont_do_it'])) {
|
||||
die('no_dont_do_it');
|
||||
} else {
|
||||
$step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
|
||||
}
|
||||
|
||||
$this->header();
|
||||
|
||||
if (!current_user_can('manage_categories')) {
|
||||
print '<div class="narrow">';
|
||||
print '<p>' . __('Cheatin’ uh?') . '</p>';
|
||||
print '</div>';
|
||||
} else {
|
||||
switch ($step) {
|
||||
case 1 :
|
||||
$this->welcome();
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
$this->convert_them();
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
$this->convert_all_confirm();
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
$this->convert_all();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->footer();
|
||||
}
|
||||
|
||||
function WP_Categories_to_Tags() {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
$wp_cat2tag_importer = new WP_Categories_to_Tags();
|
||||
|
||||
register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init'));
|
||||
|
||||
?>
|
@ -73,18 +73,10 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
|
||||
$category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
|
||||
$wp_rewrite->set_category_base($category_base);
|
||||
}
|
||||
|
||||
if ( isset($_POST['tag_base']) ) {
|
||||
$tag_base = $_POST['tag_base'];
|
||||
if (! empty($tag_base) )
|
||||
$tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
|
||||
$wp_rewrite->set_tag_base($tag_base);
|
||||
}
|
||||
}
|
||||
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
$category_base = get_option('category_base');
|
||||
$tag_base = get_option( 'tag_base' );
|
||||
|
||||
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
|
||||
$writable = true;
|
||||
@ -167,9 +159,6 @@ checked="checked"
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
<?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo attribute_escape($category_base); ?>" size="30" />
|
||||
</p>
|
||||
<p>
|
||||
<?php _e('Tag base'); ?>: <input name="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" />
|
||||
</p>
|
||||
<p class="submit">
|
||||
<input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" />
|
||||
|
@ -18,10 +18,8 @@ $wp_queries="CREATE TABLE $wpdb->categories (
|
||||
category_parent bigint(20) NOT NULL default '0',
|
||||
category_count bigint(20) NOT NULL default '0',
|
||||
link_count bigint(20) NOT NULL default '0',
|
||||
tag_count bigint(20) NOT NULL default '0',
|
||||
posts_private tinyint(1) NOT NULL default '0',
|
||||
links_private tinyint(1) NOT NULL default '0',
|
||||
type tinyint NOT NULL default '1',
|
||||
PRIMARY KEY (cat_ID),
|
||||
KEY category_nicename (category_nicename)
|
||||
) $charset_collate;
|
||||
@ -90,7 +88,6 @@ CREATE TABLE $wpdb->post2cat (
|
||||
rel_id bigint(20) NOT NULL auto_increment,
|
||||
post_id bigint(20) NOT NULL default '0',
|
||||
category_id bigint(20) NOT NULL default '0',
|
||||
rel_type varchar(64) NOT NULL default 'category',
|
||||
PRIMARY KEY (rel_id),
|
||||
KEY post_id (post_id,category_id)
|
||||
) $charset_collate;
|
||||
@ -243,9 +240,6 @@ function populate_options() {
|
||||
add_option('default_link_category', 2);
|
||||
add_option('show_on_front', 'posts');
|
||||
|
||||
// 2.2
|
||||
add_option('tag_base');
|
||||
|
||||
// Delete unused options
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
|
||||
foreach ($unusedoptions as $option) :
|
||||
|
@ -538,7 +538,7 @@ input.disabled, textarea.disabled {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#postdiv, #titlediv, #guiddiv, #tagdiv {
|
||||
#postdiv, #titlediv, #guiddiv {
|
||||
margin: 0 8px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
@ -558,7 +558,7 @@ input.disabled, textarea.disabled {
|
||||
line-height: 140%;
|
||||
}
|
||||
|
||||
#titlediv input, #guiddiv input, #tagdiv input {
|
||||
#titlediv input, #guiddiv input {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ get_header();
|
||||
|
||||
<div class="post" id="post-<?php the_ID(); ?>">
|
||||
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
|
||||
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
|
||||
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
|
||||
|
||||
<div class="storycontent">
|
||||
<?php the_content(__('(more...)')); ?>
|
||||
|
@ -1,25 +1,29 @@
|
||||
<?php get_header(); ?>
|
||||
|
||||
<div id="content" class="narrowcolumn">
|
||||
<?php is_tag(); ?>
|
||||
|
||||
<?php if (have_posts()) : ?>
|
||||
|
||||
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
|
||||
<?php /* If this is a category archive */ if (is_category()) { ?>
|
||||
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
|
||||
<?php /* If this is a category archive */ if (is_category()) { ?>
|
||||
<h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
|
||||
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
|
||||
<h2 class="pagetitle">Posts Tagged ‘<?php single_cat_title(); ?>’</h2>
|
||||
|
||||
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
|
||||
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
|
||||
|
||||
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
|
||||
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
|
||||
|
||||
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
|
||||
|
||||
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
|
||||
<h2 class="pagetitle">Author Archive</h2>
|
||||
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
|
||||
|
||||
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
|
||||
<h2 class="pagetitle">Blog Archives</h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<div class="navigation">
|
||||
@ -36,7 +40,7 @@
|
||||
<?php the_content() ?>
|
||||
</div>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<?php the_content('Read the rest of this entry »'); ?>
|
||||
</div>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
</div>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
|
||||
<small><?php the_time('l, F jS, Y') ?></small>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
</div>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
@ -16,7 +16,6 @@
|
||||
<?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
|
||||
|
||||
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
|
||||
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
|
||||
|
||||
<p class="postmetadata alt">
|
||||
<small>
|
||||
|
@ -272,90 +272,6 @@ function wp_list_categories($args = '') {
|
||||
echo apply_filters('wp_list_categories', $output);
|
||||
}
|
||||
|
||||
function wp_tag_cloud( $args = '' ) {
|
||||
$defaults = array(
|
||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
|
||||
'exclude' => '', 'include' => ''
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags
|
||||
|
||||
if ( empty($tags) )
|
||||
return;
|
||||
|
||||
$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
|
||||
echo apply_filters( 'wp_tag_cloud', $return, $args );
|
||||
}
|
||||
|
||||
// $tags = prefetched tag array ( get_tags() )
|
||||
// $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array()
|
||||
// $args['orderby'] = 'name', 'count'
|
||||
function wp_generate_tag_cloud( $tags, $args = '' ) {
|
||||
global $wp_rewrite;
|
||||
$defaults = array(
|
||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
extract($args);
|
||||
|
||||
if ( !$tags )
|
||||
return;
|
||||
$counts = $tag_links = array();
|
||||
foreach ( (array) $tags as $tag ) {
|
||||
$counts[$tag->cat_name] = $tag->tag_count;
|
||||
$tag_links[$tag->cat_name] = get_tag_link( $tag->cat_ID );
|
||||
}
|
||||
|
||||
$min_count = min($counts);
|
||||
$spread = max($counts) - $min_count;
|
||||
if ( $spread <= 0 )
|
||||
$spread = 1;
|
||||
$font_spread = $largest - $smallest;
|
||||
if ( $font_spread <= 0 )
|
||||
$font_spread = 1;
|
||||
$font_step = $font_spread / $spread;
|
||||
|
||||
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
|
||||
if ( 'name' == $orderby )
|
||||
uksort($counts, 'strnatcasecmp');
|
||||
else
|
||||
asort($counts);
|
||||
|
||||
if ( 'DESC' == $order )
|
||||
$counts = array_reverse( $tag_counts, true );
|
||||
|
||||
$a = array();
|
||||
|
||||
$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
|
||||
|
||||
foreach ( $counts as $tag => $count ) {
|
||||
$tag_link = clean_url($tag_links[$tag]);
|
||||
$tag = str_replace(' ', ' ', wp_specialchars( $tag ));
|
||||
$a[] = "<a href='$tag_link' title='" . attribute_escape( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " .
|
||||
( $smallest + ( ( $count - $min_count ) * $font_step ) )
|
||||
. "$unit;'>$tag</a>";
|
||||
}
|
||||
|
||||
switch ( $format ) :
|
||||
case 'array' :
|
||||
$return =& $a;
|
||||
break;
|
||||
case 'list' :
|
||||
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
|
||||
$return .= join("</li>\n\t<li>", $a);
|
||||
$return .= "</li>\n</ul>\n";
|
||||
break;
|
||||
default :
|
||||
$return = join("\n", $a);
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
|
||||
}
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
@ -372,63 +288,4 @@ function walk_category_dropdown_tree() {
|
||||
return call_user_func_array(array(&$walker, 'walk'), $args);
|
||||
}
|
||||
|
||||
//
|
||||
// Tags
|
||||
//
|
||||
|
||||
function get_tag_link( $tag_id ) {
|
||||
global $wp_rewrite;
|
||||
$catlink = $wp_rewrite->get_tag_permastruct();
|
||||
|
||||
$category = &get_category($tag_id);
|
||||
$category_nicename = $category->category_nicename;
|
||||
|
||||
if ( empty($catlink) ) {
|
||||
$file = get_option('home') . '/';
|
||||
$catlink = $file . '?tag=' . $category_nicename;
|
||||
} else {
|
||||
|
||||
$catlink = str_replace('%tag%', $category_nicename, $catlink);
|
||||
$catlink = get_option('home') . user_trailingslashit($catlink, 'category');
|
||||
}
|
||||
return apply_filters('tag_link', $catlink, $tag_id);
|
||||
}
|
||||
|
||||
function get_the_tags( $id = 0 ) {
|
||||
global $post;
|
||||
|
||||
$id = (int) $id;
|
||||
|
||||
if ( ! $id && ! in_the_loop() )
|
||||
return false; // in-the-loop function
|
||||
|
||||
if ( !$id )
|
||||
$id = (int) $post->ID;
|
||||
|
||||
$tags = wp_get_post_tags( $id );
|
||||
$tags = apply_filters( 'get_the_tags', $tags );
|
||||
if ( empty( $tags ) )
|
||||
return false;
|
||||
return $tags;
|
||||
}
|
||||
|
||||
function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
|
||||
$tags = get_the_tags();
|
||||
|
||||
if ( empty( $tags ) )
|
||||
return false;
|
||||
|
||||
$tag_list = $before;
|
||||
foreach ( $tags as $tag )
|
||||
$tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>';
|
||||
|
||||
$tag_links = join( $sep, $tag_links );
|
||||
$tag_links = apply_filters( 'the_tags', $tag_links );
|
||||
$tag_list .= $tag_links;
|
||||
|
||||
$tag_list .= $after;
|
||||
|
||||
echo $tag_list;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
define('TAXONOMY_CATEGORY', 1);
|
||||
define('TAXONOMY_TAG', 2);
|
||||
|
||||
function get_all_category_ids() {
|
||||
global $wpdb;
|
||||
|
||||
@ -80,12 +77,8 @@ function &get_categories($args = '') {
|
||||
$where .= ' AND link_count > 0';
|
||||
else
|
||||
$where .= ' AND category_count > 0';
|
||||
} else {
|
||||
$where .= ' AND ( type & ' . TAXONOMY_CATEGORY . ' != 0 ) ';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !empty($number) )
|
||||
$number = 'LIMIT ' . $number;
|
||||
else
|
||||
@ -213,15 +206,6 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function get_category_by_slug( $slug ) {
|
||||
global $wpdb;
|
||||
$slug = sanitize_title( $slug );
|
||||
if ( empty( $slug ) )
|
||||
return false;
|
||||
$category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );
|
||||
return get_category( $category );
|
||||
}
|
||||
|
||||
// Get the ID of a category from its name
|
||||
function get_cat_ID($cat_name='General') {
|
||||
global $wpdb;
|
||||
@ -344,86 +328,4 @@ function _get_category_hierarchy() {
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
// Tags
|
||||
|
||||
function &get_tags($args = '') {
|
||||
global $wpdb, $category_links;
|
||||
|
||||
$defaults = array('orderby' => 'name', 'order' => 'ASC',
|
||||
'hide_empty' => true, 'exclude' => '', 'include' => '',
|
||||
'number' => '');
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
if ( 'count' == $args['orderby'] )
|
||||
$args['orderby'] = 'tag_count';
|
||||
else
|
||||
$args['orderby'] = "cat_" . $args['orderby']; // restricts order by to cat_ID and cat_name fields
|
||||
$args['number'] = (int) $args['number'];
|
||||
extract($args);
|
||||
|
||||
$key = md5( serialize( $args ) );
|
||||
if ( $cache = wp_cache_get( 'get_tags', 'category' ) )
|
||||
if ( isset( $cache[ $key ] ) )
|
||||
return apply_filters('get_tags', $cache[$key], $args);
|
||||
|
||||
$where = 'cat_ID > 0';
|
||||
$inclusions = '';
|
||||
if ( !empty($include) ) {
|
||||
$child_of = 0; //ignore child_of and exclude params if using include
|
||||
$exclude = '';
|
||||
$incategories = preg_split('/[\s,]+/',$include);
|
||||
if ( count($incategories) ) {
|
||||
foreach ( $incategories as $incat ) {
|
||||
if (empty($inclusions))
|
||||
$inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
|
||||
else
|
||||
$inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($inclusions))
|
||||
$inclusions .= ')';
|
||||
$where .= $inclusions;
|
||||
|
||||
$exclusions = '';
|
||||
if ( !empty($exclude) ) {
|
||||
$excategories = preg_split('/[\s,]+/',$exclude);
|
||||
if ( count($excategories) ) {
|
||||
foreach ( $excategories as $excat ) {
|
||||
if (empty($exclusions))
|
||||
$exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
|
||||
else
|
||||
$exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($exclusions))
|
||||
$exclusions .= ')';
|
||||
$exclusions = apply_filters('list_tags_exclusions', $exclusions, $args );
|
||||
$where .= $exclusions;
|
||||
|
||||
if ( $hide_empty )
|
||||
$where .= ' AND tag_count > 0';
|
||||
|
||||
$where .= ' AND ( type & ' . TAXONOMY_TAG . ' != 0 ) ';
|
||||
|
||||
if ( !empty($number) )
|
||||
$number = 'LIMIT ' . $number;
|
||||
else
|
||||
$number = '';
|
||||
|
||||
$tags = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number");
|
||||
|
||||
if ( empty($tags) )
|
||||
return array();
|
||||
|
||||
$cache[ $key ] = $tags;
|
||||
wp_cache_set( 'get_tags', $cache, 'category' );
|
||||
|
||||
$tags = apply_filters('get_tags', $tags, $args);
|
||||
return $tags;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class WP {
|
||||
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
|
||||
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
|
||||
|
||||
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
|
||||
var $extra_query_vars = array();
|
||||
|
@ -602,7 +602,7 @@ function update_post_cache(&$posts) {
|
||||
}
|
||||
|
||||
function clean_post_cache($id) {
|
||||
global $post_cache, $post_meta_cache, $category_cache, $tag_cache, $blog_id;
|
||||
global $post_cache, $post_meta_cache, $category_cache, $blog_id;
|
||||
|
||||
if ( isset( $post_cache[$blog_id][$id] ) )
|
||||
unset( $post_cache[$blog_id][$id] );
|
||||
@ -612,9 +612,6 @@ function clean_post_cache($id) {
|
||||
|
||||
if ( isset( $category_cache[$blog_id][$id]) )
|
||||
unset ( $category_cache[$blog_id][$id] );
|
||||
|
||||
if ( isset( $tag_cache[$blog_id][$id]) )
|
||||
unset ( $tag_cache[$blog_id][$id] );
|
||||
}
|
||||
|
||||
function update_page_cache(&$pages) {
|
||||
@ -641,7 +638,7 @@ function clean_page_cache($id) {
|
||||
}
|
||||
|
||||
function update_post_category_cache($post_ids) {
|
||||
global $wpdb, $category_cache, $tag_cache, $blog_id;
|
||||
global $wpdb, $category_cache, $blog_id;
|
||||
|
||||
if ( empty($post_ids) )
|
||||
return;
|
||||
@ -662,21 +659,17 @@ function update_post_category_cache($post_ids) {
|
||||
return;
|
||||
$post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
|
||||
|
||||
$dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
|
||||
$dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
|
||||
|
||||
if ( empty($dogs) )
|
||||
return;
|
||||
|
||||
foreach ($dogs as $catt) {
|
||||
if ( 'category' == $catt->rel_type )
|
||||
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
elseif ( 'tag' == $catt->rel_type )
|
||||
$tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
}
|
||||
foreach ($dogs as $catt)
|
||||
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
}
|
||||
|
||||
function update_post_caches(&$posts) {
|
||||
global $post_cache, $category_cache, $post_meta_cache, $tag_cache;
|
||||
global $post_cache, $category_cache, $post_meta_cache;
|
||||
global $wpdb, $blog_id;
|
||||
|
||||
// No point in doing all this work if we didn't match any posts.
|
||||
@ -1475,22 +1468,4 @@ function smilies_init() {
|
||||
}
|
||||
}
|
||||
|
||||
function wp_parse_args( $args, $defaults = '' ) {
|
||||
if ( is_array($args) ) :
|
||||
$r =& $args;
|
||||
else :
|
||||
parse_str( $args, $r );
|
||||
if ( get_magic_quotes_gpc() )
|
||||
$r = stripslashes_deep( $r );
|
||||
endif;
|
||||
|
||||
if ( is_array($defaults) ) :
|
||||
extract($defaults);
|
||||
extract($r);
|
||||
return compact(array_keys($defaults)); // only those options defined in $defaults
|
||||
else :
|
||||
return $r;
|
||||
endif;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -59,7 +59,6 @@ function get_permalink($id = 0) {
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%',
|
||||
'%tag%',
|
||||
'%author%',
|
||||
'%pagename%'
|
||||
);
|
||||
|
@ -458,17 +458,6 @@ function wp_get_post_categories($post_id = 0) {
|
||||
return array_unique($cat_ids);
|
||||
}
|
||||
|
||||
function wp_get_post_tags( $post_id = 0 ) {
|
||||
global $tag_cache, $blog_id;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !isset( $tag_cache[$blog_id][$post_id] ) )
|
||||
update_post_category_cache( $post_id ); // loads $tag_cache
|
||||
|
||||
return $tag_cache[$blog_id][$post_id];
|
||||
}
|
||||
|
||||
function wp_get_recent_posts($num = 10) {
|
||||
global $wpdb;
|
||||
|
||||
@ -530,7 +519,6 @@ function wp_insert_post($postarr = array()) {
|
||||
$post_name = apply_filters('name_save_pre', $post_name);
|
||||
$comment_status = apply_filters('comment_status_pre', $comment_status);
|
||||
$ping_status = apply_filters('ping_status_pre', $ping_status);
|
||||
$tags_input = apply_filters('tags_input_pre', $tags_input);
|
||||
}
|
||||
|
||||
if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) )
|
||||
@ -665,8 +653,7 @@ function wp_insert_post($postarr = array()) {
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
|
||||
}
|
||||
|
||||
wp_set_post_categories( $post_ID, $post_category );
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
wp_set_post_categories($post_ID, $post_category);
|
||||
|
||||
if ( 'page' == $post_type ) {
|
||||
clean_page_cache($post_ID);
|
||||
@ -784,90 +771,6 @@ function wp_publish_post($post_id) {
|
||||
return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true));
|
||||
}
|
||||
|
||||
function wp_add_post_tags($post_id = 0, $tags = '') {
|
||||
return wp_set_post_tags($post_id, $tags, true);
|
||||
}
|
||||
|
||||
function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
/* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !$post_id )
|
||||
return false;
|
||||
|
||||
// prevent warnings for unintialized variables
|
||||
$tag_ids = array();
|
||||
|
||||
if ( empty($tags) )
|
||||
$tags = array();
|
||||
$tags = (is_array($tags)) ? $tags : explode( ',', $tags );
|
||||
|
||||
foreach ( $tags as $tag ) {
|
||||
$tag = trim( $tag );
|
||||
if ( !$tag_slug = sanitize_title( $tag ) )
|
||||
continue; // discard
|
||||
if ( !$tag_id = tag_exists( $tag ) )
|
||||
$tag_id = wp_create_tag( $tag );
|
||||
$tag_ids[] = $tag_id;
|
||||
}
|
||||
|
||||
if ( empty($tag_ids) && ( !empty($tags) || $append ) )
|
||||
return false;
|
||||
|
||||
$tag_ids = array_unique( $tag_ids );
|
||||
|
||||
// First the old tags
|
||||
$old_tags = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->post2cat
|
||||
WHERE post_id = '$post_id' AND rel_type = 'tag'");
|
||||
|
||||
if ( !$old_tags ) {
|
||||
$old_tags = array();
|
||||
} else {
|
||||
$old_tags = array_unique( $old_tags );
|
||||
}
|
||||
|
||||
// Delete any?
|
||||
$delete_tags = array_diff( $old_tags, $tag_ids);
|
||||
if ( $delete_tags && !$append ) {
|
||||
foreach ( $delete_tags as $del ) {
|
||||
$wpdb->query("
|
||||
DELETE FROM $wpdb->post2cat
|
||||
WHERE category_id = '$del'
|
||||
AND post_id = '$post_id'
|
||||
AND rel_type = 'tag'
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
// Add any?
|
||||
$add_tags = array_diff( $tag_ids, $old_tags );
|
||||
if ( $add_tags ) {
|
||||
foreach ( $add_tags as $new_tag ) {
|
||||
$new_tag = (int) $new_tag;
|
||||
if ( !empty($new_tag) )
|
||||
$wpdb->query("
|
||||
INSERT INTO $wpdb->post2cat (post_id, category_id, rel_type)
|
||||
VALUES ('$post_id', '$new_tag', 'tag')");
|
||||
}
|
||||
}
|
||||
|
||||
// Update category counts.
|
||||
$all_affected_tags = array_unique( array_merge( $tag_ids, $old_tags ) );
|
||||
foreach ( $all_affected_tags as $tag_id ) {
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$tag_id' AND rel_type = 'tag'" );
|
||||
$wpdb->query( "UPDATE $wpdb->categories SET tag_count = '$count', type = type | " . TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
|
||||
if ( $count == 0 )
|
||||
$wpdb->query( "UPDATE $wpdb->categories SET type = type & ~". TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
|
||||
clean_category_cache( $tag_id );
|
||||
do_action( 'edit_category', $tag_id );
|
||||
do_action( 'edit_tag', $tag_id );
|
||||
}
|
||||
}
|
||||
|
||||
function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
global $wpdb;
|
||||
|
||||
@ -882,7 +785,7 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
$old_categories = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->post2cat
|
||||
WHERE post_id = '$post_ID' AND rel_type = 'category'");
|
||||
WHERE post_id = '$post_ID'");
|
||||
|
||||
if (!$old_categories) {
|
||||
$old_categories = array();
|
||||
@ -898,7 +801,7 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
$wpdb->query("
|
||||
DELETE FROM $wpdb->post2cat
|
||||
WHERE category_id = '$del'
|
||||
AND post_id = '$post_ID' AND rel_type = 'category'
|
||||
AND post_id = '$post_ID'
|
||||
");
|
||||
}
|
||||
}
|
||||
@ -919,8 +822,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
// Update category counts.
|
||||
$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
|
||||
foreach ( $all_affected_cats as $cat_id ) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id' AND rel_type = 'category'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count', type = type | " . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_id'");
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
clean_category_cache($cat_id);
|
||||
do_action('edit_category', $cat_id);
|
||||
}
|
||||
|
@ -86,20 +86,6 @@ function is_category ($category = '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_tag( $slug = '' ) {
|
||||
global $wp_query;
|
||||
if ( !$wp_query->is_tag )
|
||||
return false;
|
||||
|
||||
if ( empty( $slug ) )
|
||||
return true;
|
||||
|
||||
$cat_obj = $wp_query->get_queried_object();
|
||||
if ( $category == $cat_obj->category_nicename )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_comments_popup () {
|
||||
global $wp_query;
|
||||
|
||||
@ -319,7 +305,6 @@ class WP_Query {
|
||||
var $is_time = false;
|
||||
var $is_author = false;
|
||||
var $is_category = false;
|
||||
var $is_tag = false;
|
||||
var $is_search = false;
|
||||
var $is_feed = false;
|
||||
var $is_comment_feed = false;
|
||||
@ -344,7 +329,6 @@ class WP_Query {
|
||||
$this->is_time = false;
|
||||
$this->is_author = false;
|
||||
$this->is_category = false;
|
||||
$this->is_tag = false;
|
||||
$this->is_search = false;
|
||||
$this->is_feed = false;
|
||||
$this->is_comment_feed = false;
|
||||
@ -399,7 +383,6 @@ class WP_Query {
|
||||
, 'year'
|
||||
, 'w'
|
||||
, 'category_name'
|
||||
, 'tag'
|
||||
, 'author_name'
|
||||
, 'feed'
|
||||
, 'tb'
|
||||
@ -548,9 +531,6 @@ class WP_Query {
|
||||
$this->is_category = true;
|
||||
}
|
||||
|
||||
if ( '' != $qv['tag'] )
|
||||
$this->is_tag = true;
|
||||
|
||||
if ( empty($qv['author']) || ($qv['author'] == '0') ) {
|
||||
$this->is_author = false;
|
||||
} else {
|
||||
@ -561,7 +541,7 @@ class WP_Query {
|
||||
$this->is_author = true;
|
||||
}
|
||||
|
||||
if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) )
|
||||
if ( ($this->is_date || $this->is_author || $this->is_category) )
|
||||
$this->is_archive = true;
|
||||
}
|
||||
|
||||
@ -857,7 +837,7 @@ class WP_Query {
|
||||
$in_cats = substr($in_cats, 0, -2);
|
||||
$out_cats = substr($out_cats, 0, -2);
|
||||
if ( strlen($in_cats) > 0 )
|
||||
$in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats) AND rel_type = 'category' ";
|
||||
$in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats)";
|
||||
if ( strlen($out_cats) > 0 ) {
|
||||
$ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE $wpdb->post2cat.category_id IN ($out_cats)");
|
||||
if ( is_array($ids) && count($ids > 0) ) {
|
||||
@ -874,21 +854,6 @@ class WP_Query {
|
||||
$groupby = "{$wpdb->posts}.ID";
|
||||
}
|
||||
|
||||
if ( '' != $q['tag'] ) {
|
||||
$reqcat= get_category_by_slug( $q['tag'] );
|
||||
if ( !empty($reqcat) )
|
||||
$reqcat = $reqcat->cat_ID;
|
||||
else
|
||||
$reqcat = 0;
|
||||
|
||||
$q['cat'] = $reqcat;
|
||||
|
||||
$tables = ", $wpdb->post2cat, $wpdb->categories";
|
||||
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
|
||||
$whichcat = " AND category_id IN ({$q['cat']}) AND rel_type = 'tag' ";
|
||||
$groupby = "{$wpdb->posts}.ID";
|
||||
}
|
||||
|
||||
// Category stuff for nice URLs
|
||||
if ( '' != $q['category_name'] ) {
|
||||
$reqcat = get_category_by_path($q['category_name']);
|
||||
|
@ -46,12 +46,11 @@ define('EP_ROOT', 64 );
|
||||
define('EP_COMMENTS', 128 );
|
||||
define('EP_SEARCH', 256 );
|
||||
define('EP_CATEGORIES', 512 );
|
||||
define('EP_TAGS', 1024 );
|
||||
define('EP_AUTHORS', 2048);
|
||||
define('EP_PAGES', 4096);
|
||||
define('EP_AUTHORS', 1024);
|
||||
define('EP_PAGES', 2048);
|
||||
//pseudo-places
|
||||
define('EP_NONE', 0 );
|
||||
define('EP_ALL', 8191);
|
||||
define('EP_ALL', 4095);
|
||||
|
||||
//and an endpoint, like /trackback/
|
||||
function add_rewrite_endpoint($name, $places) {
|
||||
@ -153,9 +152,7 @@ class WP_Rewrite {
|
||||
var $permalink_structure;
|
||||
var $use_trailing_slashes;
|
||||
var $category_base;
|
||||
var $tag_base;
|
||||
var $category_structure;
|
||||
var $tag_structure;
|
||||
var $author_base = 'author';
|
||||
var $author_structure;
|
||||
var $date_structure;
|
||||
@ -186,7 +183,6 @@ class WP_Rewrite {
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%',
|
||||
'%tag%',
|
||||
'%author%',
|
||||
'%pagename%',
|
||||
'%search%'
|
||||
@ -203,7 +199,6 @@ class WP_Rewrite {
|
||||
'([^/]+)',
|
||||
'([0-9]+)',
|
||||
'(.+?)',
|
||||
'(.+?)',
|
||||
'([^/]+)',
|
||||
'([^/]+)',
|
||||
'(.+)'
|
||||
@ -220,7 +215,6 @@ class WP_Rewrite {
|
||||
'name=',
|
||||
'p=',
|
||||
'category_name=',
|
||||
'tag=',
|
||||
'author_name=',
|
||||
'pagename=',
|
||||
's='
|
||||
@ -386,26 +380,6 @@ class WP_Rewrite {
|
||||
return $this->category_structure;
|
||||
}
|
||||
|
||||
function get_tag_permastruct() {
|
||||
if (isset($this->tag_structure)) {
|
||||
return $this->tag_structure;
|
||||
}
|
||||
|
||||
if (empty($this->permalink_structure)) {
|
||||
$this->tag_structure = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->tag_base))
|
||||
$this->tag_structure = $this->front . 'tag/';
|
||||
else
|
||||
$this->tag_structure = $this->tag_base . '/';
|
||||
|
||||
$this->tag_structure .= '%tag%';
|
||||
|
||||
return $this->tag_structure;
|
||||
}
|
||||
|
||||
function get_author_permastruct() {
|
||||
if (isset($this->author_structure)) {
|
||||
return $this->author_structure;
|
||||
@ -762,10 +736,6 @@ class WP_Rewrite {
|
||||
$category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
|
||||
$category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
|
||||
|
||||
// Tags
|
||||
$tag_rewrite = $this->generate_rewrite_rules($this->get_tag_permastruct(), EP_TAGS);
|
||||
$tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite);
|
||||
|
||||
// Authors
|
||||
$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
|
||||
$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
|
||||
@ -775,7 +745,7 @@ class WP_Rewrite {
|
||||
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
|
||||
|
||||
// Put them together.
|
||||
$this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
|
||||
$this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
|
||||
|
||||
do_action_ref_array('generate_rewrite_rules', array(&$this));
|
||||
$this->rules = apply_filters('rewrite_rules_array', $this->rules);
|
||||
@ -901,8 +871,7 @@ class WP_Rewrite {
|
||||
if ($this->using_index_permalinks()) {
|
||||
$this->root = $this->index . '/';
|
||||
}
|
||||
$this->category_base = get_option( 'category_base' );
|
||||
$this->tag_base = get_option( 'tag_base' );
|
||||
$this->category_base = get_option('category_base');
|
||||
unset($this->category_structure);
|
||||
unset($this->author_structure);
|
||||
unset($this->date_structure);
|
||||
@ -927,13 +896,6 @@ class WP_Rewrite {
|
||||
}
|
||||
}
|
||||
|
||||
function set_tag_base( $tag_base ) {
|
||||
if ( $tag_base != $this->tag_base ) {
|
||||
update_option( 'tag_base', $tag_base );
|
||||
$this->init();
|
||||
}
|
||||
}
|
||||
|
||||
function WP_Rewrite() {
|
||||
$this->init();
|
||||
}
|
||||
|
@ -35,9 +35,6 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
|
||||
} else if ( is_category() && $template = get_category_template()) {
|
||||
include($template);
|
||||
return;
|
||||
} else if ( is_tag() && $template = get_tag_template()) {
|
||||
include($template);
|
||||
return;
|
||||
} else if ( is_author() && $template = get_author_template() ) {
|
||||
include($template);
|
||||
return;
|
||||
|
@ -328,17 +328,6 @@ function get_category_template() {
|
||||
return apply_filters('category_template', $template);
|
||||
}
|
||||
|
||||
function get_tag_template() {
|
||||
$template = '';
|
||||
if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
|
||||
$template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php';
|
||||
elseif ( file_exists(TEMPLATEPATH . "/tag.php") )
|
||||
$template = TEMPLATEPATH . "/tag.php";
|
||||
|
||||
return apply_filters('tag_template', $template);
|
||||
}
|
||||
|
||||
|
||||
function get_date_template() {
|
||||
return get_query_template('date');
|
||||
}
|
||||
|
@ -1554,7 +1554,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$categories_struct = array();
|
||||
|
||||
// FIXME: can we avoid using direct SQL there?
|
||||
if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories WHERE (type & " . TAXONOMY_CATEGORY . " != 0)", ARRAY_A)) {
|
||||
if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
|
||||
foreach ($cats as $cat) {
|
||||
$struct['categoryId'] = $cat['cat_ID'];
|
||||
$struct['categoryName'] = $cat['cat_name'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user