| 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 |
global $user_ID; |
|---|
| 31 |
get_currentuserinfo(); |
|---|
| 32 |
|
|---|
| 33 |
if ('' == $user_ID) |
|---|
| 34 |
$link = '<a href="' . get_settings('home') . '/wp-login.php">' . __('Login') . '</a>'; |
|---|
| 35 |
else |
|---|
| 36 |
$link = '<a href="' . get_settings('home') . '/wp-login.php?action=logout">' . __('Logout') . '</a>'; |
|---|
| 37 |
|
|---|
| 38 |
echo apply_filters('loginout', $link); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
function wp_register( $before = '<li>', $after = '</li>' ) { |
|---|
| 43 |
global $user_ID, $blog, $blogdata; |
|---|
| 44 |
|
|---|
| 45 |
get_currentuserinfo(); |
|---|
| 46 |
|
|---|
| 47 |
if ( '' == $user_ID && get_settings('users_can_register') ) |
|---|
| 48 |
$link = ''; |
|---|
| 49 |
elseif ('' == $user_ID && !get_settings('users_can_register') ) |
|---|
| 50 |
$link = ''; |
|---|
| 51 |
else |
|---|
| 52 |
$link = $before . '<a href="' . get_settings('home') . "/admin/\">" . __('Site Admin') . '</a>' . $after; |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
echo apply_filters('register', $link); |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
function wp_meta() { |
|---|
| 60 |
do_action('wp_meta'); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
function bloginfo($show='') { |
|---|
| 65 |
$info = get_bloginfo($show); |
|---|
| 66 |
if ( ! (strstr($info, 'url') || strstr($info, 'directory')) ) { |
|---|
| 67 |
$info = apply_filters('bloginfo', $info, $show); |
|---|
| 68 |
$info = convert_chars($info); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
echo $info; |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
function get_bloginfo($show='') { |
|---|
| 76 |
|
|---|
| 77 |
switch($show) { |
|---|
| 78 |
case 'url' : |
|---|
| 79 |
case 'home' : |
|---|
| 80 |
case 'siteurl' : |
|---|
| 81 |
$output = get_settings('home'); |
|---|
| 82 |
break; |
|---|
| 83 |
case 'wpurl' : |
|---|
| 84 |
$output = get_settings('siteurl'); |
|---|
| 85 |
break; |
|---|
| 86 |
case 'description': |
|---|
| 87 |
$output = get_settings('blogdescription'); |
|---|
| 88 |
break; |
|---|
| 89 |
case 'rdf_url': |
|---|
| 90 |
$output = get_feed_link('rdf'); |
|---|
| 91 |
break; |
|---|
| 92 |
case 'rss_url': |
|---|
| 93 |
$output = get_feed_link('rss'); |
|---|
| 94 |
break; |
|---|
| 95 |
case 'rss2_url': |
|---|
| 96 |
$output = get_feed_link('rss2'); |
|---|
| 97 |
break; |
|---|
| 98 |
case 'atom_url': |
|---|
| 99 |
$output = get_feed_link('atom'); |
|---|
| 100 |
break; |
|---|
| 101 |
case 'comments_rss2_url': |
|---|
| 102 |
$output = get_feed_link('comments_rss2'); |
|---|
| 103 |
break; |
|---|
| 104 |
case 'pingback_url': |
|---|
| 105 |
$output = get_settings('siteurl') .'/xmlrpc.php'; |
|---|
| 106 |
break; |
|---|
| 107 |
case 'stylesheet_url': |
|---|
| 108 |
$output = get_stylesheet_uri(); |
|---|
| 109 |
break; |
|---|
| 110 |
case 'stylesheet_directory': |
|---|
| 111 |
$output = get_stylesheet_directory_uri(); |
|---|
| 112 |
break; |
|---|
| 113 |
case 'template_directory': |
|---|
| 114 |
case 'template_url': |
|---|
| 115 |
$output = get_template_directory_uri(); |
|---|
| 116 |
break; |
|---|
| 117 |
case 'admin_email': |
|---|
| 118 |
$output = get_settings('admin_email'); |
|---|
| 119 |
break; |
|---|
| 120 |
case 'charset': |
|---|
| 121 |
$output = get_settings('blog_charset'); |
|---|
| 122 |
if ('' == $output) $output = 'UTF-8'; |
|---|
| 123 |
break; |
|---|
| 124 |
case 'html_type' : |
|---|
| 125 |
$output = get_option('html_type'); |
|---|
| 126 |
break; |
|---|
| 127 |
case 'version': |
|---|
| 128 |
global $wp_version; |
|---|
| 129 |
$output = $wp_version; |
|---|
| 130 |
break; |
|---|
| 131 |
case 'name': |
|---|
| 132 |
default: |
|---|
| 133 |
$output = get_settings('blogname'); |
|---|
| 134 |
break; |
|---|
| 135 |
} |
|---|
| 136 |
return $output; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
function wp_title($sep = '»', $display = true) { |
|---|
| 141 |
global $wpdb; |
|---|
| 142 |
global $m, $year, $monthnum, $day, $category_name, $month, $posts; |
|---|
| 143 |
|
|---|
| 144 |
$cat = get_query_var('cat'); |
|---|
| 145 |
$p = get_query_var('p'); |
|---|
| 146 |
$name = get_query_var('name'); |
|---|
| 147 |
$category_name = get_query_var('category_name'); |
|---|
| 148 |
$author = get_query_var('author'); |
|---|
| 149 |
$author_name = get_query_var('author_name'); |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
if(!empty($cat)) { |
|---|
| 153 |
if (!stristr($cat,'-')) { |
|---|
| 154 |
$title = get_the_category_by_ID($cat); |
|---|
| 155 |
} |
|---|
| 156 |
} |
|---|
| 157 |
if (!empty($category_name)) { |
|---|
| 158 |
if (stristr($category_name,'/')) { |
|---|
| 159 |
$category_name = explode('/',$category_name); |
|---|
| 160 |
if ($category_name[count($category_name)-1]) { |
|---|
| 161 |
$category_name = $category_name[count($category_name)-1]; |
|---|
| 162 |
} else { |
|---|
| 163 |
$category_name = $category_name[count($category_name)-2]; |
|---|
| 164 |
} |
|---|
| 165 |
} |
|---|
| 166 |
$title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE blog = '$blog' AND category_nicename = '$category_name'"); |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
if ( !empty($author) ) { |
|---|
| 171 |
$title = get_userdata($author); |
|---|
| 172 |
$title = $title->display_name; |
|---|
| 173 |
} |
|---|
| 174 |
if ( !empty($author_name) ) { |
|---|
| 175 |
|
|---|
| 176 |
$title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'"); |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
if ( !empty($m) ) { |
|---|
| 181 |
$my_year = substr($m, 0, 4); |
|---|
| 182 |
$my_month = $month[substr($m, 4, 2)]; |
|---|
| 183 |
$title = "$my_year $sep $my_month"; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
if (!empty($year)) { |
|---|
| 188 |
$title = $year; |
|---|
| 189 |
if (!empty($monthnum)) { |
|---|
| 190 |
$title .= " $sep ".$month[zeroise($monthnum, 2)]; |
|---|
| 191 |
} |
|---|
| 192 |
if (!empty($day)) { |
|---|
| 193 |
$title .= " $sep ".zeroise($day, 2); |
|---|
| 194 |
} |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
if (is_single() || is_page()) { |
|---|
| 199 |
$title = strip_tags($posts[0]->post_title); |
|---|
| 200 |
$title = apply_filters('single_post_title', $title); |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
$prefix = ''; |
|---|
| 204 |
if ( isset($title) ) |
|---|
| 205 |
$prefix = " $sep "; |
|---|
| 206 |
|
|---|
| 207 |
$title = $prefix . $title; |
|---|
| 208 |
$title = apply_filters('wp_title', $title, $sep); |
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
if ( $display ) |
|---|
| 212 |
echo $title; |
|---|
| 213 |
else |
|---|
| 214 |
return $title; |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
function single_post_title($prefix = '', $display = true) { |
|---|
| 219 |
global $wpdb; |
|---|
| 220 |
$p = get_query_var('p'); |
|---|
| 221 |
$name = get_query_var('name'); |
|---|
| 222 |
if (intval($p) || '' != $name) { |
|---|
| 223 |
if (!$p) { |
|---|
| 224 |
$p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE blog = '$blog' AND post_name = '$name'"); |
|---|
| 225 |
} |
|---|
| 226 |
$post = & get_post($p); |
|---|
| 227 |
$title = $post->post_title; |
|---|
| 228 |
$title = apply_filters('single_post_title', $title); |
|---|
| 229 |
if ($display) { |
|---|
| 230 |
echo $prefix.strip_tags($title); |
|---|
| 231 |
} else { |
|---|
| 232 |
return strip_tags($title); |
|---|
| 233 |
} |
|---|
| 234 |
} |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
function single_cat_title($prefix = '', $display = true ) { |
|---|
| 239 |
$cat = intval( get_query_var('cat') ); |
|---|
| 240 |
if( !empty($cat) && !(strtoupper($cat) == 'ALL') ) { |
|---|
| 241 |
$my_cat_name = get_the_category_by_ID($cat); |
|---|
| 242 |
if( !empty($my_cat_name) ) { |
|---|
| 243 |
if ($display) |
|---|
| 244 |
echo $prefix.strip_tags($my_cat_name); |
|---|
| 245 |
else |
|---|
| 246 |
return strip_tags($my_cat_name); |
|---|
| 247 |
} |
|---|
| 248 |
} |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
function single_month_title($prefix = '', $display = true ) { |
|---|
| 253 |
global $m, $monthnum, $month, $year; |
|---|
| 254 |
if(!empty($monthnum) && !empty($year)) { |
|---|
| 255 |
$my_year = $year; |
|---|
| 256 |
$my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)]; |
|---|
| 257 |
} elseif(!empty($m)) { |
|---|
| 258 |
$my_year = substr($m, 0, 4); |
|---|
| 259 |
$my_month = $month[substr($m, 4, 2)]; |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
if (!empty($my_month) && $display) { |
|---|
| 263 |
echo $prefix . $my_month . $prefix . $my_year; |
|---|
| 264 |
} else { |
|---|
| 265 |
return $monthnum; |
|---|
| 266 |
} |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { |
|---|
| 275 |
$text = wptexturize($text); |
|---|
| 276 |
$title_text = wp_specialchars($text, 1); |
|---|
| 277 |
|
|---|
| 278 |
if ('link' == $format) |
|---|
| 279 |
return "\t<link rel='archives' title='$title_text' href='$url' />\n"; |
|---|
| 280 |
elseif ('option' == $format) |
|---|
| 281 |
return "\t<option value='$url'>$before $text $after</option>\n"; |
|---|
| 282 |
elseif ('html' == $format) |
|---|
| 283 |
return "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n"; |
|---|
| 284 |
else |
|---|
| 285 |
return "\t$before<a href='$url' title='$title_text'>$text</a>$after\n"; |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
function wp_get_archives($args = '') { |
|---|
| 290 |
parse_str($args, $r); |
|---|
| 291 |
if (!isset($r['type'])) $r['type'] = ''; |
|---|
| 292 |
if (!isset($r['limit'])) $r['limit'] = ''; |
|---|
| 293 |
if (!isset($r['format'])) $r['format'] = 'html'; |
|---|
| 294 |
if (!isset($r['before'])) $r['before'] = ''; |
|---|
| 295 |
if (!isset($r['after'])) $r['after'] = ''; |
|---|
| 296 |
if (!isset($r['show_post_count'])) $r['show_post_count'] = false; |
|---|
| 297 |
get_archives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']); |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { |
|---|
| 302 |
global $month, $wpdb, $blog; |
|---|
| 303 |
|
|---|
| 304 |
if ('' == $type) { |
|---|
| 305 |
$type = 'monthly'; |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
if ('' != $limit) { |
|---|
| 309 |
$limit = (int) $limit; |
|---|
| 310 |
$limit = ' LIMIT '.$limit; |
|---|
| 311 |
} |
|---|
| 312 |
|
|---|
| 313 |
$archive_week_separator = '–'; |
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
$archive_date_format_over_ride = 0; |
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
$archive_day_date_format = 'Y/m/d'; |
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
$archive_week_start_date_format = 'Y/m/d'; |
|---|
| 323 |
$archive_week_end_date_format = 'Y/m/d'; |
|---|
| 324 |
|
|---|
| 325 |
if (!$archive_date_format_over_ride) { |
|---|
| 326 |
$archive_day_date_format = get_settings('date_format'); |
|---|
| 327 |
$archive_week_start_date_format = get_settings('date_format'); |
|---|
| 328 |
$archive_week_end_date_format = get_settings('date_format'); |
|---|
| 329 |
} |
|---|
| 330 |
|
|---|
| 331 |
$add_hours = intval(get_settings('gmt_offset')); |
|---|
| 332 |
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); |
|---|
| 333 |
|
|---|
| 334 |
$now = current_time('mysql'); |
|---|
| 335 |
|
|---|
| 336 |
if ( 'monthly' == $type ) { |
|---|
| 337 |
$arcresults = $wpdb->get_post_results("DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts", "post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); |
|---|
| 338 |
if ( $arcresults ) { |
|---|
| 339 |
$afterafter = $after; |
|---|
| 340 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 341 |
$url = get_month_link($arcresult->year, $arcresult->month); |
|---|
| 342 |
if ( $show_post_count ) { |
|---|
| 343 |
$text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); |
|---|
| 344 |
$after = ' ('.$arcresult->posts.')' . $afterafter; |
|---|
| 345 |
} else { |
|---|
| 346 |
$text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); |
|---|
| 347 |
} |
|---|
| 348 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 349 |
} |
|---|
| 350 |
} |
|---|
| 351 |
} elseif ( 'daily' == $type ) { |
|---|
| 352 |
$arcresults = $wpdb->get_post_results("DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`", "post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); |
|---|
| 353 |
if ( $arcresults ) { |
|---|
| 354 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 355 |
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); |
|---|
| 356 |
$date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); |
|---|
| 357 |
$text = mysql2date($archive_day_date_format, $date); |
|---|
| 358 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 359 |
} |
|---|
| 360 |
} |
|---|
| 361 |
} elseif ( 'weekly' == $type ) { |
|---|
| 362 |
$start_of_week = get_settings('start_of_week'); |
|---|
| 363 |
$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_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); |
|---|
| 364 |
$arc_w_last = ''; |
|---|
| 365 |
if ( $arcresults ) { |
|---|
| 366 |
foreach ( $arcresults as $arcresult ) { |
|---|
| 367 |
if ( $arcresult->week != $arc_w_last ) { |
|---|
| 368 |
$arc_year = $arcresult->yr; |
|---|
| 369 |
$arc_w_last = $arcresult->week; |
|---|
| 370 |
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week')); |
|---|
| 371 |
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); |
|---|
| 372 |
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); |
|---|
| 373 |
$url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); |
|---|
| 374 |
$text = $arc_week_start . $archive_week_separator . $arc_week_end; |
|---|
| 375 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 376 |
} |
|---|
| 377 |
} |
|---|
| 378 |
} |
|---|
| 379 |
} elseif ('postbypost' == $type) { |
|---|
| 380 |
$arcresults = $wpdb->get_post_results("*", "post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); |
|---|
| 381 |
if ($arcresults) { |
|---|
| 382 |
foreach ($arcresults as $arcresult) { |
|---|
| 383 |
if ($arcresult->post_date != '0000-00-00 00:00:00') { |
|---|
| 384 |
$url = get_permalink($arcresult); |
|---|
| 385 |
$arc_title = $arcresult->post_title; |
|---|
| 386 |
if ($arc_title) { |
|---|
| 387 |
$text = strip_tags($arc_title); |
|---|
| 388 |
} else { |
|---|
| 389 |
$text = $arcresult->ID; |
|---|
| 390 |
} |
|---|
| 391 |
echo get_archives_link($url, $text, $format, $before, $after); |
|---|
| 392 |
} |
|---|
| 393 |
} |
|---|
| 394 |
} |
|---|
| 395 |
} |
|---|
| 396 |
} |
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
function calendar_week_mod($num) { |
|---|
| 401 |
$base = 7; |
|---|
| 402 |
return ($num - $base*floor($num/$base)); |
|---|
| 403 |
} |
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
function get_calendar($daylength = 1) { |
|---|
| 407 |
global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts; |
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
if (!$posts) { |
|---|
| 411 |
|
|---|
| 412 |
$gotsome = $wpdb->get_post_var("ID", "post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); |
|---|
| 413 |
if (!$gotsome) |
|---|
| 414 |
return; |
|---|
| 415 |
} |
|---|
| 416 |
|
|---|
| 417 |
if (isset($_GET['w'])) { |
|---|
| 418 |
$w = ''.intval($_GET['w']); |
|---|
| 419 |
} |
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
$week_begins = intval(get_settings('start_of_week')); |
|---|
| 423 |
$add_hours = intval(get_settings('gmt_offset')); |
|---|
| 424 |
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); |
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
if (!empty($monthnum) && !empty($year)) { |
|---|
| 428 |
$thismonth = ''.zeroise(intval($monthnum), 2); |
|---|
| 429 |
$thisyear = ''.intval($year); |
|---|
| 430 |
} elseif (!empty($w)) { |
|---|
| 431 |
|
|---|
| 432 |
$thisyear = ''.intval(substr($m, 0, 4)); |
|---|
| 433 |
$d = (($w - 1) * 7) + 6; |
|---|
| 434 |
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); |
|---|
| 435 |
} elseif (!empty($m)) { |
|---|
| 436 |
$calendar = substr($m, 0, 6); |
|---|
| 437 |
$thisyear = ''.intval(substr($m, 0, 4)); |
|---|
| 438 |
if (strlen($m) < 6) { |
|---|
| 439 |
$thismonth = '01'; |
|---|
| 440 |
} else { |
|---|
| 441 |
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); |
|---|
| 442 |
} |
|---|
| 443 |
} else { |
|---|
| 444 |
$thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600); |
|---|
| 445 |
$thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600); |
|---|
| 446 |
} |
|---|
| 447 |
|
|---|
| 448 |
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
/* $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year |
|---|
| 452 |
FROM $wpdb->posts |
|---|
| 453 |
WHERE blog = '$blog' |
|---|
| 454 |
AND post_date < '$thisyear-$thismonth-01' |
|---|
| 455 |
AND post_status = 'publish' |
|---|
| 456 |
ORDER BY post_date DESC |
|---|
| 457 |
LIMIT 1");*/ |
|---|
| 458 |
|
|---|
| 459 |
$previous = $wpdb->get_post_row("DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year", " |
|---|
| 460 |
post_date < '$thisyear-$thismonth-01' AND |
|---|
| 461 |
post_status = 'publish' |
|---|
| 462 |
ORDER BY post_date DESC |
|---|
| 463 |
LIMIT 1"); |
|---|
| 464 |
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
$next = $wpdb->get_post_row("DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year", " |
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 |
); |
|---|
| 480 |
|
|---|
| 481 |
'<table id="wp-calendar"> |
|---|
| 482 |
. $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption> |
|---|
| 483 |
|
|---|
| 484 |
; |
|---|
| 485 |
|
|---|
| 486 |
$day_abbrev = $weekday_initial; |
|---|
| 487 |
$daylength > 1) { |
|---|
| 488 |
$day_abbrev = $weekday_abbrev; |
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 |
$myweek = array(); |
|---|
| 492 |
|
|---|
| 493 |
$wdcount=0; $wdcount<=6; $wdcount++) { |
|---|
| 494 |
$myweek[]=$weekday[($wdcount+$week_begins)%7]; |
|---|
| 495 |
|
|---|
| 496 |
|
|---|
| 497 |
$myweek as $wd) { |
|---|
| 498 |
"\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>'; |
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
' |
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
; |
|---|
| 507 |
|
|---|
| 508 |
$previous) { |
|---|
| 509 |
"\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' . |
|---|
| 510 |
get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>'; |
|---|
| 511 |
|
|---|
| 512 |
"\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; |
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
"\n\t\t".'<td class="pad"> </td>'; |
|---|
| 516 |
|
|---|
| 517 |
$next) { |
|---|
| 518 |
"\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' . |
|---|
| 519 |
get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' . |
|---|
| 520 |
date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' »</a></td>'; |
|---|
| 521 |
|
|---|
| 522 |
"\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
' |
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
; |
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
$dayswithposts = $wpdb->get_post_results("DISTINCT DAYOFMONTH(post_date)", " |
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
. current_time('mysql') . '\'', ARRAY_N); |
|---|
| 545 |
|
|---|
| 546 |
$dayswithposts) |
|---|
| 547 |
$dayswithposts as $daywith) |
|---|
| 548 |
$daywithpost[] = $daywith[0]; |
|---|
| 549 |
|
|---|
| 550 |
$daywithpost = array(); |
|---|
| 551 |
|
|---|
| 552 |
strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) { |
|---|
| 553 |
$ak_title_separator = "\n"; |
|---|
| 554 |
|
|---|
| 555 |
$ak_title_separator = ', '; |
|---|
| 556 |
|
|---|
| 557 |
|
|---|
| 558 |
$ak_titles_for_day = array(); |
|---|
| 559 |
|
|---|
| 560 |
$ak_post_titles = $wpdb->get_post_results("post_title, DAYOFMONTH(post_date) as dom", " |
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 |
.current_time('mysql')."' AND |
|---|
| 564 |
); |
|---|
| 565 |
|
|---|
| 566 |
$ak_post_titles) { |
|---|
| 567 |
$ak_post_titles as $ak_post_title) { |
|---|
| 568 |
$ak_titles_for_day['day_'.$ak_post_title->dom])) { |
|---|
| 569 |
$ak_titles_for_day['day_'.$ak_post_title->dom] = ''; |
|---|
| 570 |
|
|---|
| 571 |
$ak_titles_for_day["$ak_post_title->dom"])) { |
|---|
| 572 |
$ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); |
|---|
| 573 |
|
|---|
| 574 |
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); |
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); |
|---|
| 582 |
0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>'; |
|---|
| 583 |
|
|---|
| 584 |
$daysinmonth = intval(date('t', $unixmonth)); |
|---|
| 585 |
$day = 1; $day <= $daysinmonth; ++$day) { |
|---|
| 586 |
$newrow) && $newrow) |
|---|
| 587 |
"\n\t</tr>\n\t<tr>\n\t\t"; |
|---|
| 588 |
$newrow = false; |
|---|
| 589 |
|
|---|
| 590 |
$day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_settings('gmt_offset') * 3600))) |
|---|
| 591 |
'<td id="today">'; |
|---|
| 592 |
|
|---|
| 593 |
'<td>'; |
|---|
| 594 |
|
|---|
| 595 |
in_array($day, $daywithpost)) { |
|---|
| 596 |
echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>"; |
|---|
| 597 |
|
|---|
| 598 |
$day; |
|---|
| 599 |
|
|---|
| 600 |
'</td>'; |
|---|
| 601 |
|
|---|
| 602 |
6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins)) |
|---|
| 603 |
$newrow = true; |
|---|
| 604 |
|
|---|
| 605 |
|
|---|
| 606 |
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); |
|---|
| 607 |
$pad != 0 && $pad != 7) |
|---|
| 608 |
"\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>'; |
|---|
| 609 |
|
|---|
| 610 |
"\n\t</tr>\n\t</tbody>\n\t</table>"; |
|---|
| 611 |
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
allowed_tags() { |
|---|
| 615 |
$allowedtags; |
|---|
| 616 |
$allowed = ''; |
|---|
| 617 |
$allowedtags as $tag => $attributes) { |
|---|
| 618 |
$allowed .= '<'.$tag; |
|---|
| 619 |
0 < count($attributes)) { |
|---|
| 620 |
$attributes as $attribute => $limits) { |
|---|
| 621 |
$allowed .= ' '.$attribute.'=""'; |
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
$allowed .= '> '; |
|---|
| 625 |
|
|---|
| 626 |
htmlentities($allowed); |
|---|
| 627 |
|
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 |
|
|---|
| 631 |
|
|---|
| 632 |
|
|---|
| 633 |
function the_date_xml() { |
|---|
| 634 |
global $post; |
|---|
| 635 |
echo mysql2date('Y-m-d', $post->post_date); |
|---|
| 636 |
|
|---|
| 637 |
} |
|---|
| 638 |
|
|---|
| 639 |
|
|---|
| 640 |
function the_date($d='', $before='', $after='', $echo = true) { |
|---|
| 641 |
global $id, $post, $day, $previousday, $newday; |
|---|
| 642 |
$the_date = ''; |
|---|
| 643 |
if ($day != $previousday) { |
|---|
| 644 |
$the_date .= $before; |
|---|
| 645 |
if ($d=='') { |
|---|
| 646 |
$the_date .= mysql2date(get_settings('date_format'), $post->post_date); |
|---|
| 647 |
} else { |
|---|
| 648 |
$the_date .= mysql2date($d, $post->post_date); |
|---|
| 649 |
} |
|---|
| 650 |
$the_date .= $after; |
|---|
| 651 |
$previousday = $day; |
|---|
| 652 |
} |
|---|
| 653 |
$the_date = apply_filters('the_date', $the_date, $d, $before, $after); |
|---|
| 654 |
if ($echo) { |
|---|
| 655 |
echo $the_date; |
|---|
| 656 |
} else { |
|---|
| 657 |
return $the_date; |
|---|
| 658 |
} |
|---|
| 659 |
} |
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 |
function the_time( $d = '' ) { |
|---|
| 663 |
echo apply_filters('the_time', get_the_time( $d ), $d); |
|---|
| 664 |
} |
|---|
| 665 |
|
|---|
| 666 |
|
|---|
| 667 |
function get_the_time( $d = '' ) { |
|---|
| 668 |
if ( '' == $d ) |
|---|
| 669 |
$the_time = get_post_time(get_settings('time_format')); |
|---|
| 670 |
else |
|---|
| 671 |
$the_time = get_post_time($d); |
|---|
| 672 |
return apply_filters('get_the_time', $the_time, $d); |
|---|
| 673 |
} |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
function get_post_time( $d = 'U', $gmt = false ) { |
|---|
| 677 |
global $post; |
|---|
| 678 |
if ( $gmt ) |
|---|
| 679 |
$time = $post->post_date_gmt; |
|---|
| 680 |
else |
|---|
| 681 |
$time = $post->post_date; |
|---|
| 682 |
|
|---|
| 683 |
$time = mysql2date($d, $time); |
|---|
| 684 |
return apply_filters('get_the_time', $time, $d, $gmt); |
|---|
| 685 |
} |
|---|
| 686 |
|
|---|
| 687 |
|
|---|
| 688 |
function the_modified_time($d = '') { |
|---|
| 689 |
echo apply_filters('the_modified_time', get_the_modified_time($d), $d); |
|---|
| 690 |
} |
|---|
| 691 |
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 |
function get_the_modified_time($d = '') { |
|---|
| 695 |
if ( '' == $d ) |
|---|
| 696 |
$the_time = get_post_modified_time(get_settings('time_format')); |
|---|
| 697 |
else |
|---|
| 698 |
$the_time = get_post_modified_time($d); |
|---|
| 699 |
return apply_filters('get_the_modified_time', $the_time, $d); |
|---|
| 700 |
} |
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 |
function get_post_modified_time( $d = 'U', $gmt = false ) { |
|---|
| 704 |
global $post; |
|---|
| 705 |
|
|---|
| 706 |
if ( $gmt ) |
|---|
| 707 |
$time = $post->post_modified_gmt; |
|---|
| 708 |
else |
|---|
| 709 |
$time = $post->post_modified; |
|---|
| 710 |
$time = mysql2date($d, $time); |
|---|
| 711 |
|
|---|
| 712 |
return apply_filters('get_the_modified_time', $time, $d, $gmt); |
|---|
| 713 |
} |
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 |
function the_weekday() { |
|---|
| 717 |
global $weekday, $id, $post; |
|---|
| 718 |
$the_weekday = $weekday[mysql2date('w', $post->post_date)]; |
|---|
| 719 |
$the_weekday = apply_filters('the_weekday', $the_weekday); |
|---|
| 720 |
echo $the_weekday; |
|---|
| 721 |
} |
|---|
| 722 |
|
|---|
| 723 |
|
|---|
| 724 |
function the_weekday_date($before='',$after='') { |
|---|
| 725 |
global $weekday, $id, $post, $day, $previousweekday; |
|---|
| 726 |
$the_weekday_date = ''; |
|---|
| 727 |
if ($day != $previousweekday) { |
|---|
| 728 |
$the_weekday_date .= $before; |
|---|
| 729 |
$the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; |
|---|
| 730 |
$the_weekday_date .= $after; |
|---|
| 731 |
$previousweekday = $day; |
|---|
| 732 |
} |
|---|
| 733 |
$the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); |
|---|
| 734 |
echo $the_weekday_date; |
|---|
| 735 |
} |
|---|
| 736 |
|
|---|
| 737 |
function rsd_link() { |
|---|
| 738 |
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n"; |
|---|
| 739 |
} |
|---|
| 740 |
|
|---|
| 741 |
?> |
|---|
| 742 |
|
|---|