Make WordPress Core

Ticket #31960: 31960.patch

File 31960.patch, 3.3 KB (added by umesh.nevase, 10 years ago)

patch file to add classes for archive widget items

  • wp-includes/general-template.php

     
    12771277 * @param string $after Optional.
    12781278 * @return string HTML link content for archive.
    12791279 */
    1280 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
     1280function get_archives_link($url, $text, $format = 'html', $before = '', $after = '', $archive_index = '1') {
    12811281        $text = wptexturize($text);
    12821282        $url = esc_url($url);
    12831283
     
    12851285                $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
    12861286        elseif ('option' == $format)
    12871287                $link_html = "\t<option value='$url'>$before $text $after</option>\n";
    1288         elseif ('html' == $format)
    1289                 $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
     1288        elseif ('html' == $format) {
     1289                $class = 'archive-item archive-item-' . $archive_index;
     1290                $link_html = "\t<li class='$class'>$before<a href='$url'>$text</a>$after</li>\n";       
     1291        }
    12901292        else // custom
    12911293                $link_html = "\t$before<a href='$url'>$text</a>$after\n";
    12921294
     
    14061408        }
    14071409
    14081410        $limit = $r['limit'];
     1411       
     1412        $archive_index = 1;
    14091413
    14101414        if ( 'monthly' == $r['type'] ) {
    14111415                $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
     
    14241428                                if ( $r['show_post_count'] ) {
    14251429                                        $r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
    14261430                                }
    1427                                 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
     1431                                $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $archive_index );
     1432                                $archive_index ++;
    14281433                        }
    14291434                }
    14301435        } elseif ( 'yearly' == $r['type'] ) {
     
    14431448                                if ( $r['show_post_count'] ) {
    14441449                                        $r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
    14451450                                }
    1446                                 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
     1451                                $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $archive_index );
     1452                                $archive_index ++;
    14471453                        }
    14481454                }
    14491455        } elseif ( 'daily' == $r['type'] ) {
     
    14631469                                if ( $r['show_post_count'] ) {
    14641470                                        $r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
    14651471                                }
    1466                                 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
     1472                                $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $archive_index );
     1473                                $archive_index ++;
    14671474                        }
    14681475                }
    14691476        } elseif ( 'weekly' == $r['type'] ) {
     
    14901497                                        if ( $r['show_post_count'] ) {
    14911498                                                $r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
    14921499                                        }
    1493                                         $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
     1500                                        $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $archive_index );
     1501                                        $archive_index ++;
    14941502                                }
    14951503                        }
    14961504                }
     
    15131521                                        } else {
    15141522                                                $text = $result->ID;
    15151523                                        }
    1516                                         $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
     1524                                        $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $archive_index );
     1525                                        $archive_index ++;
    15171526                                }
    15181527                        }
    15191528                }