From 001f4a16b8203ac3c4d1f69712d27f1b8bee8fe7 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 22 Dec 2008 19:33:09 +0000 Subject: [PATCH] get_previous_comments_link() and get_next_comments_link(). Props Viper007Bond. fixes #8058 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@10239 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-tag-form.php | 1 + wp-admin/edit-tags.php | 19 ++++++++------ wp-admin/includes/template.php | 14 +++++----- wp-includes/link-template.php | 48 ++++++++++++++++++++++++---------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php index f2218ac067..8cd22f8ef5 100644 --- a/wp-admin/edit-tag-form.php +++ b/wp-admin/edit-tag-form.php @@ -21,6 +21,7 @@ do_action('edit_tag_form_pre', $tag); ?>
+ diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 41467ecb9a..e74221dcfe 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -11,7 +11,10 @@ require_once('admin.php'); $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'] ) ) $action = 'bulk-delete'; @@ -25,7 +28,7 @@ case 'addtag': if ( !current_user_can('manage_categories') ) wp_die(__('Cheatin’ uh?')); - $ret = wp_insert_term($_POST['name'], 'post_tag', $_POST); + $ret = wp_insert_term($_POST['name'], $taxonomy, $_POST); if ( $ret && !is_wp_error( $ret ) ) { wp_redirect('edit-tags.php?message=1#addtag'); } else { @@ -41,7 +44,7 @@ case 'delete': if ( !current_user_can('manage_categories') ) wp_die(__('Cheatin’ uh?')); - wp_delete_term( $tag_ID, 'post_tag'); + wp_delete_term( $tag_ID, $taxonomy); wp_redirect('edit-tags.php?message=2'); exit; @@ -56,7 +59,7 @@ case 'bulk-delete': $tags = $_GET['delete_tags']; foreach( (array) $tags as $tag_ID ) { - wp_delete_term( $tag_ID, 'post_tag'); + wp_delete_term( $tag_ID, $taxonomy); } $location = 'edit-tags.php'; @@ -77,7 +80,7 @@ case 'edit': require_once ('admin-header.php'); $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'); break; @@ -89,7 +92,7 @@ case 'editedtag': if ( !current_user_can('manage_categories') ) wp_die(__('Cheatin’ uh?')); - $ret = wp_update_term($tag_ID, 'post_tag', $_POST); + $ret = wp_update_term($tag_ID, $taxonomy, $_POST); $location = 'edit-tags.php'; if ( $referer = wp_get_original_referer() ) { @@ -167,7 +170,7 @@ $page_links = paginate_links( array( 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), - 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), + 'total' => ceil(wp_count_terms($taxonomy) / $tagsperpage), 'current' => $pagenum )); @@ -207,7 +210,7 @@ if ( $page_links ) $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; -$count = tag_rows( $pagenum, $tagsperpage, $searchterms ); +$count = tag_rows( $pagenum, $tagsperpage, $searchterms, $taxonomy ); ?>
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 84aecd01a3..74d25ea2ae 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -581,13 +581,13 @@ function wp_link_category_checklist( $link_id = 0 ) { * @param unknown_type $class * @return unknown */ -function _tag_row( $tag, $class = '' ) { +function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) { $count = number_format_i18n( $tag->count ); $count = ( $count > 0 ) ? "$count" : $count; $name = apply_filters( 'term_name', $tag->name ); - $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); - $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id"; + $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); + $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; $out = ''; $out .= ''; $columns = get_column_headers('edit-tags'); @@ -610,7 +610,7 @@ function _tag_row( $tag, $class = '' ) { $actions = array(); $actions['edit'] = '' . __('Edit') . ''; $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; - $actions['delete'] = "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') . ""; + $actions['delete'] = "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') . ""; $action_count = count($actions); $i = 0; $out .= '
'; @@ -652,7 +652,7 @@ function _tag_row( $tag, $class = '' ) { * @param unknown_type $searchterms * @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 $start = ($page - 1) * $pagesize; @@ -663,13 +663,13 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { $args['search'] = $searchterms; } - $tags = get_terms( 'post_tag', $args ); + $tags = get_terms( $taxonomy, $args ); // convert it to table rows $out = ''; $count = 0; 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 echo $out; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index dcd1cad2c9..4409bb080a 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -569,13 +569,13 @@ function get_tag_feed_link($tag_id, $feed = '') { * @param int $tag_id Tag ID * @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'); if ( !current_user_can('manage_categories') ) return; - $location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id; + $location = admin_url('edit-tags.php?action=edit&taxonomy=' . $taxonomy . '&tag_ID=' . $tag->term_id); 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 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; if ( !is_singular() ) @@ -1277,20 +1278,30 @@ function next_comments_link($label='', $max_page = 0) { if ( empty($label) ) $label = __('Newer Comments »'); - echo '". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + return ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; } /** - * Display the previous comments page link. + * Display the link to next comments pages. * * @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() ) return; @@ -1307,9 +1318,18 @@ function previous_comments_link($label='') { if ( empty($label) ) $label = __('« Older Comments'); - echo '". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + return '' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; +} + +/** + * 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 ); } /**