WordPress.org

Make WordPress Core

Changeset 10239


Ignore:
Timestamp:
12/22/08 19:33:09 (5 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-tag-form.php

    r10137 r10239  
    2222<input type="hidden" name="action" value="editedtag" /> 
    2323<input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" /> 
     24<input type="hidden" name="taxonomy" value="<?php echo attribute_escape($taxonomy) ?>" /> 
    2425<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?> 
    2526    <table class="form-table"> 
  • trunk/wp-admin/edit-tags.php

    r10150 r10239  
    1212$title = __('Tags'); 
    1313 
    14 wp_reset_vars( array('action', 'tag') ); 
     14wp_reset_vars( array('action', 'tag', 'taxonomy') ); 
     15 
     16if ( empty($taxonomy) ) 
     17    $taxonomy = 'post_tag'; 
    1518 
    1619if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) 
     
    2629        wp_die(__('Cheatin&#8217; uh?')); 
    2730 
    28     $ret = wp_insert_term($_POST['name'], 'post_tag', $_POST); 
     31    $ret = wp_insert_term($_POST['name'], $taxonomy, $_POST); 
    2932    if ( $ret && !is_wp_error( $ret ) ) { 
    3033        wp_redirect('edit-tags.php?message=1#addtag'); 
     
    4245        wp_die(__('Cheatin&#8217; uh?')); 
    4346 
    44     wp_delete_term( $tag_ID, 'post_tag'); 
     47    wp_delete_term( $tag_ID, $taxonomy); 
    4548 
    4649    wp_redirect('edit-tags.php?message=2'); 
     
    5760    $tags = $_GET['delete_tags']; 
    5861    foreach( (array) $tags as $tag_ID ) { 
    59         wp_delete_term( $tag_ID, 'post_tag'); 
     62        wp_delete_term( $tag_ID, $taxonomy); 
    6063    } 
    6164 
     
    7881    $tag_ID = (int) $_GET['tag_ID']; 
    7982 
    80     $tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit'); 
     83    $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit'); 
    8184    include('edit-tag-form.php'); 
    8285 
     
    9093        wp_die(__('Cheatin&#8217; uh?')); 
    9194 
    92     $ret = wp_update_term($tag_ID, 'post_tag', $_POST); 
     95    $ret = wp_update_term($tag_ID, $taxonomy, $_POST); 
    9396 
    9497    $location = 'edit-tags.php'; 
     
    168171    'prev_text' => __('&laquo;'), 
    169172    'next_text' => __('&raquo;'), 
    170     'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), 
     173    'total' => ceil(wp_count_terms($taxonomy) / $tagsperpage), 
    171174    'current' => $pagenum 
    172175)); 
     
    208211$searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; 
    209212 
    210 $count = tag_rows( $pagenum, $tagsperpage, $searchterms ); 
     213$count = tag_rows( $pagenum, $tagsperpage, $searchterms, $taxonomy ); 
    211214?> 
    212215    </tbody> 
  • trunk/wp-admin/includes/template.php

    r10222 r10239  
    582582 * @return unknown 
    583583 */ 
    584 function _tag_row( $tag, $class = '' ) { 
     584function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) { 
    585585        $count = number_format_i18n( $tag->count ); 
    586586        $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count; 
    587587 
    588588        $name = apply_filters( 'term_name', $tag->name ); 
    589         $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); 
    590         $edit_link = "edit-tags.php?action=edit&amp;tag_ID=$tag->term_id"; 
     589        $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); 
     590        $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id"; 
    591591        $out = ''; 
    592592        $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; 
     
    611611                    $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 
    612612                    $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>'; 
    613                     $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>"; 
     613                    $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>"; 
    614614                    $action_count = count($actions); 
    615615                    $i = 0; 
     
    653653 * @return unknown 
    654654 */ 
    655 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { 
     655function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) { 
    656656 
    657657    // Get a page worth of tags 
     
    664664    } 
    665665 
    666     $tags = get_terms( 'post_tag', $args ); 
     666    $tags = get_terms( $taxonomy, $args ); 
    667667 
    668668    // convert it to table rows 
     
    670670    $count = 0; 
    671671    foreach( $tags as $tag ) 
    672         $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' ); 
     672        $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy ); 
    673673 
    674674    // filter and send to screen 
  • trunk/wp-includes/link-template.php

    r10213 r10239  
    570570 * @return string 
    571571 */ 
    572 function get_edit_tag_link( $tag_id = 0 ) { 
     572function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { 
    573573    $tag = get_term($tag_id, 'post_tag'); 
    574574 
     
    576576        return; 
    577577 
    578     $location = admin_url('edit-tags.php?action=edit&amp;tag_ID=') . $tag->term_id; 
     578    $location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;tag_ID=' . $tag->term_id); 
    579579    return apply_filters( 'get_edit_tag_link', $location ); 
    580580} 
     
    12461246 
    12471247/** 
    1248  * Display link to next comments pages. 
    1249  * 
    1250  * @since 2.7.0 
     1248 * Return the link to next comments pages. 
     1249 * 
     1250 * @since 2.7.1 
    12511251 * 
    12521252 * @param string $label Optional. Label for link text. 
    12531253 * @param int $max_page Optional. Max page. 
    1254  */ 
    1255 function next_comments_link($label='', $max_page = 0) { 
     1254 * @return string|null 
     1255 */ 
     1256function get_next_comments_link( $label = '', $max_page = 0 ) { 
    12561257    global $wp_query; 
    12571258 
     
    12781279        $label = __('Newer Comments &raquo;'); 
    12791280 
    1280     echo '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ); 
    1281     $attr = apply_filters( 'next_comments_link_attributes', '' ); 
    1282     echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>'; 
    1283 } 
    1284  
    1285 /** 
    1286  * Display the previous comments page link. 
     1281    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>'; 
     1282} 
     1283 
     1284/** 
     1285 * Display the link to next comments pages. 
    12871286 * 
    12881287 * @since 2.7.0 
    12891288 * 
     1289 * @param string $label Optional. Label for link text. 
     1290 * @param int $max_page Optional. Max page. 
     1291 */ 
     1292function next_comments_link( $label = '', $max_page = 0 ) { 
     1293    echo get_next_comments_link( $label, $max_page ); 
     1294} 
     1295 
     1296/** 
     1297 * Return the previous comments page link. 
     1298 * 
     1299 * @since 2.7.1 
     1300 * 
    12901301 * @param string $label Optional. Label for comments link text. 
    1291  */ 
    1292 function previous_comments_link($label='') { 
    1293  
     1302 * @return string|null 
     1303 */ 
     1304function get_previous_comments_link( $label = '' ) { 
    12941305    if ( !is_singular() ) 
    12951306        return; 
     
    13081319        $label = __('&laquo; Older Comments'); 
    13091320 
    1310     echo '<a href="' . clean_url(get_comments_pagenum_link($prevpage)); 
    1311     $attr = apply_filters( 'previous_comments_link_attributes', '' ); 
    1312     echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>'; 
     1321    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>'; 
     1322} 
     1323 
     1324/** 
     1325 * Display the previous comments page link. 
     1326 * 
     1327 * @since 2.7.0 
     1328 * 
     1329 * @param string $label Optional. Label for comments link text. 
     1330 */ 
     1331function previous_comments_link( $label = '' ) { 
     1332    echo get_previous_comments_link( $label ); 
    13131333} 
    13141334 
Note: See TracChangeset for help on using the changeset viewer.