home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-includes / template-functions-general.php < prev    next >
Encoding:
PHP Script  |  2005-04-04  |  22.2 KB  |  645 lines

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