function wp_loginout() {
- global $user_ID;
- get_currentuserinfo();
-
- if ('' == $user_ID)
+ if ( ! is_user_logged_in() )
$link = '<a href="' . get_settings('siteurl') . '/wp-login.php">' . __('Login') . '</a>';
else
$link = '<a href="' . get_settings('siteurl') . '/wp-login.php?action=logout">' . __('Logout') . '</a>';
function wp_register( $before = '<li>', $after = '</li>' ) {
- global $user_ID;
-
- get_currentuserinfo();
- if ( '' == $user_ID && get_settings('users_can_register') )
- $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
- elseif ( '' == $user_ID && !get_settings('users_can_register') )
- $link = '';
- else
+ if ( ! is_user_logged_in() ) {
+ if ( get_settings('users_can_register') )
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
+ else
+ $link = '';
+ } else {
$link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
+ }
echo apply_filters('register', $link);
}
function bloginfo($show='') {
$info = get_bloginfo($show);
- if ( ! (strstr($info, 'url') || strstr($info, 'directory')) ) {
+ if (!strstr($show, 'url') && //don't filter URLs
+ !strstr($show, 'directory') &&
+ !strstr($show, 'home')) {
$info = apply_filters('bloginfo', $info, $show);
$info = convert_chars($info);
+ } else {
+ $info = apply_filters('bloginfo_url', $info, $show);
}
echo $info;
function wp_title($sep = '»', $display = true) {
- global $wpdb;
- global $m, $year, $monthnum, $day, $category_name, $month, $posts;
+ global $wpdb, $posts, $month;
$cat = get_query_var('cat');
$p = get_query_var('p');
$category_name = get_query_var('category_name');
$author = get_query_var('author');
$author_name = get_query_var('author_name');
+ $m = (int) get_query_var('m');
+ $year = (int) get_query_var('year');
+ $monthnum = (int) get_query_var('monthnum');
+ $day = (int) get_query_var('day');
+ $title = '';
// If there's a category
if ( !empty($cat) ) {
// category exclusion
if ( !stristr($cat,'-') )
- $title = get_the_category_by_ID($cat);
- }
- if ( !empty($category_name) ) {
+ $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
+ } elseif ( !empty($category_name) ) {
if ( stristr($category_name,'/') ) {
$category_name = explode('/',$category_name);
if ( $category_name[count($category_name)-1] )
$category_name = $category_name[count($category_name)-2]; // there was a trailling slash
}
$title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
+ $title = apply_filters('single_cat_title', $title);
}
// If there's an author
}
$prefix = '';
- if ( isset($title) )
+ if ( !empty($title) )
$prefix = " $sep ";
$title = $prefix . $title;
function single_month_title($prefix = '', $display = true ) {
- global $m, $monthnum, $month, $year;
+ global $month;
+
+ $m = (int) get_query_var('m');
+ $year = (int) get_query_var('year');
+ $monthnum = (int) get_query_var('monthnum');
+
if ( !empty($monthnum) && !empty($year) ) {
$my_year = $year;
$my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
/* link navigation hack by Orien http://icecode.com/ */
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
$text = wptexturize($text);
- $title_text = wp_specialchars($text, 1);
+ $title_text = attribute_escape($text);
if ('link' == $format)
return "\t<link rel='archives' title='$title_text' href='$url' />\n";
foreach ( $arcresults as $arcresult ) {
$url = get_month_link($arcresult->year, $arcresult->month);
if ( $show_post_count ) {
- $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ $text = sprintf(__('%1$s %2$d'), $month[zeroise($arcresult->month,2)], $arcresult->year);
$after = ' ('.$arcresult->posts.')' . $afterafter;
} else {
- $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ $text = sprintf(__('%1$s %2$d'), $month[zeroise($arcresult->month,2)], $arcresult->year);
}
echo get_archives_link($url, $text, $format, $before, $after);
}
if ( $arcresults ) {
foreach ( $arcresults as $arcresult ) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
- $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date);
echo get_archives_link($url, $text, $format, $before, $after);
}
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
- $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
+ $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
echo get_archives_link($url, $text, $format, $before, $after);
}
function get_calendar($daylength = 1) {
global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
- // Quick check. If we have no posts at all, abort!
+ $now = current_time('mysql');
+
+ // Quick check. If we have no posts yet published, abort!
if ( !$posts ) {
- $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
+ $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now' ORDER BY post_date DESC LIMIT 1");
if ( !$gotsome )
return;
}
else
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
} else {
- $thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
- $thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
+ $thisyear = gmdate('Y', current_time('timestamp'));
+ $thismonth = gmdate('m', current_time('timestamp'));
}
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
$next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
FROM $wpdb->posts
WHERE post_date > '$thisyear-$thismonth-01'
+ AND post_date < '$now'
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
AND post_status = 'publish'
ORDER BY post_date ASC
// Get days with posts
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
- FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
- AND YEAR(post_date) = $thisyear
+ FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
+ AND YEAR(post_date) = '$thisyear'
AND post_status = 'publish'
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
if ( $dayswithposts ) {