Log in with username/password: lyceum/lyceum

root/trunk/src/lib/wp-includes/template-functions-general.php

Revision 602, 22.7 kB (checked in by jjb, 4 years ago)

ticket:328

thanks to Whatup of http://blog.twkang.net for the patches.

Line 
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, $blog, $blogdata;
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('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 = '&raquo;', $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         // If there's a category
152         if(!empty($cat)) {
153                 if (!stristr($cat,'-')) { // category excluded
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]; // no trailing slash
162                         } else {
163                                 $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
164                         }
165                 }
166                 $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE blog = '$blog' AND category_nicename = '$category_name'");
167         }
168
169     // If there's an author
170     if ( !empty($author) ) {
171         $title = get_userdata($author);
172         $title = $title->display_name;
173     }
174     if ( !empty($author_name) ) {
175         // We do a direct query here because we don't cache by nicename.
176         $title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'");
177     }
178
179     // If there's a month
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     // If there's a post
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     // Send it out
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 /* link navigation hack by Orien http://icecode.com/ */
271 // I snuck in the blog var here. i think this will work for most cases. In order to deal
272 // with permalink url structures it will probably have to
273 // be integrated directly intp functions such as get_month_link  --jjb
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 // custom
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         // this is what will separate dates on weekly archive links
313         $archive_week_separator = '&#8211;';
314
315         // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
316         $archive_date_format_over_ride = 0;
317
318         // options for daily archive (only if you over-ride the general date format)
319         $archive_day_date_format = 'Y/m/d';
320
321         // options for weekly archive (only if you over-ride the general date format)
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 = '&nbsp;('.$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, '&amp;', '=', $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 // Used in get_calendar
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         // Quick check. If we have no posts at all, abort!
410         if (!$posts) {
411                 //$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE blog = '$blog' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
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         // week_begins = 0 stands for sunday
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         // Let's figure out when we are
427         if (!empty($monthnum) && !empty($year)) {
428                 $thismonth = ''.zeroise(intval($monthnum), 2);
429                 $thisyear = ''.intval($year);
430         } elseif (!empty($w)) {
431                 // We need to get the month from MySQL
432                 $thisyear = ''.intval(substr($m, 0, 4));
433                 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
434                 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");// i think.... TODO jjb
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         // Get the next and previous month and year with at least one post
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 /*        $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
466             FROM $wpdb->posts
467             WHERE blog = '$blog'
468             AND post_date > '$thisyear-$thismonth-01'
469             AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
470             AND post_status = 'publish'
471             ORDER     BY post_date ASC
472             LIMIT 1");*/
473
474         $next = $wpdb->get_post_row("DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year", "
475             post_date > '$thisyear-$thismonth-01' AND
476             MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) AND
477             post_status = 'publish'
478             ORDER    BY post_date ASC
479             LIMIT 1");
480             
481         echo '<table id="wp-calendar">
482         <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
483         <thead>
484         <tr>';
485
486         $day_abbrev = $weekday_initial;
487         if ($daylength > 1) {
488                 $day_abbrev = $weekday_abbrev;
489         }
490
491         $myweek = array();
492     
493         for ($wdcount=0; $wdcount<=6; $wdcount++) {
494                 $myweek[]=$weekday[($wdcount+$week_begins)%7];
495         }
496     
497         foreach ($myweek as $wd) {
498                 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
499         }
500
501         echo '
502         </tr>
503         </thead>
504
505         <tfoot>
506         <tr>';
507
508         if ($previous) {
509                 echo "\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))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
511         } else {
512                 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
513         }
514
515         echo "\n\t\t".'<td class="pad">&nbsp;</td>';
516
517         if ($next) {
518                 echo "\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)]] . ' &raquo;</a></td>';
521         } else {
522                 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
523         }
524
525         echo '
526         </tr>
527         </tfoot>
528
529         <tbody>
530         <tr>';
531
532 /*        $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
533                         FROM $wpdb->posts WHERE    blog = '$blog'
534                         AND MONTH(post_date) = $thismonth
535                         AND YEAR(post_date) = $thisyear
536                         AND post_status = 'publish'
537                         AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);*/
538
539         // Get days with posts
540         $dayswithposts = $wpdb->get_post_results("DISTINCT DAYOFMONTH(post_date)", "
541             MONTH(post_date) = $thismonth AND
542             YEAR(post_date) = $thisyear AND
543             post_status = 'publish' AND
544             post_date < '" . current_time('mysql') . '\'', ARRAY_N);
545
546         if ($dayswithposts)
547             foreach ($dayswithposts as $daywith)
548                 $daywithpost[] = $daywith[0];
549         else
550             $daywithpost = array();
551
552         if (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         } else {
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             YEAR(post_date) = '$thisyear' AND
562             MONTH(post_date) = '$thismonth' AND
563             post_date < '".current_time('mysql')."' AND
564             post_status = 'publish'");
565
566         if ($ak_post_titles) {
567             foreach ($ak_post_titles as $ak_post_title) {
568                 if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
569                     $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
570                 }
571                 if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
572                     $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
573                 } else {
574                     $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
575                 }
576             }
577         }
578
579
580         // See how much we should pad in the beginning
581         $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
582         if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
583
584         $daysinmonth = intval(date('t', $unixmonth));
585         for ($day = 1; $day <= $daysinmonth; ++$day) {
586                 if (isset($newrow) && $newrow)
587                         echo "\n\t</tr>\n\t<tr>\n\t\t";
588                 $newrow = false;
589
590                 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)))
591                         echo '<td id="today">';
592                 else
593                         echo '<td>';
594
595                 if (in_array($day, $daywithpost)) { // any posts today?
596                         echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
597                 } else {
598                         echo $day;
599                 }
600                 echo '</td>';
601
602     if (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         if ($pad != 0 && $pad != 7)
608                 echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
609
610         echo "\n\t</tr>\n\t</tbody>\n\t</table>";
611 }
612
613
614 function allowed_tags() {
615         global $allowedtags;
616     $allowed = '';
617         foreach($allowedtags as $tag => $attributes) {
618                 $allowed .= '<'.$tag;
619                 if (0 < count($attributes)) {
620                         foreach ($attributes as $attribute => $limits) {
621                                 $allowed .= ' '.$attribute.'=""';
622                         }
623                 }
624                 $allowed .= '> ';
625         }
626         return htmlentities($allowed);
627 }
628
629
630 /***** Date/Time tags *****/
631
632
633 function the_date_xml() {
634         global $post;
635         echo mysql2date('Y-m-d', $post->post_date);
636         //echo ""+$post->post_date;
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 ) { // returns timestamp
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 ) { // returns timestamp
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
Note: See TracBrowser for help on using the browser.
Log in with username/password: lyceum/lyceum