WordPress.org

Make WordPress Core

Ticket #11511: 11511.3.patch

File 11511.3.patch, 2.1 KB (added by garyc40, 6 years ago)
  • wp-includes/taxonomy.php

    Property changes on: .
    ___________________________________________________________________
    Added: svn:ignore
       + wp-config.php
    
    
     
    10711071function wp_count_terms( $taxonomy, $args = array() ) { 
    10721072        global $wpdb; 
    10731073 
    1074         $defaults = array('ignore_empty' => false); 
     1074        $defaults = array('ignore_empty' => false, 'search' => ''); 
    10751075        $args = wp_parse_args($args, $defaults); 
    10761076        extract($args, EXTR_SKIP); 
    10771077 
    10781078        $where = ''; 
     1079        $join = ''; 
     1080        if ( ! empty( $search ) ) { 
     1081                $search = like_escape( $search ); 
     1082                $join = "INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id AND t.name LIKE '%%{$search}%%'"; 
     1083        } 
     1084         
    10791085        if ( $ignore_empty ) 
    1080                 $where = 'AND count > 0'; 
     1086                $where .= 'AND count > 0'; 
    10811087 
    1082         return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = %s $where", $taxonomy) ); 
     1088        return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy AS tt $join WHERE taxonomy = %s $where", $taxonomy) ); 
    10831089} 
    10841090 
    10851091/** 
  • wp-admin/edit-tags.php

     
    200200$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 
    201201$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 
    202202 
     203$searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; 
     204 
    203205$page_links = paginate_links( array( 
    204206        'base' => add_query_arg( 'pagenum', '%#%' ), 
    205207        'format' => '', 
    206208        'prev_text' => __('«'), 
    207209        'next_text' => __('»'), 
    208         'total' => ceil(wp_count_terms($taxonomy) / $tags_per_page), 
     210        'total' => ceil( wp_count_terms( $taxonomy, array( 'search' => $searchterms ) ) / $tags_per_page ), 
    209211        'current' => $pagenum 
    210212)); 
    211213 
     
    243245        <tbody id="the-list" class="list:tag"> 
    244246<?php 
    245247 
    246 $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; 
    247  
    248248$count = tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); 
    249249?> 
    250250        </tbody>