Make WordPress Core


Ignore:
Timestamp:
04/02/2006 12:20:11 AM (19 years ago)
Author:
ryan
Message:

WP_Locale. Props Sewar. fixes #2568

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-general.php

    r3566 r3676  
    135135function wp_title($sep = '»', $display = true) {
    136136    global $wpdb;
    137     global $m, $year, $monthnum, $day, $category_name, $month, $posts;
     137    global $m, $year, $monthnum, $day, $category_name, $wp_locale, $posts;
    138138
    139139    $cat = get_query_var('cat');
     
    174174    if ( !empty($m) ) {
    175175        $my_year = substr($m, 0, 4);
    176         $my_month = $month[substr($m, 4, 2)];
     176        $my_month = $wp_locale->get_month($m);
    177177        $title = "$my_year $sep $my_month";
    178178    }
     
    181181        $title = $year;
    182182        if ( !empty($monthnum) )
    183             $title .= " $sep ".$month[zeroise($monthnum, 2)];
     183            $title .= " $sep ".$wp_locale->get_month($monthnum);
    184184        if ( !empty($day) )
    185185            $title .= " $sep ".zeroise($day, 2);
     
    241241
    242242function single_month_title($prefix = '', $display = true ) {
    243     global $m, $monthnum, $month, $year;
     243    global $m, $monthnum, $wp_locale, $year;
    244244    if ( !empty($monthnum) && !empty($year) ) {
    245245        $my_year = $year;
    246         $my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
     246        $my_month = $wp_locale->get_month($monthnum);
    247247    } elseif ( !empty($m) ) {
    248248        $my_year = substr($m, 0, 4);
    249         $my_month = $month[substr($m, 4, 2)];
     249        $my_month = $wp_locale->get_month($m);
    250250    }
    251251
     
    293293
    294294function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
    295     global $month, $wpdb;
     295    global $wp_locale, $wpdb;
    296296
    297297    if ( '' == $type )
     
    331331                $url    = get_month_link($arcresult->year,  $arcresult->month);
    332332                if ( $show_post_count ) {
    333                     $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
     333                    $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
    334334                    $after = ' ('.$arcresult->posts.')' . $afterafter;
    335335                } else {
    336                     $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
     336                    $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
    337337                }
    338338                echo get_archives_link($url, $text, $format, $before, $after);
     
    394394
    395395
    396 function get_calendar($daylength = 1) {
    397     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
     396function get_calendar($initial = true) {
     397    global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts;
    398398
    399399    // Quick check. If we have no posts at all, abort!
     
    451451
    452452    echo '<table id="wp-calendar">
    453     <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
     453    <caption>' . $wp_locale->get_month($thismonth) . ' ' . date('Y', $unixmonth) . '</caption>
    454454    <thead>
    455455    <tr>';
    456456
    457     $day_abbrev = $weekday_initial;
    458     if ( $daylength > 1 )
    459         $day_abbrev = $weekday_abbrev;
    460 
    461457    $myweek = array();
    462458
    463459    for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
    464         $myweek[]=$weekday[($wdcount+$week_begins)%7];
     460        $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
    465461    }
    466462
    467463    foreach ( $myweek as $wd ) {
    468         echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
     464        $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
     465        echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
    469466    }
    470467
     
    477474
    478475    if ( $previous ) {
    479         echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
    480         get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)],
    481             date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
     476        echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
     477        get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
     478            date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
    482479    } else {
    483480        echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
     
    487484
    488485    if ( $next ) {
    489         echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
    490         get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($next->month, 2)],
    491             date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
     486        echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
     487        get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
     488            date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
    492489    } else {
    493490        echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
     
    676673
    677674function the_weekday() {
    678     global $weekday, $id, $post;
    679     $the_weekday = $weekday[mysql2date('w', $post->post_date)];
     675    global $wp_locale, $id, $post;
     676    $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
    680677    $the_weekday = apply_filters('the_weekday', $the_weekday);
    681678    echo $the_weekday;
     
    684681
    685682function the_weekday_date($before='',$after='') {
    686     global $weekday, $id, $post, $day, $previousweekday;
     683    global $wp_locale, $id, $post, $day, $previousweekday;
    687684    $the_weekday_date = '';
    688685    if ( $day != $previousweekday ) {
    689686        $the_weekday_date .= $before;
    690         $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)];
     687        $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
    691688        $the_weekday_date .= $after;
    692689        $previousweekday = $day;
Note: See TracChangeset for help on using the changeset viewer.