mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-20 04:43:21 +02:00
git-svn-id: http://svn.automattic.com/wordpress/trunk@8930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
239 lines
5.5 KiB
PHP
239 lines
5.5 KiB
PHP
<?php
|
|
/**
|
|
* Edit Tags Administration Panel.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Administration
|
|
*/
|
|
|
|
/** WordPress Administration Bootstrap */
|
|
require_once('admin.php');
|
|
|
|
$title = __('Tags');
|
|
|
|
wp_reset_vars(array('action', 'tag'));
|
|
|
|
if ( $_GET['action'] == 'delete' && isset($_GET['delete_tags']) )
|
|
$action = 'bulk-delete';
|
|
|
|
switch($action) {
|
|
|
|
case 'addtag':
|
|
|
|
check_admin_referer('add-tag');
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
wp_die(__('Cheatin’ uh?'));
|
|
|
|
$ret = wp_insert_term($_POST['name'], 'post_tag', $_POST);
|
|
if ( $ret && !is_wp_error( $ret ) ) {
|
|
wp_redirect('edit-tags.php?message=1#addtag');
|
|
} else {
|
|
wp_redirect('edit-tags.php?message=4#addtag');
|
|
}
|
|
exit;
|
|
break;
|
|
|
|
case 'delete':
|
|
$tag_ID = (int) $_GET['tag_ID'];
|
|
check_admin_referer('delete-tag_' . $tag_ID);
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
wp_die(__('Cheatin’ uh?'));
|
|
|
|
wp_delete_term( $tag_ID, 'post_tag');
|
|
|
|
wp_redirect('edit-tags.php?message=2');
|
|
exit;
|
|
|
|
break;
|
|
|
|
case 'bulk-delete':
|
|
check_admin_referer('bulk-tags');
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
wp_die(__('Cheatin’ uh?'));
|
|
|
|
$tags = $_GET['delete_tags'];
|
|
foreach( (array) $tags as $tag_ID ) {
|
|
wp_delete_term( $tag_ID, 'post_tag');
|
|
}
|
|
|
|
$location = 'edit-tags.php';
|
|
if ( $referer = wp_get_referer() ) {
|
|
if ( false !== strpos($referer, 'edit-tags.php') )
|
|
$location = $referer;
|
|
}
|
|
|
|
$location = add_query_arg('message', 6, $location);
|
|
wp_redirect($location);
|
|
exit;
|
|
|
|
break;
|
|
|
|
case 'edit':
|
|
|
|
require_once ('admin-header.php');
|
|
$tag_ID = (int) $_GET['tag_ID'];
|
|
|
|
$tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit');
|
|
include('edit-tag-form.php');
|
|
|
|
break;
|
|
|
|
case 'editedtag':
|
|
$tag_ID = (int) $_POST['tag_ID'];
|
|
check_admin_referer('update-tag_' . $tag_ID);
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
wp_die(__('Cheatin’ uh?'));
|
|
|
|
$ret = wp_update_term($tag_ID, 'post_tag', $_POST);
|
|
|
|
$location = 'edit-tags.php';
|
|
if ( $referer = wp_get_original_referer() ) {
|
|
if ( false !== strpos($referer, 'edit-tags.php') )
|
|
$location = $referer;
|
|
}
|
|
|
|
if ( $ret && !is_wp_error( $ret ) )
|
|
$location = add_query_arg('message', 3, $location);
|
|
else
|
|
$location = add_query_arg('message', 5, $location);
|
|
|
|
wp_redirect($location);
|
|
exit;
|
|
break;
|
|
|
|
default:
|
|
|
|
if ( !empty($_GET['_wp_http_referer']) ) {
|
|
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
|
|
exit;
|
|
}
|
|
|
|
wp_enqueue_script( 'admin-tags' );
|
|
wp_enqueue_script('admin-forms');
|
|
|
|
require_once ('admin-header.php');
|
|
|
|
$messages[1] = __('Tag added.');
|
|
$messages[2] = __('Tag deleted.');
|
|
$messages[3] = __('Tag updated.');
|
|
$messages[4] = __('Tag not added.');
|
|
$messages[5] = __('Tag not updated.');
|
|
$messages[6] = __('Tags deleted.');
|
|
?>
|
|
|
|
<form class="search-form" action="" method="get">
|
|
<p id="tag-search" class="search-box">
|
|
<label class="hidden" for="tag-search-input"><?php _e( 'Search Tags' ); ?></label>
|
|
<input type="text" id="tag-search-input" class="search-input" name="s" value="<?php the_search_query(); ?>" />
|
|
<input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" />
|
|
</p>
|
|
</form>
|
|
|
|
<?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
|
|
<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
|
|
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
|
endif; ?>
|
|
|
|
<div class="wrap">
|
|
|
|
<form id="posts-filter" action="" method="get">
|
|
|
|
<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Advanced Options') ?></a>
|
|
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></a></div>
|
|
|
|
<div id="edit-settings" class="hide-if-js hide-if-no-js">
|
|
<div id="edit-settings-wrap">
|
|
<h5><?php _e('Show on screen') ?></h5>
|
|
<div class="metabox-prefs">
|
|
<?php manage_columns_prefs('tag') ?>
|
|
<br class="clear" />
|
|
</div></div>
|
|
</div>
|
|
|
|
<h2><?php printf( current_user_can('manage_categories') ? __('Tags (<a href="%s">Add New</a>)') : __('Manage Tags'), '#addtag' ); ?></h2>
|
|
|
|
<br class="clear" />
|
|
|
|
<div class="tablenav">
|
|
|
|
<?php
|
|
$pagenum = absint( $_GET['pagenum'] );
|
|
if ( empty($pagenum) )
|
|
$pagenum = 1;
|
|
if( !$tagsperpage || $tagsperpage < 0 )
|
|
$tagsperpage = 20;
|
|
|
|
$page_links = paginate_links( array(
|
|
'base' => add_query_arg( 'pagenum', '%#%' ),
|
|
'format' => '',
|
|
'total' => ceil(wp_count_terms('post_tag') / $tagsperpage),
|
|
'current' => $pagenum
|
|
));
|
|
|
|
if ( $page_links )
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
|
?>
|
|
|
|
<div class="alignleft">
|
|
<select name="action">
|
|
<option value="" selected><?php _e('Actions'); ?></option>
|
|
<option value="delete"><?php _e('Delete'); ?></option>
|
|
</select>
|
|
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
|
|
<?php wp_nonce_field('bulk-tags'); ?>
|
|
</div>
|
|
|
|
<br class="clear" />
|
|
</div>
|
|
|
|
<br class="clear" />
|
|
|
|
<table class="widefat">
|
|
<thead>
|
|
<tr>
|
|
<?php print_column_headers('tag'); ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="the-list" class="list:tag">
|
|
<?php
|
|
|
|
$searchterms = trim( $_GET['s'] );
|
|
|
|
$count = tag_rows( $pagenum, $tagsperpage, $searchterms );
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
|
|
</form>
|
|
|
|
<div class="tablenav">
|
|
|
|
<?php
|
|
if ( $page_links )
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
|
?>
|
|
<br class="clear" />
|
|
</div>
|
|
<br class="clear" />
|
|
|
|
</div>
|
|
|
|
<?php if ( current_user_can('manage_categories') ) : ?>
|
|
|
|
<br />
|
|
<?php include('edit-tag-form.php'); ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
include('admin-footer.php');
|
|
|
|
?>
|