[ Index ]

PHP Cross Reference of WordPress Trunk (Latest)

title

Body

[close]

/wp-includes/ -> template-functions-general.php (source)

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

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sun Jun 11 00:10:35 2006 Courtesy of Taragana