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