| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
function get_header() { |
|---|
| 6 |
if ( file_exists( TEMPLATEPATH . '/header.php') ) |
|---|
| 7 |
load_template( TEMPLATEPATH . '/header.php'); |
|---|
| 8 |
else |
|---|
| 9 |
load_template( ABSPATH . 'wp-content/themes/default/header.php'); |
|---|
| 10 |
} |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
function get_footer() { |
|---|
| 14 |
if ( file_exists( TEMPLATEPATH . '/footer.php') ) |
|---|
| 15 |
load_template( TEMPLATEPATH . '/footer.php'); |
|---|
| 16 |
else |
|---|
| 17 |
load_template( ABSPATH . 'wp-content/themes/default/footer.php'); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
function get_sidebar() { |
|---|
| 22 |
if ( file_exists( TEMPLATEPATH . '/sidebar.php') ) |
|---|
| 23 |
load_template( TEMPLATEPATH . '/sidebar.php'); |
|---|
| 24 |
else |
|---|
| 25 |
load_template( ABSPATH . 'wp-content/themes/default/sidebar.php'); |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
function wp_loginout() { |
|---|
| 30 |
if ( ! is_user_logged_in() ) |
|---|
| 31 |
$link = '<a href="' . get_settings('siteurl') . '/wp-login.php">' . __('Login') . '</a>'; |
|---|
| 32 |
else |
|---|
| 33 |
$link = '<a href="' . get_settings('siteurl') . '/wp-login.php?action=logout">' . __('Logout') . '</a>'; |
|---|
| 34 |
|
|---|
| 35 |
echo apply_filters('loginout', $link); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
function wp_register( $before = '<li>', $after = '</li>' ) { |
|---|
| 40 |
|
|---|
| 41 |
if ( ! is_user_logged_in() ) { |
|---|
| 42 |
if ( get_settings('users_can_register') ) |
|---|
| 43 |
$link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after; |
|---|
| 44 |
else |
|---|
| 45 |
$link = ''; |
|---|
| 46 |
} else { |
|---|
| 47 |
$link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after; |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
echo apply_filters('register', $link); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
function wp_meta() { |
|---|
| 55 |
do_action('wp_meta'); |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
function bloginfo($show='') { |
|---|
| 60 |
$info = get_bloginfo($show); |
|---|
| 61 |
if (!strstr($show, 'url') && |
|---|
| 62 |
!strstr($show, 'directory') && |
|---|
| 63 |
!strstr($show, 'home')) { |
|---|
| 64 |
$info = apply_filters('bloginfo', $info, $show); |
|---|
| 65 |
$info = convert_chars($info); |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
echo $info; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
function get_bloginfo($show='') { |
|---|
| 73 |
|
|---|
| 74 |
switch($show) { |
|---|
| 75 |
case 'url' : |
|---|
| 76 |
case 'home' : |
|---|
| 77 |
case 'siteurl' : |
|---|
| 78 |
$output = get_settings('home'); |
|---|
| 79 |
break; |
|---|
| 80 |
case 'wpurl' : |
|---|
| 81 |
$output = get_settings('siteurl'); |
|---|
| 82 |
break; |
|---|
| 83 |
case 'description': |
|---|
| 84 |
$output = get_settings('blogdescription'); |
|---|
| 85 |
break; |
|---|
| 86 |
case 'rdf_url': |
|---|
| 87 |
$output = get_feed_link('rdf'); |
|---|
| 88 |
break; |
|---|
| 89 |
case 'rss_url': |
|---|
| 90 |
$output = get_feed_link('rss'); |
|---|
| 91 |
break; |
|---|
| 92 |
case 'rss2_url': |
|---|
| 93 |
$output = get_feed_link('rss2'); |
|---|
| 94 |
break; |
|---|
| 95 |
case 'atom_url': |
|---|
| 96 |
$output = get_feed_link('atom'); |
|---|
| 97 |
break; |
|---|
| 98 |
case 'comments_rss2_url': |
|---|
| 99 |
$output = get_feed_link('comments_rss2'); |
|---|
| 100 |
break; |
|---|
| 101 |
case 'pingback_url': |
|---|
| 102 |
$output = get_settings('siteurl') .'/xmlrpc.php'; |
|---|
| 103 |
break; |
|---|
| 104 |
case 'stylesheet_url': |
|---|
| 105 |
$output = get_stylesheet_uri(); |
|---|
| 106 |
break; |
|---|
| 107 |
case 'stylesheet_directory': |
|---|
| 108 |
$output = get_stylesheet_directory_uri(); |
|---|
| 109 |
break; |
|---|
| 110 |
case 'template_directory': |
|---|
| 111 |
case 'template_url': |
|---|
| 112 |
$output = get_template_directory_uri(); |
|---|
| 113 |
break; |
|---|
| 114 |
case 'admin_email': |
|---|
| 115 |
$output = get_settings('admin_email'); |
|---|
| 116 |
break; |
|---|
| 117 |
case 'charset': |
|---|
| 118 |
$output = get_settings('blog_charset'); |
|---|
| 119 |
if ('' == $output) $output = 'UTF-8'; |
|---|
| 120 |
break; |
|---|
| 121 |
case 'html_type' : |
|---|
| 122 |
$output = get_option('html_type'); |
|---|
| 123 |
break; |
|---|
| 124 |
case 'version': |
|---|
| 125 |
global $wp_version; |
|---|
| 126 |
$output = $wp_version; |
|---|
| 127 |
break; |
|---|
| 128 |
case 'name': |
|---|
| 129 |
default: |
|---|
| 130 |
$output = get_settings('blogname'); |
|---|
| 131 |
break; |
|---|
| 132 |
} |
|---|
| 133 |
return $output; |
|---|
| 134 |
} |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
function wp_title($sep = '»', $display = true) { |
|---|
| 138 |
global $wpdb; |
|---|
| 139 |
global $m, $year, $monthnum, $day, $category_name, $wp_locale, $posts; |
|---|
| 140 |
|
|---|
| 141 |
$cat = get_query_var('cat'); |
|---|
| 142 |
$p = get_query_var('p'); |
|---|
| 143 |
$name = get_query_var('name'); |
|---|
| 144 |
$category_name = get_query_var('category_name'); |
|---|
| 145 |
$author = get_query_var('author'); |
|---|
| 146 |
$author_name = get_query_var('author_name'); |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
if ( !empty($cat) ) { |
|---|
| 150 |
|
|---|
| 151 |
if ( !stristr($cat,'-') ) |
|---|
| 152 |
$title = get_the_category_by_ID($cat); |
|---|
| 153 |
} |
|---|
| 154 |
if ( !empty($category_name) ) { |
|---|
| 155 |
if ( stristr($category_name,'/') ) { |
|---|
| 156 |
$category_name = explode('/',$category_name); |
|---|
| 157 |
if ( $category_name[count($category_name)-1] ) |
|---|
| 158 |
$category_name = $category_name[count($category_name)-1]; |
|---|
| 159 |
else |
|---|
| 160 |
$category_name = $category_name[count($category_name)-2]; |
|---|
| 161 |
} |
|---|
| 162 |
$title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"); |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
if ( !empty($author) ) { |
|---|
| 167 |
$title = get_userdata($author); |
|---|
| 168 |
$title = $title->display_name; |
|---|
| 169 |
} |
|---|
| 170 |
if ( !empty($author_name) ) { |
|---|
| 171 |
|
|---|
| 172 |
$title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'"); |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
if ( !empty($m) ) { |
|---|
| 177 |
$my_year = substr($m, 0, 4); |
|---|
| 178 |
$my_month = $wp_locale->get_month($m); |
|---|
| 179 |
$title = "$my_year $sep $my_month"; |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
if ( !empty($year) ) { |
|---|
| 183 |
$title = $year; |
|---|
| 184 |
if ( !empty($monthnum) ) |
|---|
| 185 |
$title .= " $sep ".$wp_locale->get_month($monthnum); |
|---|
| 186 |
if ( !empty($day) ) |
|---|
| 187 |
$title .= " $sep ".zeroise($day, 2); |
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
if ( is_single() || is_page() ) { |
|---|
| 192 |
$title = strip_tags($posts[0]->post_title); |
|---|
| 193 |
$title = apply_filters('single_post_title', $title); |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
$prefix = ''; |
|---|
| 197 |
if ( isset($title) ) |
|---|
| 198 |
$prefix = " $sep "; |
|---|
| 199 |
|
|---|
| 200 |
$title = $prefix . $title; |
|---|
| 201 |
$title = apply_filters('wp_title', $title, $sep); |
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
if ( $display ) |
|---|
| 205 |
echo $title; |
|---|
| 206 |
else |
|---|
| 207 |
return $title; |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
function single_post_title($prefix = '', $display = true) { |
|---|
| 212 |
global $wpdb; |
|---|
| 213 |
$p = get_query_var('p'); |
|---|
| 214 |
$name = get_query_var('name'); |
|---|
| 215 |
|
|---|
| 216 |
if ( intval($p) || '' != $name ) { |
|---|
| 217 |
if ( !$p ) |
|---|
| 218 |
$p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'"); |
|---|
| 219 |
$post = & get_post($p); |
|---|
| 220 |
$title = $post->post_title; |
|---|
| 221 |
$title = apply_filters('single_post_title', $title); |
|---|
| 222 |
if ( $display ) |
|---|
| 223 |
echo $prefix.strip_tags($title); |
|---|
| 224 |
else |
|---|
| 225 |
return strip_tags($title); |
|---|
| 226 |
} |
|---|
| 227 |
} |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
function single_cat_title($prefix = '', $display = true ) { |
|---|
| 231 |
$cat = intval( get_query_var('cat') ); |
|---|
| 232 |
if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) { |
|---|
| 233 |
$my_cat_name = get_the_category_by_ID($cat); |
|---|
| 234 |
if ( !empty($my_cat_name) ) { |
|---|
| 235 |
if ( $display ) |
|---|
| 236 |
echo $prefix.strip_tags($my_cat_name); |
|---|
| 237 |
else |
|---|
| 238 |
return strip_tags($my_cat_name); |
|---|
| 239 |
} |
|---|
| 240 |
} |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
function single_month_title($prefix = '', $display = true ) { |
|---|
| 245 |
global $m, $monthnum, $wp_locale, $year; |
|---|
| 246 |
if ( !empty($monthnum) && !empty($year) ) { |
|---|
| 247 |
$my_year = $year; |
|---|
| 248 |
$my_month = $wp_locale->get_month($monthnum); |
|---|
| 249 |
} elseif ( !empty($m) ) { |
|---|
| 250 |
$my_year = substr($m, 0, 4); |
|---|
| 251 |
$my_month = $wp_locale->get_month($m); |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
if ( !empty($my_month) && $display ) |
|---|
| 255 |
echo $prefix . $my_month . $prefix . $my_year; |
|---|
| 256 |
else |
|---|
| 257 |
return $monthnum; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { |
|---|
| 263 |
$text = wptexturize($text); |
|---|
| 264 |
$title_text = wp_specialchars($text, 1); |
|---|
| 265 |
|
|---|
| 266 |
if ('link' == $format) |
|---|
| 267 |
return "\t<link rel='archives' title='$title_text' href='$url' />\n"; |
|---|
| 268 |
elseif ('option' == $format) |
|---|
| 269 |
return "\t<option value='$url'>$before $text $after</option>\n"; |
|---|
| 270 |
elseif ('html' == $format) |
|---|
| 271 |
return "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n"; |
|---|
| 272 |
else |
|---|
| 273 |
return "\t$before<a href='$url' title='$title_text'>$text</a>$after\n"; |
|---|
| 274 |
} |
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
function wp_get_archives($args = '') { |
|---|
| 278 |
global $wp_locale, $wpdb; |
|---|
| 279 |
|
|---|
| 280 |
if ( is_array($args) ) |
|---|
| 281 |
$r = &$args; |
|---|
| 282 |
else |
|---|
| 283 |
parse_str($args, $r); |
|---|
| 284 |
|
|---|
| 285 |
$defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false); |
|---|
| 286 |
$r = array_merge($defaults, $r); |
|---|
| 287 |
extract($r); |
|---|
| 288 |
|
|---|
| 289 |
if ( '' == $type ) |
|---|
| 290 |
$type = 'monthly'; |
|---|
| 291 |
|
|---|
| 292 |
if ( '' != $limit ) { |
|---|
| 293 |
$limit = (int) $limit; |
|---|
| 294 |
$limit = ' LIMIT '.$limit; |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
$archive_week_separator = '–'; |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
$archive_date_format_over_ride = 0; |
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 |
$archive_day_date_format = 'Y/m/d'; |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
$archive_week_start_date_format = 'Y/m/d'; |
|---|
| 308 |
$archive_week_end_date_format = 'Y/m/d'; |
|---|
| 309 |
|
|---|
| 310 |
if ( !$archive_date_format_over_ride ) { |
|---|
| 311 |
$archive_day_date_format = get_settings('date_format'); |
|---|
| 312 |
$archive_week_start_date_format = get_settings('date_format'); |
|---|
| 313 |
$archive_week_end_date_format = get_settings('date_format'); |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
$add_hours = intval(get_settings('gmt_offset')); |
|---|
| 317 |
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); |
|---|
| 318 |
|
|---|
| 319 |
if ( 'monthly' == $type ) { |
|---|
| 320 |
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); |
|---|
| 321 |
if ( $arcresults ) { |
|---|
| 322 |
$afterafter = $after; |
|---|
| 323 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 324 |
$url = get_month_link($arcresult->year, $arcresult->month); |
|---|
| 325 |
if ( $show_post_count ) { |
|---|
| 326 |
$text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); |
|---|
| 327 |
$after = ' ('.$arcresult->posts.')' . $afterafter; |
|---|
| 328 |
} else { |
|---|
| 329 |
$text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); |
|---|
| 330 |
} |
|---|
| 331 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 332 |
} |
|---|
| 333 |
} |
|---|
| 334 |
} elseif ( 'daily' == $type ) { |
|---|
| 335 |
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); |
|---|
| 336 |
if ( $arcresults ) { |
|---|
| 337 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 338 |
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); |
|---|
| 339 |
$date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); |
|---|
| 340 |
$text = mysql2date($archive_day_date_format, $date); |
|---|
| 341 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 342 |
} |
|---|
| 343 |
} |
|---|
| 344 |
} elseif ( 'weekly' == $type ) { |
|---|
| 345 |
$start_of_week = get_settings('start_of_week'); |
|---|
| 346 |
$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); |
|---|
| 347 |
$arc_w_last = ''; |
|---|
| 348 |
if ( $arcresults ) { |
|---|
| 349 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 350 |
if ( $arcresult->week != $arc_w_last ) { |
|---|
| 351 |
$arc_year = $arcresult->yr; |
|---|
| 352 |
$arc_w_last = $arcresult->week; |
|---|
| 353 |
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week')); |
|---|
| 354 |
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); |
|---|
| 355 |
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); |
|---|
| 356 |
$url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); |
|---|
| 357 |
$text = $arc_week_start . $archive_week_separator . $arc_week_end; |
|---|
| 358 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 359 |
} |
|---|
| 360 |
} |
|---|
| 361 |
} |
|---|
| 362 |
} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { |
|---|
| 363 |
('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; |
|---|
| 364 |
$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit"); |
|---|
| 365 |
if ( $arcresults ) { |
|---|
| 366 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 367 |
if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { |
|---|
| 368 |
$url = get_permalink($arcresult); |
|---|
| 369 |
$arc_title = $arcresult->post_title; |
|---|
| 370 |
if ( $arc_title ) |
|---|
| 371 |
$text = strip_tags($arc_title); |
|---|
| 372 |
else |
|---|
| 373 |
$text = $arcresult->ID; |
|---|
| 374 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 375 |
} |
|---|
| 376 |
} |
|---|
| 377 |
} |
|---|
| 378 |
} |
|---|
| 379 |
} |
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
function calendar_week_mod($num) { |
|---|
| 384 |
$base = 7; |
|---|
| 385 |
return ($num - $base*floor($num/$base)); |
|---|
| 386 |
} |
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
function get_calendar($initial = true) { |
|---|
| 390 |
global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts; |
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
if ( !$posts ) { |
|---|
| 394 |
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); |
|---|
| 395 |
if ( !$gotsome ) |
|---|
| 396 |
return; |
|---|
| 397 |
} |
|---|
| 398 |
|
|---|
| 399 |
if ( isset($_GET['w']) ) |
|---|
| 400 |
$w = ''.intval($_GET['w']); |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
$week_begins = intval(get_settings('start_of_week')); |
|---|
| 404 |
$add_hours = intval(get_settings('gmt_offset')); |
|---|
| 405 |
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); |
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
if ( !empty($monthnum) && !empty($year) ) { |
|---|
| 409 |
$thismonth = ''.zeroise(intval($monthnum), 2); |
|---|
| 410 |
$thisyear = ''.intval($year); |
|---|
| 411 |
} elseif ( !empty($w) ) { |
|---|
| 412 |
|
|---|
| 413 |
$thisyear = ''.intval(substr($m, 0, 4)); |
|---|
| 414 |
$d = (($w - 1) * 7) + 6; |
|---|
| 415 |
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); |
|---|
| 416 |
} elseif ( !empty($m) ) { |
|---|
| 417 |
$calendar = substr($m, 0, 6); |
|---|
| 418 |
$thisyear = ''.intval(substr($m, 0, 4)); |
|---|
| 419 |
if ( strlen($m) < 6 ) |
|---|
| 420 |
$thismonth = '01'; |
|---|
| 421 |
else |
|---|
| 422 |
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); |
|---|
| 423 |
} else { |
|---|
| 424 |
$thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600); |
|---|
| 425 |
$thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600); |
|---|
| 426 |
} |
|---|
| 427 |
|
|---|
| 428 |
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); |
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
$previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year |
|---|
| 432 |
FROM $wpdb->posts |
|---|
| 433 |
WHERE post_date < '$thisyear-$thismonth-01' |
|---|
| 434 |
AND post_type = 'post' AND post_status = 'publish' |
|---|
| 435 |
ORDER BY post_date DESC |
|---|
| 436 |
LIMIT 1"); |
|---|
| 437 |
$next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year |
|---|
| 438 |
FROM $wpdb->posts |
|---|
| 439 |
WHERE post_date > '$thisyear-$thismonth-01' |
|---|
| 440 |
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) |
|---|
| 441 |
AND post_type = 'post' AND post_status = 'publish' |
|---|
| 442 |
ORDER BY post_date ASC |
|---|
| 443 |
LIMIT 1"); |
|---|
| 444 |
|
|---|
| 445 |
echo '<table id="wp-calendar"> |
|---|
| 446 |
<caption>' . $wp_locale->get_month($thismonth) . ' ' . date('Y', $unixmonth) . '</caption> |
|---|
| 447 |
<thead> |
|---|
| 448 |
<tr>'; |
|---|
| 449 |
|
|---|
| 450 |
$myweek = array(); |
|---|
| 451 |
|
|---|
| 452 |
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { |
|---|
| 453 |
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); |
|---|
| 454 |
} |
|---|
| 455 |
|
|---|
| 456 |
foreach ( $myweek as $wd ) { |
|---|
| 457 |
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial |
|---|