get_previous_comments_link() and get_next_comments_link(). Props Viper007Bond. fixes #8058 for trunk

git-svn-id: http://svn.automattic.com/wordpress/trunk@10239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-12-22 19:33:09 +00:00
parent c55feaddbf
commit 22a1c35cea
4 changed files with 53 additions and 29 deletions

View File

@ -21,6 +21,7 @@ do_action('edit_tag_form_pre', $tag); ?>
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"> <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
<input type="hidden" name="action" value="editedtag" /> <input type="hidden" name="action" value="editedtag" />
<input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" /> <input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" />
<input type="hidden" name="taxonomy" value="<?php echo attribute_escape($taxonomy) ?>" />
<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
<table class="form-table"> <table class="form-table">
<tr class="form-field form-required"> <tr class="form-field form-required">

View File

@ -11,7 +11,10 @@ require_once('admin.php');
$title = __('Tags'); $title = __('Tags');
wp_reset_vars( array('action', 'tag') ); wp_reset_vars( array('action', 'tag', 'taxonomy') );
if ( empty($taxonomy) )
$taxonomy = 'post_tag';
if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
$action = 'bulk-delete'; $action = 'bulk-delete';
@ -25,7 +28,7 @@ case 'addtag':
if ( !current_user_can('manage_categories') ) if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin&#8217; uh?')); wp_die(__('Cheatin&#8217; uh?'));
$ret = wp_insert_term($_POST['name'], 'post_tag', $_POST); $ret = wp_insert_term($_POST['name'], $taxonomy, $_POST);
if ( $ret && !is_wp_error( $ret ) ) { if ( $ret && !is_wp_error( $ret ) ) {
wp_redirect('edit-tags.php?message=1#addtag'); wp_redirect('edit-tags.php?message=1#addtag');
} else { } else {
@ -41,7 +44,7 @@ case 'delete':
if ( !current_user_can('manage_categories') ) if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin&#8217; uh?')); wp_die(__('Cheatin&#8217; uh?'));
wp_delete_term( $tag_ID, 'post_tag'); wp_delete_term( $tag_ID, $taxonomy);
wp_redirect('edit-tags.php?message=2'); wp_redirect('edit-tags.php?message=2');
exit; exit;
@ -56,7 +59,7 @@ case 'bulk-delete':
$tags = $_GET['delete_tags']; $tags = $_GET['delete_tags'];
foreach( (array) $tags as $tag_ID ) { foreach( (array) $tags as $tag_ID ) {
wp_delete_term( $tag_ID, 'post_tag'); wp_delete_term( $tag_ID, $taxonomy);
} }
$location = 'edit-tags.php'; $location = 'edit-tags.php';
@ -77,7 +80,7 @@ case 'edit':
require_once ('admin-header.php'); require_once ('admin-header.php');
$tag_ID = (int) $_GET['tag_ID']; $tag_ID = (int) $_GET['tag_ID'];
$tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit'); $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit');
include('edit-tag-form.php'); include('edit-tag-form.php');
break; break;
@ -89,7 +92,7 @@ case 'editedtag':
if ( !current_user_can('manage_categories') ) if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin&#8217; uh?')); wp_die(__('Cheatin&#8217; uh?'));
$ret = wp_update_term($tag_ID, 'post_tag', $_POST); $ret = wp_update_term($tag_ID, $taxonomy, $_POST);
$location = 'edit-tags.php'; $location = 'edit-tags.php';
if ( $referer = wp_get_original_referer() ) { if ( $referer = wp_get_original_referer() ) {
@ -167,7 +170,7 @@ $page_links = paginate_links( array(
'format' => '', 'format' => '',
'prev_text' => __('&laquo;'), 'prev_text' => __('&laquo;'),
'next_text' => __('&raquo;'), 'next_text' => __('&raquo;'),
'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), 'total' => ceil(wp_count_terms($taxonomy) / $tagsperpage),
'current' => $pagenum 'current' => $pagenum
)); ));
@ -207,7 +210,7 @@ if ( $page_links )
$searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '';
$count = tag_rows( $pagenum, $tagsperpage, $searchterms ); $count = tag_rows( $pagenum, $tagsperpage, $searchterms, $taxonomy );
?> ?>
</tbody> </tbody>
</table> </table>

View File

@ -581,13 +581,13 @@ function wp_link_category_checklist( $link_id = 0 ) {
* @param unknown_type $class * @param unknown_type $class
* @return unknown * @return unknown
*/ */
function _tag_row( $tag, $class = '' ) { function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
$count = number_format_i18n( $tag->count ); $count = number_format_i18n( $tag->count );
$count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count; $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
$name = apply_filters( 'term_name', $tag->name ); $name = apply_filters( 'term_name', $tag->name );
$qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
$edit_link = "edit-tags.php?action=edit&amp;tag_ID=$tag->term_id"; $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id";
$out = ''; $out = '';
$out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
$columns = get_column_headers('edit-tags'); $columns = get_column_headers('edit-tags');
@ -610,7 +610,7 @@ function _tag_row( $tag, $class = '' ) {
$actions = array(); $actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>'; $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
$action_count = count($actions); $action_count = count($actions);
$i = 0; $i = 0;
$out .= '<div class="row-actions">'; $out .= '<div class="row-actions">';
@ -652,7 +652,7 @@ function _tag_row( $tag, $class = '' ) {
* @param unknown_type $searchterms * @param unknown_type $searchterms
* @return unknown * @return unknown
*/ */
function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
// Get a page worth of tags // Get a page worth of tags
$start = ($page - 1) * $pagesize; $start = ($page - 1) * $pagesize;
@ -663,13 +663,13 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
$args['search'] = $searchterms; $args['search'] = $searchterms;
} }
$tags = get_terms( 'post_tag', $args ); $tags = get_terms( $taxonomy, $args );
// convert it to table rows // convert it to table rows
$out = ''; $out = '';
$count = 0; $count = 0;
foreach( $tags as $tag ) foreach( $tags as $tag )
$out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' ); $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy );
// filter and send to screen // filter and send to screen
echo $out; echo $out;

View File

@ -569,13 +569,13 @@ function get_tag_feed_link($tag_id, $feed = '') {
* @param int $tag_id Tag ID * @param int $tag_id Tag ID
* @return string * @return string
*/ */
function get_edit_tag_link( $tag_id = 0 ) { function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) {
$tag = get_term($tag_id, 'post_tag'); $tag = get_term($tag_id, 'post_tag');
if ( !current_user_can('manage_categories') ) if ( !current_user_can('manage_categories') )
return; return;
$location = admin_url('edit-tags.php?action=edit&amp;tag_ID=') . $tag->term_id; $location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;tag_ID=' . $tag->term_id);
return apply_filters( 'get_edit_tag_link', $location ); return apply_filters( 'get_edit_tag_link', $location );
} }
@ -1245,14 +1245,15 @@ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
} }
/** /**
* Display link to next comments pages. * Return the link to next comments pages.
* *
* @since 2.7.0 * @since 2.7.1
* *
* @param string $label Optional. Label for link text. * @param string $label Optional. Label for link text.
* @param int $max_page Optional. Max page. * @param int $max_page Optional. Max page.
* @return string|null
*/ */
function next_comments_link($label='', $max_page = 0) { function get_next_comments_link( $label = '', $max_page = 0 ) {
global $wp_query; global $wp_query;
if ( !is_singular() ) if ( !is_singular() )
@ -1277,20 +1278,30 @@ function next_comments_link($label='', $max_page = 0) {
if ( empty($label) ) if ( empty($label) )
$label = __('Newer Comments &raquo;'); $label = __('Newer Comments &raquo;');
echo '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ); return '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
$attr = apply_filters( 'next_comments_link_attributes', '' );
echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
} }
/** /**
* Display the previous comments page link. * Display the link to next comments pages.
* *
* @since 2.7.0 * @since 2.7.0
* *
* @param string $label Optional. Label for comments link text. * @param string $label Optional. Label for link text.
* @param int $max_page Optional. Max page.
*/ */
function previous_comments_link($label='') { function next_comments_link( $label = '', $max_page = 0 ) {
echo get_next_comments_link( $label, $max_page );
}
/**
* Return the previous comments page link.
*
* @since 2.7.1
*
* @param string $label Optional. Label for comments link text.
* @return string|null
*/
function get_previous_comments_link( $label = '' ) {
if ( !is_singular() ) if ( !is_singular() )
return; return;
@ -1307,9 +1318,18 @@ function previous_comments_link($label='') {
if ( empty($label) ) if ( empty($label) )
$label = __('&laquo; Older Comments'); $label = __('&laquo; Older Comments');
echo '<a href="' . clean_url(get_comments_pagenum_link($prevpage)); return '<a href="' . clean_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
$attr = apply_filters( 'previous_comments_link_attributes', '' ); }
echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
/**
* Display the previous comments page link.
*
* @since 2.7.0
*
* @param string $label Optional. Label for comments link text.
*/
function previous_comments_link( $label = '' ) {
echo get_previous_comments_link( $label );
} }
/** /**