WordPress.org

Make WordPress Core

Ticket #5692: detailedArchives.patch

File detailedArchives.patch, 2.7 KB (added by davidedelvento, 5 years ago)
  • general-template.php

     
    359359        $defaults = array( 
    360360                'type' => 'monthly', 'limit' => '', 
    361361                'format' => 'html', 'before' => '', 
    362                 'after' => '', 'show_post_count' => false 
     362                'after' => '', 'show_post_count' => 0 
    363363        ); 
    364364 
    365365        $r = wp_parse_args( $args, $defaults ); 
     
    412412                        foreach ( $arcresults as $arcresult ) { 
    413413                                $url    = get_month_link($arcresult->year,      $arcresult->month); 
    414414                                $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); 
    415                                 if ( $show_post_count ) 
    416                                         $after = ' ('.$arcresult->posts.')' . $afterafter; 
     415                                if ( $show_post_count ) { 
     416                                        if ( $show_post_count > 1 ) { 
     417                                                $detail_counts=""; 
     418                                                foreach( get_categories() as $categoria) { 
     419                                                        $howmanyincat=count(query_posts("year=$arcresult->year&monthnum=$arcresult->month&category_name=$categoria->cat_name")); 
     420                                                        if ($howmanyincat > 0)  
     421                                                                $detail_counts .= $howmanyincat . " " .  $categoria->cat_name . ', '; 
     422                                                } 
     423                                                $detail_counts=substr($detail_counts, 0, -2); 
     424                                        } 
     425                                        if ( $show_post_count == 1 ) { 
     426                                                $after = ' ('. $arcresult->posts . ')' . $afterafter; 
     427                                        } else if ( $show_post_count == 2 ) { 
     428                                                $after = ' ('. $detail_counts . ')' . $afterafter; 
     429                                        } else { 
     430                                                $after = ' ('.$arcresult->posts . ', ' . $detail_counts . ')' . $afterafter; 
     431                                        } 
     432                                } 
    417433                                echo get_archives_link($url, $text, $format, $before, $after); 
    418434                        } 
    419435                } 
     
    433449                        foreach ($arcresults as $arcresult) { 
    434450                                $url = get_year_link($arcresult->year); 
    435451                                $text = sprintf('%d', $arcresult->year); 
    436                                 if ($show_post_count) 
    437                                         $after = ' ('.$arcresult->posts.')' . $afterafter; 
     452                                if ($show_post_count) { 
     453                                        if ( $show_post_count > 1 ) { 
     454                                                $detail_counts=""; 
     455                                                foreach( get_categories() as $categoria) { 
     456                                                        $howmanyincat=count(query_posts("year=$arcresult->year&monthnum=$arcresult->month&category_name=$categoria->cat_name")); 
     457                                                        if ($howmanyincat > 0)  
     458                                                                $detail_counts .= $howmanyincat . " " .  $categoria->cat_name . ', '; 
     459                                                } 
     460                                                $detail_counts=substr($detail_counts, 0, -2); 
     461                                        } 
     462                                        if ( $show_post_count == 1 ) { 
     463                                                $after = ' ('. $arcresult->posts . ')' . $afterafter; 
     464                                        } else if ( $show_post_count == 2 ) { 
     465                                                $after = ' ('. $detail_counts . ')' . $afterafter; 
     466                                        } else { 
     467                                                $after = ' ('.$arcresult->posts . ', ' . $detail_counts . ')' . $afterafter; 
     468                                        } 
     469                                } 
    438470                                echo get_archives_link($url, $text, $format, $before, $after); 
    439471                        } 
    440472                }