]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/general-template.php
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-includes / general-template.php
1 <?php
2
3 /* Note: these tags go anywhere in the template */
4
5 function get_header() {
6         do_action( 'get_header' );
7         if ( file_exists( TEMPLATEPATH . '/header.php') )
8                 load_template( TEMPLATEPATH . '/header.php');
9         else
10                 load_template( WP_CONTENT_DIR . '/themes/default/header.php');
11 }
12
13
14 function get_footer() {
15         do_action( 'get_footer' );
16         if ( file_exists( TEMPLATEPATH . '/footer.php') )
17                 load_template( TEMPLATEPATH . '/footer.php');
18         else
19                 load_template( WP_CONTENT_DIR . '/themes/default/footer.php');
20 }
21
22
23 function get_sidebar( $name = null ) {
24         do_action( 'get_sidebar' );
25         if ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") )
26                 load_template( TEMPLATEPATH . "/sidebar-{$name}.php");
27         elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') )
28                 load_template( TEMPLATEPATH . '/sidebar.php');
29         else
30                 load_template( WP_CONTENT_DIR . '/themes/default/sidebar.php');
31 }
32
33
34 function wp_loginout() {
35         if ( ! is_user_logged_in() )
36                 $link = '<a href="' . site_url('wp-login.php', 'login') . '">' . __('Log in') . '</a>';
37         else
38                 $link = '<a href="' . site_url('wp-login.php?action=logout', 'login') . '">' . __('Log out') . '</a>';
39
40         echo apply_filters('loginout', $link);
41 }
42
43
44 function wp_register( $before = '<li>', $after = '</li>' ) {
45
46         if ( ! is_user_logged_in() ) {
47                 if ( get_option('users_can_register') )
48                         $link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
49                 else
50                         $link = '';
51         } else {
52                 $link = $before . '<a href="' . admin_url() . '">' . __('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         echo get_bloginfo($show, 'display');
66 }
67
68 /**
69  * Note: some of these values are DEPRECATED. Meaning they could be
70  * taken out at any time and shouldn't be relied upon. Options
71  * without "// DEPRECATED" are the preferred and recommended ways
72  * to get the information.
73  */
74 function get_bloginfo($show = '', $filter = 'raw') {
75
76         switch($show) {
77                 case 'url' :
78                 case 'home' : // DEPRECATED
79                 case 'siteurl' : // DEPRECATED
80                         $output = get_option('home');
81                         break;
82                 case 'wpurl' :
83                         $output = get_option('siteurl');
84                         break;
85                 case 'description':
86                         $output = get_option('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_atom_url':
101                         $output = get_feed_link('comments_atom');
102                         break;
103                 case 'comments_rss2_url':
104                         $output = get_feed_link('comments_rss2');
105                         break;
106                 case 'pingback_url':
107                         $output = get_option('siteurl') .'/xmlrpc.php';
108                         break;
109                 case 'stylesheet_url':
110                         $output = get_stylesheet_uri();
111                         break;
112                 case 'stylesheet_directory':
113                         $output = get_stylesheet_directory_uri();
114                         break;
115                 case 'template_directory':
116                 case 'template_url':
117                         $output = get_template_directory_uri();
118                         break;
119                 case 'admin_email':
120                         $output = get_option('admin_email');
121                         break;
122                 case 'charset':
123                         $output = get_option('blog_charset');
124                         if ('' == $output) $output = 'UTF-8';
125                         break;
126                 case 'html_type' :
127                         $output = get_option('html_type');
128                         break;
129                 case 'version':
130                         global $wp_version;
131                         $output = $wp_version;
132                         break;
133                 case 'language':
134                         $output = get_locale();
135                         $output = str_replace('_', '-', $output);
136                         break;
137                 case 'text_direction':
138                         global $wp_locale;
139                         $output = $wp_locale->text_direction;
140                         break;
141                 case 'name':
142                 default:
143                         $output = get_option('blogname');
144                         break;
145         }
146
147         $url = true;
148         if (strpos($show, 'url') === false &&
149                 strpos($show, 'directory') === false &&
150                 strpos($show, 'home') === false)
151                 $url = false;
152
153         if ( 'display' == $filter ) {
154                 if ( $url )
155                         $output = apply_filters('bloginfo_url', $output, $show);
156                 else
157                         $output = apply_filters('bloginfo', $output, $show);
158         }
159
160         return $output;
161 }
162
163
164 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
165         global $wpdb, $wp_locale, $wp_query;
166
167         $cat = get_query_var('cat');
168         $tag = get_query_var('tag_id');
169         $category_name = get_query_var('category_name');
170         $author = get_query_var('author');
171         $author_name = get_query_var('author_name');
172         $m = get_query_var('m');
173         $year = get_query_var('year');
174         $monthnum = get_query_var('monthnum');
175         $day = get_query_var('day');
176         $title = '';
177
178         // If there's a category
179         if ( !empty($cat) ) {
180                         // category exclusion
181                         if ( !stristr($cat,'-') )
182                                 $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
183         } elseif ( !empty($category_name) ) {
184                 if ( stristr($category_name,'/') ) {
185                                 $category_name = explode('/',$category_name);
186                                 if ( $category_name[count($category_name)-1] )
187                                         $category_name = $category_name[count($category_name)-1]; // no trailing slash
188                                 else
189                                         $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
190                 }
191                 $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display');
192                 if ( $cat )
193                         $title = apply_filters('single_cat_title', $cat->name);
194         }
195
196         if ( !empty($tag) ) {
197                 $tag = get_term($tag, 'post_tag', OBJECT, 'display');
198                 if ( is_wp_error( $tag ) )
199                         return $tag;
200                 if ( ! empty($tag->name) )
201                         $title = apply_filters('single_tag_title', $tag->name);
202         }
203
204         // If there's an author
205         if ( !empty($author) ) {
206                 $title = get_userdata($author);
207                 $title = $title->display_name;
208         }
209         if ( !empty($author_name) ) {
210                 // We do a direct query here because we don't cache by nicename.
211                 $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name));
212         }
213
214         // If there's a month
215         if ( !empty($m) ) {
216                 $my_year = substr($m, 0, 4);
217                 $my_month = $wp_locale->get_month(substr($m, 4, 2));
218                 $my_day = intval(substr($m, 6, 2));
219                 $title = "$my_year" . ($my_month ? "$sep $my_month" : "") . ($my_day ? "$sep $my_day" : "");
220         }
221
222         if ( !empty($year) ) {
223                 $title = $year;
224                 if ( !empty($monthnum) )
225                         $title .= " $sep " . $wp_locale->get_month($monthnum);
226                 if ( !empty($day) )
227                         $title .= " $sep " . zeroise($day, 2);
228         }
229
230         // If there is a post
231         if ( is_single() || is_page() ) {
232                 $post = $wp_query->get_queried_object();
233                 $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
234         }
235
236         // If there's a taxonomy
237         if ( is_tax() ) {
238                 $taxonomy = get_query_var( 'taxonomy' );
239                 $tax = get_taxonomy( $taxonomy );
240                 $tax = $tax->label;
241                 $term = $wp_query->get_queried_object();
242                 $term = $term->name;
243                 if ( 'right' == $seplocation )
244                         $title = "$term $sep $tax";
245                 else
246                         $title = "$tax $sep $term";
247         }
248
249         $prefix = '';
250         if ( !empty($title) )
251                 $prefix = " $sep ";
252
253         // Determines position of the separator
254         if ( 'right' == $seplocation )
255                 $title = $title . $prefix;
256         else
257                 $title = $prefix . $title;
258
259         $title = apply_filters('wp_title', $title, $sep);
260
261         // Send it out
262         if ( $display )
263                 echo $title;
264         else
265                 return $title;
266
267 }
268
269
270 function single_post_title($prefix = '', $display = true) {
271         global $wpdb;
272         $p = get_query_var('p');
273         $name = get_query_var('name');
274
275         if ( intval($p) || '' != $name ) {
276                 if ( !$p )
277                         $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
278                 $post = & get_post($p);
279                 $title = $post->post_title;
280                 $title = apply_filters('single_post_title', $title);
281                 if ( $display )
282                         echo $prefix.strip_tags($title);
283                 else
284                         return strip_tags($title);
285         }
286 }
287
288
289 function single_cat_title($prefix = '', $display = true ) {
290         $cat = intval( get_query_var('cat') );
291         if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
292                 $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
293                 if ( !empty($my_cat_name) ) {
294                         if ( $display )
295                                 echo $prefix.strip_tags($my_cat_name);
296                         else
297                                 return strip_tags($my_cat_name);
298                 }
299         } else if ( is_tag() ) {
300                 return single_tag_title($prefix, $display);
301         }
302 }
303
304
305 function single_tag_title($prefix = '', $display = true ) {
306         if ( !is_tag() )
307                 return;
308
309         $tag_id = intval( get_query_var('tag_id') );
310
311         if ( !empty($tag_id) ) {
312                 $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
313                 if ( is_wp_error( $my_tag ) )
314                         return false;
315                 $my_tag_name = apply_filters('single_tag_title', $my_tag->name);
316                 if ( !empty($my_tag_name) ) {
317                         if ( $display )
318                                 echo $prefix . $my_tag_name;
319                         else
320                                 return $my_tag_name;
321                 }
322         }
323 }
324
325
326 function single_month_title($prefix = '', $display = true ) {
327         global $wp_locale;
328
329         $m = get_query_var('m');
330         $year = get_query_var('year');
331         $monthnum = get_query_var('monthnum');
332
333         if ( !empty($monthnum) && !empty($year) ) {
334                 $my_year = $year;
335                 $my_month = $wp_locale->get_month($monthnum);
336         } elseif ( !empty($m) ) {
337                 $my_year = substr($m, 0, 4);
338                 $my_month = $wp_locale->get_month(substr($m, 4, 2));
339         }
340
341         if ( empty($my_month) )
342                 return false;
343
344         $result = $prefix . $my_month . $prefix . $my_year;
345
346         if ( !$display )
347                 return $result;
348         echo $result;
349 }
350
351
352 /* link navigation hack by Orien http://icecode.com/ */
353 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
354         $text = wptexturize($text);
355         $title_text = attribute_escape($text);
356         $url = clean_url($url);
357
358         if ('link' == $format)
359                 $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
360         elseif ('option' == $format)
361                 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
362         elseif ('html' == $format)
363                 $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
364         else // custom
365                 $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
366
367         $link_html = apply_filters( "get_archives_link", $link_html );
368                 
369         return $link_html;
370 }
371
372
373 function wp_get_archives($args = '') {
374         global $wpdb, $wp_locale;
375
376         $defaults = array(
377                 'type' => 'monthly', 'limit' => '',
378                 'format' => 'html', 'before' => '',
379                 'after' => '', 'show_post_count' => false
380         );
381
382         $r = wp_parse_args( $args, $defaults );
383         extract( $r, EXTR_SKIP );
384
385         if ( '' == $type )
386                 $type = 'monthly';
387
388         if ( '' != $limit ) {
389                 $limit = absint($limit);
390                 $limit = ' LIMIT '.$limit;
391         }
392
393         // this is what will separate dates on weekly archive links
394         $archive_week_separator = '&#8211;';
395
396         // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
397         $archive_date_format_over_ride = 0;
398
399         // options for daily archive (only if you over-ride the general date format)
400         $archive_day_date_format = 'Y/m/d';
401
402         // options for weekly archive (only if you over-ride the general date format)
403         $archive_week_start_date_format = 'Y/m/d';
404         $archive_week_end_date_format   = 'Y/m/d';
405
406         if ( !$archive_date_format_over_ride ) {
407                 $archive_day_date_format = get_option('date_format');
408                 $archive_week_start_date_format = get_option('date_format');
409                 $archive_week_end_date_format = get_option('date_format');
410         }
411
412         //filters
413         $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
414         $join = apply_filters('getarchives_join', "", $r);
415
416         if ( 'monthly' == $type ) {
417                 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
418                 $key = md5($query);
419                 $cache = wp_cache_get( 'wp_get_archives' , 'general');
420                 if ( !isset( $cache[ $key ] ) ) {
421                         $arcresults = $wpdb->get_results($query);
422                         $cache[ $key ] = $arcresults;
423                         wp_cache_add( 'wp_get_archives', $cache, 'general' );
424                 } else {
425                         $arcresults = $cache[ $key ];
426                 }
427                 if ( $arcresults ) {
428                         $afterafter = $after;
429                         foreach ( $arcresults as $arcresult ) {
430                                 $url    = get_month_link($arcresult->year,      $arcresult->month);
431                                 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
432                                 if ( $show_post_count )
433                                         $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
434                                 echo get_archives_link($url, $text, $format, $before, $after);
435                         }
436                 }
437         } elseif ('yearly' == $type) {
438                 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
439                 $key = md5($query);
440                 $cache = wp_cache_get( 'wp_get_archives' , 'general');
441                 if ( !isset( $cache[ $key ] ) ) {
442                         $arcresults = $wpdb->get_results($query);
443                         $cache[ $key ] = $arcresults;
444                         wp_cache_add( 'wp_get_archives', $cache, 'general' );
445                 } else {
446                         $arcresults = $cache[ $key ];
447                 }
448                 if ($arcresults) {
449                         $afterafter = $after;
450                         foreach ($arcresults as $arcresult) {
451                                 $url = get_year_link($arcresult->year);
452                                 $text = sprintf('%d', $arcresult->year);
453                                 if ($show_post_count)
454                                         $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
455                                 echo get_archives_link($url, $text, $format, $before, $after);
456                         }
457                 }
458         } elseif ( 'daily' == $type ) {
459                 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
460                 $key = md5($query);
461                 $cache = wp_cache_get( 'wp_get_archives' , 'general');
462                 if ( !isset( $cache[ $key ] ) ) {
463                         $arcresults = $wpdb->get_results($query);
464                         $cache[ $key ] = $arcresults;
465                         wp_cache_add( 'wp_get_archives', $cache, 'general' );
466                 } else {
467                         $arcresults = $cache[ $key ];
468                 }
469                 if ( $arcresults ) {
470                         $afterafter = $after;
471                         foreach ( $arcresults as $arcresult ) {
472                                 $url    = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
473                                 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
474                                 $text = mysql2date($archive_day_date_format, $date);
475                                 if ($show_post_count)
476                                         $after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
477                                 echo get_archives_link($url, $text, $format, $before, $after);
478                         }
479                 }
480         } elseif ( 'weekly' == $type ) {
481                 $start_of_week = get_option('start_of_week');
482                 $query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit";
483                 $key = md5($query);
484                 $cache = wp_cache_get( 'wp_get_archives' , 'general');
485                 if ( !isset( $cache[ $key ] ) ) {
486                         $arcresults = $wpdb->get_results($query);
487                         $cache[ $key ] = $arcresults;
488                         wp_cache_add( 'wp_get_archives', $cache, 'general' );
489                 } else {
490                         $arcresults = $cache[ $key ];
491                 }
492                 $arc_w_last = '';
493                 $afterafter = $after;
494                 if ( $arcresults ) {
495                                 foreach ( $arcresults as $arcresult ) {
496                                         if ( $arcresult->week != $arc_w_last ) {
497                                                 $arc_year = $arcresult->yr;
498                                                 $arc_w_last = $arcresult->week;
499                                                 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
500                                                 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
501                                                 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
502                                                 $url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
503                                                 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
504                                                 if ($show_post_count)
505                                                         $after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
506                                                 echo get_archives_link($url, $text, $format, $before, $after);
507                                         }
508                                 }
509                 }
510         } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
511                 ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
512                 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
513                 $key = md5($query);
514                 $cache = wp_cache_get( 'wp_get_archives' , 'general');
515                 if ( !isset( $cache[ $key ] ) ) {
516                         $arcresults = $wpdb->get_results($query);
517                         $cache[ $key ] = $arcresults;
518                         wp_cache_add( 'wp_get_archives', $cache, 'general' );
519                 } else {
520                         $arcresults = $cache[ $key ];
521                 }
522                 if ( $arcresults ) {
523                         foreach ( $arcresults as $arcresult ) {
524                                 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
525                                         $url  = get_permalink($arcresult);
526                                         $arc_title = $arcresult->post_title;
527                                         if ( $arc_title )
528                                                 $text = strip_tags(apply_filters('the_title', $arc_title));
529                                         else
530                                                 $text = $arcresult->ID;
531                                         echo get_archives_link($url, $text, $format, $before, $after);
532                                 }
533                         }
534                 }
535         }
536 }
537
538
539 // Used in get_calendar
540 function calendar_week_mod($num) {
541         $base = 7;
542         return ($num - $base*floor($num/$base));
543 }
544
545
546 function get_calendar($initial = true) {
547         global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
548
549         $key = md5( $m . $monthnum . $year );
550         if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
551                 if ( isset( $cache[ $key ] ) ) {
552                         echo $cache[ $key ];
553                         return;
554                 }
555         }
556
557         ob_start();
558         // Quick check. If we have no posts at all, abort!
559         if ( !$posts ) {
560                 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
561                 if ( !$gotsome )
562                         return;
563         }
564
565         if ( isset($_GET['w']) )
566                 $w = ''.intval($_GET['w']);
567
568         // week_begins = 0 stands for Sunday
569         $week_begins = intval(get_option('start_of_week'));
570
571         // Let's figure out when we are
572         if ( !empty($monthnum) && !empty($year) ) {
573                 $thismonth = ''.zeroise(intval($monthnum), 2);
574                 $thisyear = ''.intval($year);
575         } elseif ( !empty($w) ) {
576                 // We need to get the month from MySQL
577                 $thisyear = ''.intval(substr($m, 0, 4));
578                 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
579                 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
580         } elseif ( !empty($m) ) {
581                 $thisyear = ''.intval(substr($m, 0, 4));
582                 if ( strlen($m) < 6 )
583                                 $thismonth = '01';
584                 else
585                                 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
586         } else {
587                 $thisyear = gmdate('Y', current_time('timestamp'));
588                 $thismonth = gmdate('m', current_time('timestamp'));
589         }
590
591         $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
592
593         // Get the next and previous month and year with at least one post
594         $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
595                 FROM $wpdb->posts
596                 WHERE post_date < '$thisyear-$thismonth-01'
597                 AND post_type = 'post' AND post_status = 'publish'
598                         ORDER BY post_date DESC
599                         LIMIT 1");
600         $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
601                 FROM $wpdb->posts
602                 WHERE post_date >       '$thisyear-$thismonth-01'
603                 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
604                 AND post_type = 'post' AND post_status = 'publish'
605                         ORDER   BY post_date ASC
606                         LIMIT 1");
607
608         echo '<table id="wp-calendar" summary="' . __('Calendar') . '">
609         <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
610         <thead>
611         <tr>';
612
613         $myweek = array();
614
615         for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
616                 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
617         }
618
619         foreach ( $myweek as $wd ) {
620                 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
621                 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
622         }
623
624         echo '
625         </tr>
626         </thead>
627
628         <tfoot>
629         <tr>';
630
631         if ( $previous ) {
632                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
633                 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
634                         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>';
635         } else {
636                 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
637         }
638
639         echo "\n\t\t".'<td class="pad">&nbsp;</td>';
640
641         if ( $next ) {
642                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
643                 get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
644                         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>';
645         } else {
646                 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
647         }
648
649         echo '
650         </tr>
651         </tfoot>
652
653         <tbody>
654         <tr>';
655
656         // Get days with posts
657         $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
658                 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
659                 AND YEAR(post_date) = '$thisyear'
660                 AND post_type = 'post' AND post_status = 'publish'
661                 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
662         if ( $dayswithposts ) {
663                 foreach ( $dayswithposts as $daywith ) {
664                         $daywithpost[] = $daywith[0];
665                 }
666         } else {
667                 $daywithpost = array();
668         }
669
670         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false)
671                 $ak_title_separator = "\n";
672         else
673                 $ak_title_separator = ', ';
674
675         $ak_titles_for_day = array();
676         $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
677                 ."FROM $wpdb->posts "
678                 ."WHERE YEAR(post_date) = '$thisyear' "
679                 ."AND MONTH(post_date) = '$thismonth' "
680                 ."AND post_date < '".current_time('mysql')."' "
681                 ."AND post_type = 'post' AND post_status = 'publish'"
682         );
683         if ( $ak_post_titles ) {
684                 foreach ( $ak_post_titles as $ak_post_title ) {
685
686                                 $post_title = apply_filters( "the_title", $ak_post_title->post_title );
687                                 $post_title = str_replace('"', '&quot;', wptexturize( $post_title ));
688
689                                 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
690                                         $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
691                                 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
692                                         $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
693                                 else
694                                         $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
695                 }
696         }
697
698
699         // See how much we should pad in the beginning
700         $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
701         if ( 0 != $pad )
702                 echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
703
704         $daysinmonth = intval(date('t', $unixmonth));
705         for ( $day = 1; $day <= $daysinmonth; ++$day ) {
706                 if ( isset($newrow) && $newrow )
707                         echo "\n\t</tr>\n\t<tr>\n\t\t";
708                 $newrow = false;
709
710                 if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) )
711                         echo '<td id="today">';
712                 else
713                         echo '<td>';
714
715                 if ( in_array($day, $daywithpost) ) // any posts today?
716                                 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
717                 else
718                         echo $day;
719                 echo '</td>';
720
721                 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
722                         $newrow = true;
723         }
724
725         $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
726         if ( $pad != 0 && $pad != 7 )
727                 echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
728
729         echo "\n\t</tr>\n\t</tbody>\n\t</table>";
730
731         $output = ob_get_contents();
732         ob_end_clean();
733         echo $output;
734         $cache[ $key ] = $output;
735         wp_cache_set( 'get_calendar', $cache, 'calendar' );
736 }
737
738 function delete_get_calendar_cache() {
739         wp_cache_delete( 'get_calendar', 'calendar' );
740 }
741 add_action( 'save_post', 'delete_get_calendar_cache' );
742 add_action( 'delete_post', 'delete_get_calendar_cache' );
743 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
744 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
745 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
746
747
748 function allowed_tags() {
749         global $allowedtags;
750         $allowed = '';
751         foreach ( $allowedtags as $tag => $attributes ) {
752                 $allowed .= '<'.$tag;
753                 if ( 0 < count($attributes) ) {
754                         foreach ( $attributes as $attribute => $limits ) {
755                                 $allowed .= ' '.$attribute.'=""';
756                         }
757                 }
758                 $allowed .= '> ';
759         }
760         return htmlentities($allowed);
761 }
762
763
764 /***** Date/Time tags *****/
765
766
767 function the_date_xml() {
768         global $post;
769         echo mysql2date('Y-m-d', $post->post_date);
770         //echo ""+$post->post_date;
771 }
772
773
774 function the_date($d='', $before='', $after='', $echo = true) {
775         global $post, $day, $previousday;
776         $the_date = '';
777         if ( $day != $previousday ) {
778                 $the_date .= $before;
779                 if ( $d=='' )
780                         $the_date .= mysql2date(get_option('date_format'), $post->post_date);
781                 else
782                         $the_date .= mysql2date($d, $post->post_date);
783                 $the_date .= $after;
784                 $previousday = $day;
785         }
786         $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
787         if ( $echo )
788                 echo $the_date;
789         else
790                 return $the_date;
791 }
792
793
794 function the_modified_date($d = '') {
795         echo apply_filters('the_modified_date', get_the_modified_date($d), $d);
796 }
797
798
799 function get_the_modified_date($d = '') {
800         if ( '' == $d )
801                 $the_time = get_post_modified_time(get_option('date_format'));
802         else
803                 $the_time = get_post_modified_time($d);
804         return apply_filters('get_the_modified_date', $the_time, $d);
805 }
806
807
808 function the_time( $d = '' ) {
809         echo apply_filters('the_time', get_the_time( $d ), $d);
810 }
811
812
813 function get_the_time( $d = '' ) {
814         if ( '' == $d )
815                 $the_time = get_post_time(get_option('time_format'));
816         else
817                 $the_time = get_post_time($d);
818         return apply_filters('get_the_time', $the_time, $d);
819 }
820
821
822 function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp
823         global $post;
824         if ( $gmt )
825                 $time = $post->post_date_gmt;
826         else
827                 $time = $post->post_date;
828
829         $time = mysql2date($d, $time);
830         return apply_filters('get_post_time', $time, $d, $gmt);
831 }
832
833
834 function the_modified_time($d = '') {
835         echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
836 }
837
838
839 function get_the_modified_time($d = '') {
840         if ( '' == $d )
841                 $the_time = get_post_modified_time(get_option('time_format'));
842         else
843                 $the_time = get_post_modified_time($d);
844         return apply_filters('get_the_modified_time', $the_time, $d);
845 }
846
847
848 function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp
849         global $post;
850
851         if ( $gmt )
852                 $time = $post->post_modified_gmt;
853         else
854                 $time = $post->post_modified;
855         $time = mysql2date($d, $time);
856
857         return apply_filters('get_the_modified_time', $time, $d, $gmt);
858 }
859
860
861 function the_weekday() {
862         global $wp_locale, $post;
863         $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
864         $the_weekday = apply_filters('the_weekday', $the_weekday);
865         echo $the_weekday;
866 }
867
868
869 function the_weekday_date($before='',$after='') {
870         global $wp_locale, $post, $day, $previousweekday;
871         $the_weekday_date = '';
872         if ( $day != $previousweekday ) {
873                 $the_weekday_date .= $before;
874                 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
875                 $the_weekday_date .= $after;
876                 $previousweekday = $day;
877         }
878         $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
879         echo $the_weekday_date;
880 }
881
882 function wp_head() {
883         do_action('wp_head');
884 }
885
886 function wp_footer() {
887         do_action('wp_footer');
888 }
889
890 function rsd_link() {
891         echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
892 }
893
894 function wlwmanifest_link() {
895         echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
896                 . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
897 }
898
899 function noindex() {
900         // If the blog is not public, tell robots to go away.
901         if ( '0' == get_option('blog_public') )
902                 echo "<meta name='robots' content='noindex,nofollow' />\n";
903 }
904
905 function rich_edit_exists() {
906         global $wp_rich_edit_exists;
907         if ( !isset($wp_rich_edit_exists) )
908                 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
909         return $wp_rich_edit_exists;
910 }
911
912 function user_can_richedit() {
913         global $wp_rich_edit, $pagenow;
914
915         if ( !isset( $wp_rich_edit) ) {
916                 if ( get_user_option( 'rich_editing' ) == 'true' &&
917                         ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
918                                 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
919                                 && 'comment.php' != $pagenow ) {
920                         $wp_rich_edit = true;
921                 } else {
922                         $wp_rich_edit = false;
923                 }
924         }
925
926         return apply_filters('user_can_richedit', $wp_rich_edit);
927 }
928
929 function wp_default_editor() {
930         $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
931         if ( $user = wp_get_current_user() ) { // look for cookie
932                 if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) )
933                         $r = $_COOKIE['wordpress_editor_' . $user->ID];
934         }
935         return apply_filters( 'wp_default_editor', $r ); // filter
936 }
937
938 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
939         $rows = get_option('default_post_edit_rows');
940         if (($rows < 3) || ($rows > 100))
941                 $rows = 12;
942
943         $rows = "rows='$rows'"; ?>
944         <div id="editor-toolbar">
945         <?php if ( user_can_richedit() ) {
946                 $wp_default_editor = wp_default_editor(); ?>
947                 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
948                 <?php if ( 'tinymce' == $wp_default_editor ) {
949                         add_filter('the_editor_content', 'wp_richedit_pre'); ?>
950                         <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('HTML'); ?></a>
951                         <a id="edButtonPreview" class="active"><?php _e('Visual'); ?></a>
952                 <?php } elseif ( 'html' == $wp_default_editor ) {
953                         add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
954                         <a id="edButtonHTML" class="active"><?php _e('HTML'); ?></a>
955                         <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('Visual'); ?></a>
956                 <?php }
957         }
958
959         if ( $media_buttons ) { ?>
960                 <div id="media-buttons" class="hide-if-no-js">
961                 <?php do_action( 'media_buttons' ); ?>
962                 </div>
963         <?php } ?>
964         </div>
965
966         <div id="quicktags">
967         <?php wp_print_scripts( 'quicktags' ); ?>
968         <script type="text/javascript">edToolbar()</script>
969         </div>
970
971     <?php if ( 'html' != $wp_default_editor ) : ?>
972     <script type="text/javascript">
973     // <![CDATA[
974         if ( typeof tinyMCE != "undefined" )
975             document.getElementById("quicktags").style.display="none";
976     // ]]>
977     </script>
978     <?php endif; // 'html' != $wp_default_editor
979
980         $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea class='' $rows cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
981         $the_editor_content = apply_filters('the_editor_content', $content);
982
983         printf($the_editor, $the_editor_content);
984
985         ?>
986     <script type="text/javascript">
987     // <![CDATA[
988     edCanvas = document.getElementById('<?php echo $id; ?>');
989     <?php if ( $prev_id && user_can_richedit() ) : ?>
990     // If tinyMCE is defined.
991     if ( typeof tinyMCE != 'undefined' ) {
992     // This code is meant to allow tabbing from Title to Post (TinyMCE).
993         document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) {
994             e = e || window.event;
995             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
996                 if ( tinyMCE.activeEditor ) {
997                     if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); }
998                     e = null;
999                     if ( tinyMCE.activeEditor.isHidden() ) return true;
1000                     tinyMCE.activeEditor.focus();
1001                     return false;
1002                 }
1003                 return true;
1004             }
1005         }
1006     }
1007     <?php endif; ?>
1008     // ]]>
1009     </script>
1010     <?php
1011 }
1012
1013 function get_search_query() {
1014         return apply_filters( 'get_search_query', stripslashes( get_query_var( 's' ) ) );
1015 }
1016
1017 function the_search_query() {
1018         echo attribute_escape( apply_filters( 'the_search_query', get_search_query() ) );
1019 }
1020
1021 function language_attributes($doctype = 'html') {
1022         $attributes = array();
1023         $output = '';
1024
1025         if ( $dir = get_bloginfo('text_direction') )
1026                 $attributes[] = "dir=\"$dir\"";
1027
1028         if ( $lang = get_bloginfo('language') ) {
1029                 if ( get_option('html_type') == 'text/html' || $doctype == 'xhtml' )
1030                         $attributes[] = "lang=\"$lang\"";
1031
1032                 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1033                         $attributes[] = "xml:lang=\"$lang\"";
1034         }
1035
1036         $output = implode(' ', $attributes);
1037         $output = apply_filters('language_attributes', $output);
1038         echo $output;
1039 }
1040
1041 function paginate_links( $args = '' ) {
1042         $defaults = array(
1043                 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
1044                 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
1045                 'total' => 1,
1046                 'current' => 0,
1047                 'show_all' => false,
1048                 'prev_next' => true,
1049                 'prev_text' => __('&laquo; Previous'),
1050                 'next_text' => __('Next &raquo;'),
1051                 'end_size' => 1, // How many numbers on either end including the end
1052                 'mid_size' => 2, // How many numbers to either side of current not including current
1053                 'type' => 'plain',
1054                 'add_args' => false // array of query args to aadd
1055         );
1056
1057         $args = wp_parse_args( $args, $defaults );
1058         extract($args, EXTR_SKIP);
1059
1060         // Who knows what else people pass in $args
1061         $total    = (int) $total;
1062         if ( $total < 2 )
1063                 return;
1064         $current  = (int) $current;
1065         $end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
1066         $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
1067         $add_args = is_array($add_args) ? $add_args : false;
1068         $r = '';
1069         $page_links = array();
1070         $n = 0;
1071         $dots = false;
1072
1073         if ( $prev_next && $current && 1 < $current ) :
1074                 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
1075                 $link = str_replace('%#%', $current - 1, $link);
1076                 if ( $add_args )
1077                         $link = add_query_arg( $add_args, $link );
1078                 $page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
1079         endif;
1080         for ( $n = 1; $n <= $total; $n++ ) :
1081                 if ( $n == $current ) :
1082                         $page_links[] = "<span class='page-numbers current'>$n</span>";
1083                         $dots = true;
1084                 else :
1085                         if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
1086                                 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
1087                                 $link = str_replace('%#%', $n, $link);
1088                                 if ( $add_args )
1089                                         $link = add_query_arg( $add_args, $link );
1090                                 $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>";
1091                                 $dots = true;
1092                         elseif ( $dots && !$show_all ) :
1093                                 $page_links[] = "<span class='page-numbers dots'>...</span>";
1094                                 $dots = false;
1095                         endif;
1096                 endif;
1097         endfor;
1098         if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
1099                 $link = str_replace('%_%', $format, $base);
1100                 $link = str_replace('%#%', $current + 1, $link);
1101                 if ( $add_args )
1102                         $link = add_query_arg( $add_args, $link );
1103                 $page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
1104         endif;
1105         switch ( $type ) :
1106                 case 'array' :
1107                         return $page_links;
1108                         break;
1109                 case 'list' :
1110                         $r .= "<ul class='page-numbers'>\n\t<li>";
1111                         $r .= join("</li>\n\t<li>", $page_links);
1112                         $r .= "</li>\n</ul>\n";
1113                         break;
1114                 default :
1115                         $r = join("\n", $page_links);
1116                         break;
1117         endswitch;
1118         return $r;
1119 }
1120
1121 function wp_admin_css_color($key, $name, $url, $colors = array()) {
1122         global $_wp_admin_css_colors;
1123
1124         if ( !isset($_wp_admin_css_colors) )
1125                 $_wp_admin_css_colors = array();
1126
1127         $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
1128 }
1129
1130 /**
1131  * wp_admin_css_uri() - Outputs the URL of a WordPress admin CSS file
1132  *
1133  * @see WP_Styles::_css_href and its style_loader_src filter.
1134  *
1135  * @param string $file file relative to wp-admin/ without its ".css" extension.
1136  */
1137
1138 function wp_admin_css_uri( $file = 'wp-admin' ) {
1139         if ( defined('WP_INSTALLING') ) {
1140                 $_file = "./$file.css";
1141         } else {
1142                 $_file = admin_url("$file.css");
1143         }
1144         $_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
1145
1146         return apply_filters( 'wp_admin_css_uri', $_file, $file );
1147 }
1148
1149 /**
1150  * wp_admin_css() - Enqueues or directly prints a stylesheet link to the specified CSS file.
1151  *
1152  * "Intelligently" decides to enqueue or to print the CSS file.
1153  * If the wp_print_styles action has *not* yet been called, the CSS file will be enqueued.
1154  * If the wp_print_styles action *has* been called, the CSS link will be printed.
1155  * Printing may be forced by passing TRUE as the $force_echo (second) parameter.
1156  *
1157  * For backward compatibility with WordPress 2.3 calling method:
1158  * If the $file (first) parameter does not correspond to a registered CSS file, we assume $file is a
1159  * file relative to wp-admin/ without its ".css" extension.  A stylesheet link to that generated URL is printed.
1160  *
1161  * @package WordPress
1162  * @since 2.3
1163  *
1164  * @uses $wp_styles WordPress Styles Object
1165  *
1166  * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
1167  * @param bool $force_echo Optional.  Force the stylesheet link to be printed rather than enqueued.
1168  */
1169
1170 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
1171         global $wp_styles;
1172         if ( !is_a($wp_styles, 'WP_Styles') )
1173                 $wp_styles = new WP_Styles();
1174
1175         // For backward compatibility
1176         $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
1177
1178         if ( $wp_styles->query( $handle ) ) {
1179                 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue.  Print this one immediately
1180                         wp_print_styles( $handle );
1181                 else // Add to style queue
1182                         wp_enqueue_style( $handle );
1183                 return;
1184         }
1185
1186         echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
1187         if ( 'rtl' == get_bloginfo( 'text_direction' ) )
1188                 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
1189 }
1190
1191 /**
1192  * Enqueues the default ThickBox js and css. 
1193  * If any of the settings need to be changed, this can be done with another js file
1194  * similar to media-upload.js and theme-preview.js. That file should require array('thickbox')
1195  * to ensure it is loaded after. 
1196  */
1197 function add_thickbox() {
1198         wp_enqueue_script( 'thickbox' );
1199         wp_enqueue_style( 'thickbox' );
1200 }
1201
1202 /**
1203  * Outputs the XHTML generator that is generated on the wp_head hook.
1204  */
1205 function wp_generator()
1206 {
1207         the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
1208 }
1209
1210 /**
1211  * Outputs the generator XML or Comment for RSS, ATOM, etc.
1212  * @param {String} $type The type of generator to return.
1213  */
1214 function the_generator ( $type ) {
1215         echo apply_filters('the_generator',get_the_generator($type),$type) . "\n";
1216 }
1217
1218 /**
1219  * Creates the generator XML or Comment for RSS, ATOM, etc.
1220  * @param {String} $type The type of generator to return.
1221  */
1222 function get_the_generator ( $type ) {
1223         switch ($type) {
1224                 case 'html':
1225                         $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">' . "\n";
1226                         break;
1227                 case 'xhtml':
1228                         $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />' . "\n";
1229                         break;
1230                 case 'atom':
1231                         $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
1232                         break;
1233                 case 'rss2':
1234                         $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
1235                         break;
1236                 case 'rdf':
1237                         $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
1238                         break;
1239                 case 'comment':
1240                         $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
1241                         break;
1242                 case 'export':
1243                         $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '"-->';
1244                         break;
1245         }
1246         return apply_filters( "get_the_generator_{$type}", $gen, $type );
1247 }
1248 ?>