web/wp-includes/general-template.php
branchwordpress
changeset 109 03b0d1493584
child 132 4d4862461b8d
equal deleted inserted replaced
-1:000000000000 109:03b0d1493584
       
     1 <?php
       
     2 /**
       
     3  * General template tags that can go anywhere in a template.
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage Template
       
     7  */
       
     8 
       
     9 /**
       
    10  * Load header template.
       
    11  *
       
    12  * Includes the header template for a theme or if a name is specified then a
       
    13  * specialised header will be included. If the theme contains no header.php file
       
    14  * then the header from the default theme will be included.
       
    15  *
       
    16  * For the parameter, if the file is called "header-special.php" then specify
       
    17  * "special".
       
    18  *
       
    19  * @uses locate_template()
       
    20  * @since 1.5.0
       
    21  * @uses do_action() Calls 'get_header' action.
       
    22  *
       
    23  * @param string $name The name of the specialised header.
       
    24  */
       
    25 function get_header( $name = null ) {
       
    26 	do_action( 'get_header', $name );
       
    27 
       
    28 	$templates = array();
       
    29 	if ( isset($name) )
       
    30 		$templates[] = "header-{$name}.php";
       
    31 
       
    32 	$templates[] = "header.php";
       
    33 
       
    34 	if ('' == locate_template($templates, true))
       
    35 		load_template( get_theme_root() . '/default/header.php');
       
    36 }
       
    37 
       
    38 /**
       
    39  * Load footer template.
       
    40  *
       
    41  * Includes the footer template for a theme or if a name is specified then a
       
    42  * specialised footer will be included. If the theme contains no footer.php file
       
    43  * then the footer from the default theme will be included.
       
    44  *
       
    45  * For the parameter, if the file is called "footer-special.php" then specify
       
    46  * "special".
       
    47  *
       
    48  * @uses locate_template()
       
    49  * @since 1.5.0
       
    50  * @uses do_action() Calls 'get_footer' action.
       
    51  *
       
    52  * @param string $name The name of the specialised footer.
       
    53  */
       
    54 function get_footer( $name = null ) {
       
    55 	do_action( 'get_footer', $name );
       
    56 
       
    57 	$templates = array();
       
    58 	if ( isset($name) )
       
    59 		$templates[] = "footer-{$name}.php";
       
    60 
       
    61 	$templates[] = "footer.php";
       
    62 
       
    63 	if ('' == locate_template($templates, true))
       
    64 		load_template( get_theme_root() . '/default/footer.php');
       
    65 }
       
    66 
       
    67 /**
       
    68  * Load sidebar template.
       
    69  *
       
    70  * Includes the sidebar template for a theme or if a name is specified then a
       
    71  * specialised sidebar will be included. If the theme contains no sidebar.php
       
    72  * file then the sidebar from the default theme will be included.
       
    73  *
       
    74  * For the parameter, if the file is called "sidebar-special.php" then specify
       
    75  * "special".
       
    76  *
       
    77  * @uses locate_template()
       
    78  * @since 1.5.0
       
    79  * @uses do_action() Calls 'get_sidebar' action.
       
    80  *
       
    81  * @param string $name The name of the specialised sidebar.
       
    82  */
       
    83 function get_sidebar( $name = null ) {
       
    84 	do_action( 'get_sidebar', $name );
       
    85 
       
    86 	$templates = array();
       
    87 	if ( isset($name) )
       
    88 		$templates[] = "sidebar-{$name}.php";
       
    89 
       
    90 	$templates[] = "sidebar.php";
       
    91 
       
    92 	if ('' == locate_template($templates, true))
       
    93 		load_template( get_theme_root() . '/default/sidebar.php');
       
    94 }
       
    95 
       
    96 /**
       
    97  * Display search form.
       
    98  *
       
    99  * Will first attempt to locate the searchform.php file in either the child or
       
   100  * the parent, then load it. If it doesn't exist, then the default search form
       
   101  * will be displayed. The default search form is HTML, which will be displayed.
       
   102  * There is a filter applied to the search form HTML in order to edit or replace
       
   103  * it. The filter is 'get_search_form'.
       
   104  *
       
   105  * This function is primarily used by themes which want to hardcode the search
       
   106  * form into the sidebar and also by the search widget in WordPress.
       
   107  *
       
   108  * There is also an action that is called whenever the function is run called,
       
   109  * 'get_search_form'. This can be useful for outputting JavaScript that the
       
   110  * search relies on or various formatting that applies to the beginning of the
       
   111  * search. To give a few examples of what it can be used for.
       
   112  *
       
   113  * @since 2.7.0
       
   114  */
       
   115 function get_search_form() {
       
   116 	do_action( 'get_search_form' );
       
   117 
       
   118 	$search_form_template = locate_template(array('searchform.php'));
       
   119 	if ( '' != $search_form_template ) {
       
   120 		require($search_form_template);
       
   121 		return;
       
   122 	}
       
   123 
       
   124 	$form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" >
       
   125 	<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
       
   126 	<input type="text" value="' . esc_attr(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
       
   127 	<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
       
   128 	</div>
       
   129 	</form>';
       
   130 
       
   131 	echo apply_filters('get_search_form', $form);
       
   132 }
       
   133 
       
   134 /**
       
   135  * Display the Log In/Out link.
       
   136  *
       
   137  * Displays a link, which allows the user to navigate to the Log In page to log in
       
   138  * or log out depending on whether or not they are currently logged in.
       
   139  *
       
   140  * @since 1.5.0
       
   141  * @uses apply_filters() Calls 'loginout' hook on HTML link content.
       
   142  *
       
   143  * @param string $redirect Optional path to redirect to on login/logout.
       
   144  */
       
   145 function wp_loginout($redirect = '') {
       
   146 	if ( ! is_user_logged_in() )
       
   147 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
       
   148 	else
       
   149 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
       
   150 
       
   151 	echo apply_filters('loginout', $link);
       
   152 }
       
   153 
       
   154 /**
       
   155  * Returns the Log Out URL.
       
   156  *
       
   157  * Returns the URL that allows the user to log out of the site
       
   158  *
       
   159  * @since 2.7
       
   160  * @uses wp_nonce_url() To protect against CSRF
       
   161  * @uses site_url() To generate the log in URL
       
   162  * @uses apply_filters() calls 'logout_url' hook on final logout url
       
   163  *
       
   164  * @param string $redirect Path to redirect to on logout.
       
   165  */
       
   166 function wp_logout_url($redirect = '') {
       
   167 	$args = array( 'action' => 'logout' );
       
   168 	if ( !empty($redirect) ) {
       
   169 		$args['redirect_to'] = $redirect;
       
   170 	}
       
   171 
       
   172 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
       
   173 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
       
   174 
       
   175 	return apply_filters('logout_url', $logout_url, $redirect);
       
   176 }
       
   177 
       
   178 /**
       
   179  * Returns the Log In URL.
       
   180  *
       
   181  * Returns the URL that allows the user to log in to the site
       
   182  *
       
   183  * @since 2.7
       
   184  * @uses site_url() To generate the log in URL
       
   185  * @uses apply_filters() calls 'login_url' hook on final login url
       
   186  *
       
   187  * @param string $redirect Path to redirect to on login.
       
   188  */
       
   189 function wp_login_url($redirect = '') {
       
   190 	$login_url = site_url('wp-login.php', 'login');
       
   191 
       
   192 	if ( !empty($redirect) ) {
       
   193 		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
       
   194 	}
       
   195 
       
   196 	return apply_filters('login_url', $login_url, $redirect);
       
   197 }
       
   198 
       
   199 /**
       
   200  * Returns the Lost Password URL.
       
   201  *
       
   202  * Returns the URL that allows the user to retrieve the lost password
       
   203  *
       
   204  * @since 2.8.0
       
   205  * @uses site_url() To generate the lost password URL
       
   206  * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
       
   207  *
       
   208  * @param string $redirect Path to redirect to on login.
       
   209  */
       
   210 function wp_lostpassword_url($redirect = '') {
       
   211 	$args = array( 'action' => 'lostpassword' );
       
   212 	if ( !empty($redirect) ) {
       
   213 		$args['redirect_to'] = $redirect;
       
   214 	}
       
   215 
       
   216 	$lostpassword_url = add_query_arg($args, site_url('wp-login.php', 'login'));
       
   217 	return apply_filters('lostpassword_url', $lostpassword_url, $redirect);
       
   218 }
       
   219 
       
   220 /**
       
   221  * Display the Registration or Admin link.
       
   222  *
       
   223  * Display a link which allows the user to navigate to the registration page if
       
   224  * not logged in and registration is enabled or to the dashboard if logged in.
       
   225  *
       
   226  * @since 1.5.0
       
   227  * @uses apply_filters() Calls 'register' hook on register / admin link content.
       
   228  *
       
   229  * @param string $before Text to output before the link (defaults to <li>).
       
   230  * @param string $after Text to output after the link (defaults to </li>).
       
   231  */
       
   232 function wp_register( $before = '<li>', $after = '</li>' ) {
       
   233 
       
   234 	if ( ! is_user_logged_in() ) {
       
   235 		if ( get_option('users_can_register') )
       
   236 			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
       
   237 		else
       
   238 			$link = '';
       
   239 	} else {
       
   240 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
       
   241 	}
       
   242 
       
   243 	echo apply_filters('register', $link);
       
   244 }
       
   245 
       
   246 /**
       
   247  * Theme container function for the 'wp_meta' action.
       
   248  *
       
   249  * The 'wp_meta' action can have several purposes, depending on how you use it,
       
   250  * but one purpose might have been to allow for theme switching.
       
   251  *
       
   252  * @since 1.5.0
       
   253  * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
       
   254  * @uses do_action() Calls 'wp_meta' hook.
       
   255  */
       
   256 function wp_meta() {
       
   257 	do_action('wp_meta');
       
   258 }
       
   259 
       
   260 /**
       
   261  * Display information about the blog.
       
   262  *
       
   263  * @see get_bloginfo() For possible values for the parameter.
       
   264  * @since 0.71
       
   265  *
       
   266  * @param string $show What to display.
       
   267  */
       
   268 function bloginfo($show='') {
       
   269 	echo get_bloginfo($show, 'display');
       
   270 }
       
   271 
       
   272 /**
       
   273  * Retrieve information about the blog.
       
   274  *
       
   275  * Some show parameter values are deprecated and will be removed in future
       
   276  * versions. Care should be taken to check the function contents and know what
       
   277  * the deprecated blog info options are. Options without "// DEPRECATED" are
       
   278  * the preferred and recommended ways to get the information.
       
   279  *
       
   280  * The possible values for the 'show' parameter are listed below.
       
   281  * <ol>
       
   282  * <li><strong>url<strong> - Blog URI to homepage.</li>
       
   283  * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
       
   284  * <li><strong>description</strong> - Secondary title</li>
       
   285  * </ol>
       
   286  *
       
   287  * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
       
   288  * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
       
   289  * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
       
   290  * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
       
   291  *
       
   292  * There are many other options and you should check the function contents:
       
   293  * {@source 32 37}
       
   294  *
       
   295  * @since 0.71
       
   296  *
       
   297  * @param string $show Blog info to retrieve.
       
   298  * @param string $filter How to filter what is retrieved.
       
   299  * @return string Mostly string values, might be empty.
       
   300  */
       
   301 function get_bloginfo($show = '', $filter = 'raw') {
       
   302 
       
   303 	switch($show) {
       
   304 		case 'url' :
       
   305 		case 'home' : // DEPRECATED
       
   306 		case 'siteurl' : // DEPRECATED
       
   307 			$output = get_option('home');
       
   308 			break;
       
   309 		case 'wpurl' :
       
   310 			$output = get_option('siteurl');
       
   311 			break;
       
   312 		case 'description':
       
   313 			$output = get_option('blogdescription');
       
   314 			break;
       
   315 		case 'rdf_url':
       
   316 			$output = get_feed_link('rdf');
       
   317 			break;
       
   318 		case 'rss_url':
       
   319 			$output = get_feed_link('rss');
       
   320 			break;
       
   321 		case 'rss2_url':
       
   322 			$output = get_feed_link('rss2');
       
   323 			break;
       
   324 		case 'atom_url':
       
   325 			$output = get_feed_link('atom');
       
   326 			break;
       
   327 		case 'comments_atom_url':
       
   328 			$output = get_feed_link('comments_atom');
       
   329 			break;
       
   330 		case 'comments_rss2_url':
       
   331 			$output = get_feed_link('comments_rss2');
       
   332 			break;
       
   333 		case 'pingback_url':
       
   334 			$output = get_option('siteurl') .'/xmlrpc.php';
       
   335 			break;
       
   336 		case 'stylesheet_url':
       
   337 			$output = get_stylesheet_uri();
       
   338 			break;
       
   339 		case 'stylesheet_directory':
       
   340 			$output = get_stylesheet_directory_uri();
       
   341 			break;
       
   342 		case 'template_directory':
       
   343 		case 'template_url':
       
   344 			$output = get_template_directory_uri();
       
   345 			break;
       
   346 		case 'admin_email':
       
   347 			$output = get_option('admin_email');
       
   348 			break;
       
   349 		case 'charset':
       
   350 			$output = get_option('blog_charset');
       
   351 			if ('' == $output) $output = 'UTF-8';
       
   352 			break;
       
   353 		case 'html_type' :
       
   354 			$output = get_option('html_type');
       
   355 			break;
       
   356 		case 'version':
       
   357 			global $wp_version;
       
   358 			$output = $wp_version;
       
   359 			break;
       
   360 		case 'language':
       
   361 			$output = get_locale();
       
   362 			$output = str_replace('_', '-', $output);
       
   363 			break;
       
   364 		case 'text_direction':
       
   365 			global $wp_locale;
       
   366 			$output = $wp_locale->text_direction;
       
   367 			break;
       
   368 		case 'name':
       
   369 		default:
       
   370 			$output = get_option('blogname');
       
   371 			break;
       
   372 	}
       
   373 
       
   374 	$url = true;
       
   375 	if (strpos($show, 'url') === false &&
       
   376 		strpos($show, 'directory') === false &&
       
   377 		strpos($show, 'home') === false)
       
   378 		$url = false;
       
   379 
       
   380 	if ( 'display' == $filter ) {
       
   381 		if ( $url )
       
   382 			$output = apply_filters('bloginfo_url', $output, $show);
       
   383 		else
       
   384 			$output = apply_filters('bloginfo', $output, $show);
       
   385 	}
       
   386 
       
   387 	return $output;
       
   388 }
       
   389 
       
   390 /**
       
   391  * Display or retrieve page title for all areas of blog.
       
   392  *
       
   393  * By default, the page title will display the separator before the page title,
       
   394  * so that the blog title will be before the page title. This is not good for
       
   395  * title display, since the blog title shows up on most tabs and not what is
       
   396  * important, which is the page that the user is looking at.
       
   397  *
       
   398  * There are also SEO benefits to having the blog title after or to the 'right'
       
   399  * or the page title. However, it is mostly common sense to have the blog title
       
   400  * to the right with most browsers supporting tabs. You can achieve this by
       
   401  * using the seplocation parameter and setting the value to 'right'. This change
       
   402  * was introduced around 2.5.0, in case backwards compatibility of themes is
       
   403  * important.
       
   404  *
       
   405  * @since 1.0.0
       
   406  *
       
   407  * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
       
   408  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   409  * @param string $seplocation Optional. Direction to display title, 'right'.
       
   410  * @return string|null String on retrieve, null when displaying.
       
   411  */
       
   412 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
       
   413 	global $wpdb, $wp_locale, $wp_query;
       
   414 
       
   415 	$cat = get_query_var('cat');
       
   416 	$tag = get_query_var('tag_id');
       
   417 	$category_name = get_query_var('category_name');
       
   418 	$author = get_query_var('author');
       
   419 	$author_name = get_query_var('author_name');
       
   420 	$m = get_query_var('m');
       
   421 	$year = get_query_var('year');
       
   422 	$monthnum = get_query_var('monthnum');
       
   423 	$day = get_query_var('day');
       
   424 	$search = get_query_var('s');
       
   425 	$title = '';
       
   426 
       
   427 	$t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
       
   428 
       
   429 	// If there's a category
       
   430 	if ( !empty($cat) ) {
       
   431 			// category exclusion
       
   432 			if ( !stristr($cat,'-') )
       
   433 				$title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
       
   434 	} elseif ( !empty($category_name) ) {
       
   435 		if ( stristr($category_name,'/') ) {
       
   436 				$category_name = explode('/',$category_name);
       
   437 				if ( $category_name[count($category_name)-1] )
       
   438 					$category_name = $category_name[count($category_name)-1]; // no trailing slash
       
   439 				else
       
   440 					$category_name = $category_name[count($category_name)-2]; // there was a trailling slash
       
   441 		}
       
   442 		$cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display');
       
   443 		if ( $cat )
       
   444 			$title = apply_filters('single_cat_title', $cat->name);
       
   445 	}
       
   446 
       
   447 	if ( !empty($tag) ) {
       
   448 		$tag = get_term($tag, 'post_tag', OBJECT, 'display');
       
   449 		if ( is_wp_error( $tag ) )
       
   450 			return $tag;
       
   451 		if ( ! empty($tag->name) )
       
   452 			$title = apply_filters('single_tag_title', $tag->name);
       
   453 	}
       
   454 
       
   455 	// If there's an author
       
   456 	if ( !empty($author) ) {
       
   457 		$title = get_userdata($author);
       
   458 		$title = $title->display_name;
       
   459 	}
       
   460 	if ( !empty($author_name) ) {
       
   461 		// We do a direct query here because we don't cache by nicename.
       
   462 		$title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name));
       
   463 	}
       
   464 
       
   465 	// If there's a month
       
   466 	if ( !empty($m) ) {
       
   467 		$my_year = substr($m, 0, 4);
       
   468 		$my_month = $wp_locale->get_month(substr($m, 4, 2));
       
   469 		$my_day = intval(substr($m, 6, 2));
       
   470 		$title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : "");
       
   471 	}
       
   472 
       
   473 	if ( !empty($year) ) {
       
   474 		$title = $year;
       
   475 		if ( !empty($monthnum) )
       
   476 			$title .= "$t_sep" . $wp_locale->get_month($monthnum);
       
   477 		if ( !empty($day) )
       
   478 			$title .= "$t_sep" . zeroise($day, 2);
       
   479 	}
       
   480 
       
   481 	// If there is a post
       
   482 	if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
       
   483 		$post = $wp_query->get_queried_object();
       
   484 		$title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
       
   485 	}
       
   486 
       
   487 	// If there's a taxonomy
       
   488 	if ( is_tax() ) {
       
   489 		$taxonomy = get_query_var( 'taxonomy' );
       
   490 		$tax = get_taxonomy( $taxonomy );
       
   491 		$tax = $tax->label;
       
   492 		$term = $wp_query->get_queried_object();
       
   493 		$term = $term->name;
       
   494 		$title = "$tax$t_sep$term";
       
   495 	}
       
   496 
       
   497 	//If it's a search
       
   498 	if ( is_search() ) {
       
   499 		/* translators: 1: separator, 2: search phrase */
       
   500 		$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
       
   501 	}
       
   502 
       
   503 	if ( is_404() ) {
       
   504 		$title = __('Page not found');
       
   505 	}
       
   506 
       
   507 	$prefix = '';
       
   508 	if ( !empty($title) )
       
   509 		$prefix = " $sep ";
       
   510 
       
   511  	// Determines position of the separator and direction of the breadcrumb
       
   512 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
       
   513 		$title_array = explode( $t_sep, $title );
       
   514 		$title_array = array_reverse( $title_array );
       
   515 		$title = implode( " $sep ", $title_array ) . $prefix;
       
   516 	} else {
       
   517 		$title_array = explode( $t_sep, $title );
       
   518 		$title = $prefix . implode( " $sep ", $title_array );
       
   519 	}
       
   520 
       
   521 	$title = apply_filters('wp_title', $title, $sep, $seplocation);
       
   522 
       
   523 	// Send it out
       
   524 	if ( $display )
       
   525 		echo $title;
       
   526 	else
       
   527 		return $title;
       
   528 
       
   529 }
       
   530 
       
   531 /**
       
   532  * Display or retrieve page title for post.
       
   533  *
       
   534  * This is optimized for single.php template file for displaying the post title.
       
   535  * Only useful for posts, does not support pages for example.
       
   536  *
       
   537  * It does not support placing the separator after the title, but by leaving the
       
   538  * prefix parameter empty, you can set the title separator manually. The prefix
       
   539  * does not automatically place a space between the prefix, so if there should
       
   540  * be a space, the parameter value will need to have it at the end.
       
   541  *
       
   542  * @since 0.71
       
   543  * @uses $wpdb
       
   544  *
       
   545  * @param string $prefix Optional. What to display before the title.
       
   546  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   547  * @return string|null Title when retrieving, null when displaying or failure.
       
   548  */
       
   549 function single_post_title($prefix = '', $display = true) {
       
   550 	global $wpdb;
       
   551 	$p = get_query_var('p');
       
   552 	$name = get_query_var('name');
       
   553 
       
   554 	if ( intval($p) || '' != $name ) {
       
   555 		if ( !$p )
       
   556 			$p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
       
   557 		$post = & get_post($p);
       
   558 		$title = $post->post_title;
       
   559 		$title = apply_filters('single_post_title', $title);
       
   560 		if ( $display )
       
   561 			echo $prefix.strip_tags($title);
       
   562 		else
       
   563 			return strip_tags($title);
       
   564 	}
       
   565 }
       
   566 
       
   567 /**
       
   568  * Display or retrieve page title for category archive.
       
   569  *
       
   570  * This is useful for category template file or files, because it is optimized
       
   571  * for category page title and with less overhead than {@link wp_title()}.
       
   572  *
       
   573  * It does not support placing the separator after the title, but by leaving the
       
   574  * prefix parameter empty, you can set the title separator manually. The prefix
       
   575  * does not automatically place a space between the prefix, so if there should
       
   576  * be a space, the parameter value will need to have it at the end.
       
   577  *
       
   578  * @since 0.71
       
   579  *
       
   580  * @param string $prefix Optional. What to display before the title.
       
   581  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   582  * @return string|null Title when retrieving, null when displaying or failure.
       
   583  */
       
   584 function single_cat_title($prefix = '', $display = true ) {
       
   585 	$cat = intval( get_query_var('cat') );
       
   586 	if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
       
   587 		$my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
       
   588 		if ( !empty($my_cat_name) ) {
       
   589 			if ( $display )
       
   590 				echo $prefix.strip_tags($my_cat_name);
       
   591 			else
       
   592 				return strip_tags($my_cat_name);
       
   593 		}
       
   594 	} else if ( is_tag() ) {
       
   595 		return single_tag_title($prefix, $display);
       
   596 	}
       
   597 }
       
   598 
       
   599 /**
       
   600  * Display or retrieve page title for tag post archive.
       
   601  *
       
   602  * Useful for tag template files for displaying the tag page title. It has less
       
   603  * overhead than {@link wp_title()}, because of its limited implementation.
       
   604  *
       
   605  * It does not support placing the separator after the title, but by leaving the
       
   606  * prefix parameter empty, you can set the title separator manually. The prefix
       
   607  * does not automatically place a space between the prefix, so if there should
       
   608  * be a space, the parameter value will need to have it at the end.
       
   609  *
       
   610  * @since 2.3.0
       
   611  *
       
   612  * @param string $prefix Optional. What to display before the title.
       
   613  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   614  * @return string|null Title when retrieving, null when displaying or failure.
       
   615  */
       
   616 function single_tag_title($prefix = '', $display = true ) {
       
   617 	if ( !is_tag() )
       
   618 		return;
       
   619 
       
   620 	$tag_id = intval( get_query_var('tag_id') );
       
   621 
       
   622 	if ( !empty($tag_id) ) {
       
   623 		$my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
       
   624 		if ( is_wp_error( $my_tag ) )
       
   625 			return false;
       
   626 		$my_tag_name = apply_filters('single_tag_title', $my_tag->name);
       
   627 		if ( !empty($my_tag_name) ) {
       
   628 			if ( $display )
       
   629 				echo $prefix . $my_tag_name;
       
   630 			else
       
   631 				return $my_tag_name;
       
   632 		}
       
   633 	}
       
   634 }
       
   635 
       
   636 /**
       
   637  * Display or retrieve page title for post archive based on date.
       
   638  *
       
   639  * Useful for when the template only needs to display the month and year, if
       
   640  * either are available. Optimized for just this purpose, so if it is all that
       
   641  * is needed, should be better than {@link wp_title()}.
       
   642  *
       
   643  * It does not support placing the separator after the title, but by leaving the
       
   644  * prefix parameter empty, you can set the title separator manually. The prefix
       
   645  * does not automatically place a space between the prefix, so if there should
       
   646  * be a space, the parameter value will need to have it at the end.
       
   647  *
       
   648  * @since 0.71
       
   649  *
       
   650  * @param string $prefix Optional. What to display before the title.
       
   651  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   652  * @return string|null Title when retrieving, null when displaying or failure.
       
   653  */
       
   654 function single_month_title($prefix = '', $display = true ) {
       
   655 	global $wp_locale;
       
   656 
       
   657 	$m = get_query_var('m');
       
   658 	$year = get_query_var('year');
       
   659 	$monthnum = get_query_var('monthnum');
       
   660 
       
   661 	if ( !empty($monthnum) && !empty($year) ) {
       
   662 		$my_year = $year;
       
   663 		$my_month = $wp_locale->get_month($monthnum);
       
   664 	} elseif ( !empty($m) ) {
       
   665 		$my_year = substr($m, 0, 4);
       
   666 		$my_month = $wp_locale->get_month(substr($m, 4, 2));
       
   667 	}
       
   668 
       
   669 	if ( empty($my_month) )
       
   670 		return false;
       
   671 
       
   672 	$result = $prefix . $my_month . $prefix . $my_year;
       
   673 
       
   674 	if ( !$display )
       
   675 		return $result;
       
   676 	echo $result;
       
   677 }
       
   678 
       
   679 /**
       
   680  * Retrieve archive link content based on predefined or custom code.
       
   681  *
       
   682  * The format can be one of four styles. The 'link' for head element, 'option'
       
   683  * for use in the select element, 'html' for use in list (either ol or ul HTML
       
   684  * elements). Custom content is also supported using the before and after
       
   685  * parameters.
       
   686  *
       
   687  * The 'link' format uses the link HTML element with the <em>archives</em>
       
   688  * relationship. The before and after parameters are not used. The text
       
   689  * parameter is used to describe the link.
       
   690  *
       
   691  * The 'option' format uses the option HTML element for use in select element.
       
   692  * The value is the url parameter and the before and after parameters are used
       
   693  * between the text description.
       
   694  *
       
   695  * The 'html' format, which is the default, uses the li HTML element for use in
       
   696  * the list HTML elements. The before parameter is before the link and the after
       
   697  * parameter is after the closing link.
       
   698  *
       
   699  * The custom format uses the before parameter before the link ('a' HTML
       
   700  * element) and the after parameter after the closing link tag. If the above
       
   701  * three values for the format are not used, then custom format is assumed.
       
   702  *
       
   703  * @since 1.0.0
       
   704  * @author Orien
       
   705  * @link http://icecode.com/ link navigation hack by Orien
       
   706  *
       
   707  * @param string $url URL to archive.
       
   708  * @param string $text Archive text description.
       
   709  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
       
   710  * @param string $before Optional.
       
   711  * @param string $after Optional.
       
   712  * @return string HTML link content for archive.
       
   713  */
       
   714 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
       
   715 	$text = wptexturize($text);
       
   716 	$title_text = esc_attr($text);
       
   717 	$url = esc_url($url);
       
   718 
       
   719 	if ('link' == $format)
       
   720 		$link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
       
   721 	elseif ('option' == $format)
       
   722 		$link_html = "\t<option value='$url'>$before $text $after</option>\n";
       
   723 	elseif ('html' == $format)
       
   724 		$link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
       
   725 	else // custom
       
   726 		$link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
       
   727 
       
   728 	$link_html = apply_filters( "get_archives_link", $link_html );
       
   729 
       
   730 	return $link_html;
       
   731 }
       
   732 
       
   733 /**
       
   734  * Display archive links based on type and format.
       
   735  *
       
   736  * The 'type' argument offers a few choices and by default will display monthly
       
   737  * archive links. The other options for values are 'daily', 'weekly', 'monthly',
       
   738  * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
       
   739  * same archive link list, the difference between the two is that 'alpha'
       
   740  * will order by post title and 'postbypost' will order by post date.
       
   741  *
       
   742  * The date archives will logically display dates with links to the archive post
       
   743  * page. The 'postbypost' and 'alpha' values for 'type' argument will display
       
   744  * the post titles.
       
   745  *
       
   746  * The 'limit' argument will only display a limited amount of links, specified
       
   747  * by the 'limit' integer value. By default, there is no limit. The
       
   748  * 'show_post_count' argument will show how many posts are within the archive.
       
   749  * By default, the 'show_post_count' argument is set to false.
       
   750  *
       
   751  * For the 'format', 'before', and 'after' arguments, see {@link
       
   752  * get_archives_link()}. The values of these arguments have to do with that
       
   753  * function.
       
   754  *
       
   755  * @since 1.2.0
       
   756  *
       
   757  * @param string|array $args Optional. Override defaults.
       
   758  */
       
   759 function wp_get_archives($args = '') {
       
   760 	global $wpdb, $wp_locale;
       
   761 
       
   762 	$defaults = array(
       
   763 		'type' => 'monthly', 'limit' => '',
       
   764 		'format' => 'html', 'before' => '',
       
   765 		'after' => '', 'show_post_count' => false,
       
   766 		'echo' => 1
       
   767 	);
       
   768 
       
   769 	$r = wp_parse_args( $args, $defaults );
       
   770 	extract( $r, EXTR_SKIP );
       
   771 
       
   772 	if ( '' == $type )
       
   773 		$type = 'monthly';
       
   774 
       
   775 	if ( '' != $limit ) {
       
   776 		$limit = absint($limit);
       
   777 		$limit = ' LIMIT '.$limit;
       
   778 	}
       
   779 
       
   780 	// this is what will separate dates on weekly archive links
       
   781 	$archive_week_separator = '&#8211;';
       
   782 
       
   783 	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
       
   784 	$archive_date_format_over_ride = 0;
       
   785 
       
   786 	// options for daily archive (only if you over-ride the general date format)
       
   787 	$archive_day_date_format = 'Y/m/d';
       
   788 
       
   789 	// options for weekly archive (only if you over-ride the general date format)
       
   790 	$archive_week_start_date_format = 'Y/m/d';
       
   791 	$archive_week_end_date_format	= 'Y/m/d';
       
   792 
       
   793 	if ( !$archive_date_format_over_ride ) {
       
   794 		$archive_day_date_format = get_option('date_format');
       
   795 		$archive_week_start_date_format = get_option('date_format');
       
   796 		$archive_week_end_date_format = get_option('date_format');
       
   797 	}
       
   798 
       
   799 	//filters
       
   800 	$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
       
   801 	$join = apply_filters('getarchives_join', "", $r);
       
   802 
       
   803 	$output = '';
       
   804 
       
   805 	if ( 'monthly' == $type ) {
       
   806 		$query = "SELECT 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";
       
   807 		$key = md5($query);
       
   808 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
       
   809 		if ( !isset( $cache[ $key ] ) ) {
       
   810 			$arcresults = $wpdb->get_results($query);
       
   811 			$cache[ $key ] = $arcresults;
       
   812 			wp_cache_add( 'wp_get_archives', $cache, 'general' );
       
   813 		} else {
       
   814 			$arcresults = $cache[ $key ];
       
   815 		}
       
   816 		if ( $arcresults ) {
       
   817 			$afterafter = $after;
       
   818 			foreach ( (array) $arcresults as $arcresult ) {
       
   819 				$url = get_month_link( $arcresult->year, $arcresult->month );
       
   820 				$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
       
   821 				if ( $show_post_count )
       
   822 					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
       
   823 				$output .= get_archives_link($url, $text, $format, $before, $after);
       
   824 			}
       
   825 		}
       
   826 	} elseif ('yearly' == $type) {
       
   827 		$query = "SELECT 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";
       
   828 		$key = md5($query);
       
   829 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
       
   830 		if ( !isset( $cache[ $key ] ) ) {
       
   831 			$arcresults = $wpdb->get_results($query);
       
   832 			$cache[ $key ] = $arcresults;
       
   833 			wp_cache_add( 'wp_get_archives', $cache, 'general' );
       
   834 		} else {
       
   835 			$arcresults = $cache[ $key ];
       
   836 		}
       
   837 		if ($arcresults) {
       
   838 			$afterafter = $after;
       
   839 			foreach ( (array) $arcresults as $arcresult) {
       
   840 				$url = get_year_link($arcresult->year);
       
   841 				$text = sprintf('%d', $arcresult->year);
       
   842 				if ($show_post_count)
       
   843 					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
       
   844 				$output .= get_archives_link($url, $text, $format, $before, $after);
       
   845 			}
       
   846 		}
       
   847 	} elseif ( 'daily' == $type ) {
       
   848 		$query = "SELECT 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";
       
   849 		$key = md5($query);
       
   850 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
       
   851 		if ( !isset( $cache[ $key ] ) ) {
       
   852 			$arcresults = $wpdb->get_results($query);
       
   853 			$cache[ $key ] = $arcresults;
       
   854 			wp_cache_add( 'wp_get_archives', $cache, 'general' );
       
   855 		} else {
       
   856 			$arcresults = $cache[ $key ];
       
   857 		}
       
   858 		if ( $arcresults ) {
       
   859 			$afterafter = $after;
       
   860 			foreach ( (array) $arcresults as $arcresult ) {
       
   861 				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
       
   862 				$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
       
   863 				$text = mysql2date($archive_day_date_format, $date);
       
   864 				if ($show_post_count)
       
   865 					$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
       
   866 				$output .= get_archives_link($url, $text, $format, $before, $after);
       
   867 			}
       
   868 		}
       
   869 	} elseif ( 'weekly' == $type ) {
       
   870 		$start_of_week = get_option('start_of_week');
       
   871 		$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";
       
   872 		$key = md5($query);
       
   873 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
       
   874 		if ( !isset( $cache[ $key ] ) ) {
       
   875 			$arcresults = $wpdb->get_results($query);
       
   876 			$cache[ $key ] = $arcresults;
       
   877 			wp_cache_add( 'wp_get_archives', $cache, 'general' );
       
   878 		} else {
       
   879 			$arcresults = $cache[ $key ];
       
   880 		}
       
   881 		$arc_w_last = '';
       
   882 		$afterafter = $after;
       
   883 		if ( $arcresults ) {
       
   884 				foreach ( (array) $arcresults as $arcresult ) {
       
   885 					if ( $arcresult->week != $arc_w_last ) {
       
   886 						$arc_year = $arcresult->yr;
       
   887 						$arc_w_last = $arcresult->week;
       
   888 						$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
       
   889 						$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
       
   890 						$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
       
   891 						$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);
       
   892 						$text = $arc_week_start . $archive_week_separator . $arc_week_end;
       
   893 						if ($show_post_count)
       
   894 							$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
       
   895 						$output .= get_archives_link($url, $text, $format, $before, $after);
       
   896 					}
       
   897 				}
       
   898 		}
       
   899 	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
       
   900 		$orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
       
   901 		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
       
   902 		$key = md5($query);
       
   903 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
       
   904 		if ( !isset( $cache[ $key ] ) ) {
       
   905 			$arcresults = $wpdb->get_results($query);
       
   906 			$cache[ $key ] = $arcresults;
       
   907 			wp_cache_add( 'wp_get_archives', $cache, 'general' );
       
   908 		} else {
       
   909 			$arcresults = $cache[ $key ];
       
   910 		}
       
   911 		if ( $arcresults ) {
       
   912 			foreach ( (array) $arcresults as $arcresult ) {
       
   913 				if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
       
   914 					$url  = get_permalink($arcresult);
       
   915 					$arc_title = $arcresult->post_title;
       
   916 					if ( $arc_title )
       
   917 						$text = strip_tags(apply_filters('the_title', $arc_title));
       
   918 					else
       
   919 						$text = $arcresult->ID;
       
   920 					$output .= get_archives_link($url, $text, $format, $before, $after);
       
   921 				}
       
   922 			}
       
   923 		}
       
   924 	}
       
   925 	if ( $echo )
       
   926 		echo $output;
       
   927 	else
       
   928 		return $output;
       
   929 }
       
   930 
       
   931 /**
       
   932  * Get number of days since the start of the week.
       
   933  *
       
   934  * @since 1.5.0
       
   935  * @usedby get_calendar()
       
   936  *
       
   937  * @param int $num Number of day.
       
   938  * @return int Days since the start of the week.
       
   939  */
       
   940 function calendar_week_mod($num) {
       
   941 	$base = 7;
       
   942 	return ($num - $base*floor($num/$base));
       
   943 }
       
   944 
       
   945 /**
       
   946  * Display calendar with days that have posts as links.
       
   947  *
       
   948  * The calendar is cached, which will be retrieved, if it exists. If there are
       
   949  * no posts for the month, then it will not be displayed.
       
   950  *
       
   951  * @since 1.0.0
       
   952  *
       
   953  * @param bool $initial Optional, default is true. Use initial calendar names.
       
   954  */
       
   955 function get_calendar($initial = true) {
       
   956 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
       
   957 
       
   958 	$cache = array();
       
   959 	$key = md5( $m . $monthnum . $year );
       
   960 	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
       
   961 		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
       
   962 			echo $cache[ $key ];
       
   963 			return;
       
   964 		}
       
   965 	}
       
   966 
       
   967 	if ( !is_array($cache) )
       
   968 		$cache = array();
       
   969 
       
   970 	// Quick check. If we have no posts at all, abort!
       
   971 	if ( !$posts ) {
       
   972 		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
       
   973 		if ( !$gotsome ) {
       
   974 			$cache[ $key ] = '';
       
   975 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
       
   976 			return;
       
   977 		}
       
   978 	}
       
   979 
       
   980 	ob_start();
       
   981 	if ( isset($_GET['w']) )
       
   982 		$w = ''.intval($_GET['w']);
       
   983 
       
   984 	// week_begins = 0 stands for Sunday
       
   985 	$week_begins = intval(get_option('start_of_week'));
       
   986 
       
   987 	// Let's figure out when we are
       
   988 	if ( !empty($monthnum) && !empty($year) ) {
       
   989 		$thismonth = ''.zeroise(intval($monthnum), 2);
       
   990 		$thisyear = ''.intval($year);
       
   991 	} elseif ( !empty($w) ) {
       
   992 		// We need to get the month from MySQL
       
   993 		$thisyear = ''.intval(substr($m, 0, 4));
       
   994 		$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
       
   995 		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
       
   996 	} elseif ( !empty($m) ) {
       
   997 		$thisyear = ''.intval(substr($m, 0, 4));
       
   998 		if ( strlen($m) < 6 )
       
   999 				$thismonth = '01';
       
  1000 		else
       
  1001 				$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
       
  1002 	} else {
       
  1003 		$thisyear = gmdate('Y', current_time('timestamp'));
       
  1004 		$thismonth = gmdate('m', current_time('timestamp'));
       
  1005 	}
       
  1006 
       
  1007 	$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
       
  1008 
       
  1009 	// Get the next and previous month and year with at least one post
       
  1010 	$previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
       
  1011 		FROM $wpdb->posts
       
  1012 		WHERE post_date < '$thisyear-$thismonth-01'
       
  1013 		AND post_type = 'post' AND post_status = 'publish'
       
  1014 			ORDER BY post_date DESC
       
  1015 			LIMIT 1");
       
  1016 	$next = $wpdb->get_row("SELECT	DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
       
  1017 		FROM $wpdb->posts
       
  1018 		WHERE post_date >	'$thisyear-$thismonth-01'
       
  1019 		AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
       
  1020 		AND post_type = 'post' AND post_status = 'publish'
       
  1021 			ORDER	BY post_date ASC
       
  1022 			LIMIT 1");
       
  1023 
       
  1024 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
       
  1025 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
       
  1026 	echo '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">
       
  1027 	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
       
  1028 	<thead>
       
  1029 	<tr>';
       
  1030 
       
  1031 	$myweek = array();
       
  1032 
       
  1033 	for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
       
  1034 		$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
       
  1035 	}
       
  1036 
       
  1037 	foreach ( $myweek as $wd ) {
       
  1038 		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
       
  1039 		$wd = esc_attr($wd);
       
  1040 		echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
       
  1041 	}
       
  1042 
       
  1043 	echo '
       
  1044 	</tr>
       
  1045 	</thead>
       
  1046 
       
  1047 	<tfoot>
       
  1048 	<tr>';
       
  1049 
       
  1050 	if ( $previous ) {
       
  1051 		echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
       
  1052 		get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
       
  1053 			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>';
       
  1054 	} else {
       
  1055 		echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
       
  1056 	}
       
  1057 
       
  1058 	echo "\n\t\t".'<td class="pad">&nbsp;</td>';
       
  1059 
       
  1060 	if ( $next ) {
       
  1061 		echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
       
  1062 		get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) ,
       
  1063 			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>';
       
  1064 	} else {
       
  1065 		echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
       
  1066 	}
       
  1067 
       
  1068 	echo '
       
  1069 	</tr>
       
  1070 	</tfoot>
       
  1071 
       
  1072 	<tbody>
       
  1073 	<tr>';
       
  1074 
       
  1075 	// Get days with posts
       
  1076 	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
       
  1077 		FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
       
  1078 		AND YEAR(post_date) = '$thisyear'
       
  1079 		AND post_type = 'post' AND post_status = 'publish'
       
  1080 		AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
       
  1081 	if ( $dayswithposts ) {
       
  1082 		foreach ( (array) $dayswithposts as $daywith ) {
       
  1083 			$daywithpost[] = $daywith[0];
       
  1084 		}
       
  1085 	} else {
       
  1086 		$daywithpost = array();
       
  1087 	}
       
  1088 
       
  1089 	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false)
       
  1090 		$ak_title_separator = "\n";
       
  1091 	else
       
  1092 		$ak_title_separator = ', ';
       
  1093 
       
  1094 	$ak_titles_for_day = array();
       
  1095 	$ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
       
  1096 		."FROM $wpdb->posts "
       
  1097 		."WHERE YEAR(post_date) = '$thisyear' "
       
  1098 		."AND MONTH(post_date) = '$thismonth' "
       
  1099 		."AND post_date < '".current_time('mysql')."' "
       
  1100 		."AND post_type = 'post' AND post_status = 'publish'"
       
  1101 	);
       
  1102 	if ( $ak_post_titles ) {
       
  1103 		foreach ( (array) $ak_post_titles as $ak_post_title ) {
       
  1104 
       
  1105 				$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title ) );
       
  1106 
       
  1107 				if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
       
  1108 					$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
       
  1109 				if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
       
  1110 					$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
       
  1111 				else
       
  1112 					$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
       
  1113 		}
       
  1114 	}
       
  1115 
       
  1116 
       
  1117 	// See how much we should pad in the beginning
       
  1118 	$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
       
  1119 	if ( 0 != $pad )
       
  1120 		echo "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
       
  1121 
       
  1122 	$daysinmonth = intval(date('t', $unixmonth));
       
  1123 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
       
  1124 		if ( isset($newrow) && $newrow )
       
  1125 			echo "\n\t</tr>\n\t<tr>\n\t\t";
       
  1126 		$newrow = false;
       
  1127 
       
  1128 		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)) )
       
  1129 			echo '<td id="today">';
       
  1130 		else
       
  1131 			echo '<td>';
       
  1132 
       
  1133 		if ( in_array($day, $daywithpost) ) // any posts today?
       
  1134 				echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>";
       
  1135 		else
       
  1136 			echo $day;
       
  1137 		echo '</td>';
       
  1138 
       
  1139 		if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
       
  1140 			$newrow = true;
       
  1141 	}
       
  1142 
       
  1143 	$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
       
  1144 	if ( $pad != 0 && $pad != 7 )
       
  1145 		echo "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
       
  1146 
       
  1147 	echo "\n\t</tr>\n\t</tbody>\n\t</table>";
       
  1148 
       
  1149 	$output = ob_get_contents();
       
  1150 	ob_end_clean();
       
  1151 	echo $output;
       
  1152 	$cache[ $key ] = $output;
       
  1153 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
       
  1154 }
       
  1155 
       
  1156 /**
       
  1157  * Purge the cached results of get_calendar.
       
  1158  *
       
  1159  * @see get_calendar
       
  1160  * @since 2.1.0
       
  1161  */
       
  1162 function delete_get_calendar_cache() {
       
  1163 	wp_cache_delete( 'get_calendar', 'calendar' );
       
  1164 }
       
  1165 add_action( 'save_post', 'delete_get_calendar_cache' );
       
  1166 add_action( 'delete_post', 'delete_get_calendar_cache' );
       
  1167 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
       
  1168 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
       
  1169 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
       
  1170 
       
  1171 /**
       
  1172  * Display all of the allowed tags in HTML format with attributes.
       
  1173  *
       
  1174  * This is useful for displaying in the comment area, which elements and
       
  1175  * attributes are supported. As well as any plugins which want to display it.
       
  1176  *
       
  1177  * @since 1.0.1
       
  1178  * @uses $allowedtags
       
  1179  *
       
  1180  * @return string HTML allowed tags entity encoded.
       
  1181  */
       
  1182 function allowed_tags() {
       
  1183 	global $allowedtags;
       
  1184 	$allowed = '';
       
  1185 	foreach ( (array) $allowedtags as $tag => $attributes ) {
       
  1186 		$allowed .= '<'.$tag;
       
  1187 		if ( 0 < count($attributes) ) {
       
  1188 			foreach ( $attributes as $attribute => $limits ) {
       
  1189 				$allowed .= ' '.$attribute.'=""';
       
  1190 			}
       
  1191 		}
       
  1192 		$allowed .= '> ';
       
  1193 	}
       
  1194 	return htmlentities($allowed);
       
  1195 }
       
  1196 
       
  1197 /***** Date/Time tags *****/
       
  1198 
       
  1199 /**
       
  1200  * Outputs the date in iso8601 format for xml files.
       
  1201  *
       
  1202  * @since 1.0.0
       
  1203  */
       
  1204 function the_date_xml() {
       
  1205 	global $post;
       
  1206 	echo mysql2date('Y-m-d', $post->post_date, false);
       
  1207 }
       
  1208 
       
  1209 /**
       
  1210  * Display or Retrieve the date the post was written.
       
  1211  *
       
  1212  * Will only output the date if the current post's date is different from the
       
  1213  * previous one output.
       
  1214  *
       
  1215  * @since 0.71
       
  1216  *
       
  1217  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
       
  1218  * @param string $before Optional. Output before the date.
       
  1219  * @param string $after Optional. Output after the date.
       
  1220  * @param bool $echo Optional, default is display. Whether to echo the date or return it.
       
  1221  * @return string|null Null if displaying, string if retrieving.
       
  1222  */
       
  1223 function the_date($d='', $before='', $after='', $echo = true) {
       
  1224 	global $post, $day, $previousday;
       
  1225 	$the_date = '';
       
  1226 	if ( $day != $previousday ) {
       
  1227 		$the_date .= $before;
       
  1228 		if ( $d=='' )
       
  1229 			$the_date .= mysql2date(get_option('date_format'), $post->post_date);
       
  1230 		else
       
  1231 			$the_date .= mysql2date($d, $post->post_date);
       
  1232 		$the_date .= $after;
       
  1233 		$previousday = $day;
       
  1234 
       
  1235 	$the_date = apply_filters('the_date', $the_date, $d, $before, $after);
       
  1236 	if ( $echo )
       
  1237 		echo $the_date;
       
  1238 	else
       
  1239 		return $the_date;
       
  1240 	}
       
  1241 }
       
  1242 
       
  1243 /**
       
  1244  * Display the date on which the post was last modified.
       
  1245  *
       
  1246  * @since 2.1.0
       
  1247  *
       
  1248  * @param string $d Optional. PHP date format.
       
  1249  * @return string
       
  1250  */
       
  1251 function the_modified_date($d = '') {
       
  1252 	echo apply_filters('the_modified_date', get_the_modified_date($d), $d);
       
  1253 }
       
  1254 
       
  1255 /**
       
  1256  * Retrieve the date on which the post was last modified.
       
  1257  *
       
  1258  * @since 2.1.0
       
  1259  *
       
  1260  * @param string $d Optional. PHP date format. Defaults to the "date_format" option
       
  1261  * @return string
       
  1262  */
       
  1263 function get_the_modified_date($d = '') {
       
  1264 	if ( '' == $d )
       
  1265 		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
       
  1266 	else
       
  1267 		$the_time = get_post_modified_time($d, null, null, true);
       
  1268 	return apply_filters('get_the_modified_date', $the_time, $d);
       
  1269 }
       
  1270 
       
  1271 /**
       
  1272  * Display the time at which the post was written.
       
  1273  *
       
  1274  * @since 0.71
       
  1275  *
       
  1276  * @param string $d Either 'G', 'U', or php date format.
       
  1277  */
       
  1278 function the_time( $d = '' ) {
       
  1279 	echo apply_filters('the_time', get_the_time( $d ), $d);
       
  1280 }
       
  1281 
       
  1282 /**
       
  1283  * Retrieve the time at which the post was written.
       
  1284  *
       
  1285  * @since 1.5.0
       
  1286  *
       
  1287  * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
       
  1288  * @param int|object $post Optional post ID or object. Default is global $post object.
       
  1289  * @return string
       
  1290  */
       
  1291 function get_the_time( $d = '', $post = null ) {
       
  1292 	$post = get_post($post);
       
  1293 
       
  1294 	if ( '' == $d )
       
  1295 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
       
  1296 	else
       
  1297 		$the_time = get_post_time($d, false, $post, true);
       
  1298 	return apply_filters('get_the_time', $the_time, $d, $post);
       
  1299 }
       
  1300 
       
  1301 /**
       
  1302  * Retrieve the time at which the post was written.
       
  1303  *
       
  1304  * @since 2.0.0
       
  1305  *
       
  1306  * @param string $d Either 'G', 'U', or php date format.
       
  1307  * @param bool $gmt Whether of not to return the gmt time.
       
  1308  * @param int|object $post Optional post ID or object. Default is global $post object.
       
  1309  * @param bool $translate Whether to translate the time string or not
       
  1310  * @return string
       
  1311  */
       
  1312 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
       
  1313 	$post = get_post($post);
       
  1314 
       
  1315 	if ( $gmt )
       
  1316 		$time = $post->post_date_gmt;
       
  1317 	else
       
  1318 		$time = $post->post_date;
       
  1319 
       
  1320 	$time = mysql2date($d, $time, $translate);
       
  1321 	return apply_filters('get_post_time', $time, $d, $gmt);
       
  1322 }
       
  1323 
       
  1324 /**
       
  1325  * Display the time at which the post was last modified.
       
  1326  *
       
  1327  * @since 2.0.0
       
  1328  *
       
  1329  * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
       
  1330  */
       
  1331 function the_modified_time($d = '') {
       
  1332 	echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
       
  1333 }
       
  1334 
       
  1335 /**
       
  1336  * Retrieve the time at which the post was last modified.
       
  1337  *
       
  1338  * @since 2.0.0
       
  1339  *
       
  1340  * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
       
  1341  * @return string
       
  1342  */
       
  1343 function get_the_modified_time($d = '') {
       
  1344 	if ( '' == $d )
       
  1345 		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
       
  1346 	else
       
  1347 		$the_time = get_post_modified_time($d, null, null, true);
       
  1348 	return apply_filters('get_the_modified_time', $the_time, $d);
       
  1349 }
       
  1350 
       
  1351 /**
       
  1352  * Retrieve the time at which the post was last modified.
       
  1353  *
       
  1354  * @since 2.0.0
       
  1355  *
       
  1356  * @param string $d Either 'G', 'U', or php date format.
       
  1357  * @param bool $gmt Whether of not to return the gmt time.
       
  1358  * @param int|object $post A post_id or post object
       
  1359  * @param bool translate Whether to translate the result or not
       
  1360  * @return string Returns timestamp
       
  1361  */
       
  1362 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
       
  1363 	$post = get_post($post);
       
  1364 
       
  1365 	if ( $gmt )
       
  1366 		$time = $post->post_modified_gmt;
       
  1367 	else
       
  1368 		$time = $post->post_modified;
       
  1369 	$time = mysql2date($d, $time, $translate);
       
  1370 
       
  1371 	return apply_filters('get_post_modified_time', $time, $d, $gmt);
       
  1372 }
       
  1373 
       
  1374 /**
       
  1375  * Display the weekday on which the post was written.
       
  1376  *
       
  1377  * @since 0.71
       
  1378  * @uses $wp_locale
       
  1379  * @uses $post
       
  1380  */
       
  1381 function the_weekday() {
       
  1382 	global $wp_locale, $post;
       
  1383 	$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
       
  1384 	$the_weekday = apply_filters('the_weekday', $the_weekday);
       
  1385 	echo $the_weekday;
       
  1386 }
       
  1387 
       
  1388 /**
       
  1389  * Display the weekday on which the post was written.
       
  1390  *
       
  1391  * Will only output the weekday if the current post's weekday is different from
       
  1392  * the previous one output.
       
  1393  *
       
  1394  * @since 0.71
       
  1395  *
       
  1396  * @param string $before output before the date.
       
  1397  * @param string $after output after the date.
       
  1398   */
       
  1399 function the_weekday_date($before='',$after='') {
       
  1400 	global $wp_locale, $post, $day, $previousweekday;
       
  1401 	$the_weekday_date = '';
       
  1402 	if ( $day != $previousweekday ) {
       
  1403 		$the_weekday_date .= $before;
       
  1404 		$the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
       
  1405 		$the_weekday_date .= $after;
       
  1406 		$previousweekday = $day;
       
  1407 	}
       
  1408 	$the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
       
  1409 	echo $the_weekday_date;
       
  1410 }
       
  1411 
       
  1412 /**
       
  1413  * Fire the wp_head action
       
  1414  *
       
  1415  * @since 1.2.0
       
  1416  * @uses do_action() Calls 'wp_head' hook.
       
  1417  */
       
  1418 function wp_head() {
       
  1419 	do_action('wp_head');
       
  1420 }
       
  1421 
       
  1422 /**
       
  1423  * Fire the wp_footer action
       
  1424  *
       
  1425  * @since 1.5.1
       
  1426  * @uses do_action() Calls 'wp_footer' hook.
       
  1427  */
       
  1428 function wp_footer() {
       
  1429 	do_action('wp_footer');
       
  1430 }
       
  1431 
       
  1432 /**
       
  1433  * Enable/disable automatic general feed link outputting.
       
  1434  *
       
  1435  * @since 2.8.0
       
  1436  *
       
  1437  * @param boolean $add Add or remove links. Defaults to true.
       
  1438  */
       
  1439 function automatic_feed_links( $add = true ) {
       
  1440 	if ( $add )
       
  1441 		add_action( 'wp_head', 'feed_links', 2 );
       
  1442 	else {
       
  1443 		remove_action( 'wp_head', 'feed_links', 2 );
       
  1444 		remove_action( 'wp_head', 'feed_links_extra', 3 );
       
  1445 	}
       
  1446 }
       
  1447 
       
  1448 /**
       
  1449  * Display the links to the general feeds.
       
  1450  *
       
  1451  * @since 2.8.0
       
  1452  *
       
  1453  * @param array $args Optional arguments.
       
  1454  */
       
  1455 function feed_links( $args ) {
       
  1456 	$defaults = array(
       
  1457 		/* translators: Separator between blog name and feed type in feed links */
       
  1458 		'separator'	=> _x('&raquo;', 'feed link'),
       
  1459 		/* translators: 1: blog title, 2: separator (raquo) */
       
  1460 		'feedtitle'	=> __('%1$s %2$s Feed'),
       
  1461 		/* translators: %s: blog title, 2: separator (raquo) */
       
  1462 		'comstitle'	=> __('%1$s %2$s Comments Feed'),
       
  1463 	);
       
  1464 
       
  1465 	$args = wp_parse_args( $args, $defaults );
       
  1466 
       
  1467 	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
       
  1468 	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n";
       
  1469 }
       
  1470 
       
  1471 /**
       
  1472  * Display the links to the extra feeds such as category feeds.
       
  1473  *
       
  1474  * @since 2.8.0
       
  1475  *
       
  1476  * @param array $args Optional arguments.
       
  1477  */
       
  1478 function feed_links_extra( $args ) {
       
  1479 	$defaults = array(
       
  1480 		/* translators: Separator between blog name and feed type in feed links */
       
  1481 		'separator'   => _x('&raquo;', 'feed link'),
       
  1482 		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
       
  1483 		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
       
  1484 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
       
  1485 		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
       
  1486 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
       
  1487 		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
       
  1488 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
       
  1489 		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
       
  1490 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
       
  1491 		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
       
  1492 	);
       
  1493 
       
  1494 	$args = wp_parse_args( $args, $defaults );
       
  1495 
       
  1496 	if ( is_single() || is_page() ) {
       
  1497 		$post = &get_post( $id = 0 );
       
  1498 
       
  1499 		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
       
  1500 			$title = esc_attr(sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ));
       
  1501 			$href = get_post_comments_feed_link( $post->ID );
       
  1502 		}
       
  1503 	} elseif ( is_category() ) {
       
  1504 		$cat_id = intval( get_query_var('cat') );
       
  1505 
       
  1506 		$title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], get_cat_name( $cat_id ) ));
       
  1507 		$href = get_category_feed_link( $cat_id );
       
  1508 	} elseif ( is_tag() ) {
       
  1509 		$tag_id = intval( get_query_var('tag_id') );
       
  1510 		$tag = get_tag( $tag_id );
       
  1511 
       
  1512 		$title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name ));
       
  1513 		$href = get_tag_feed_link( $tag_id );
       
  1514 	} elseif ( is_author() ) {
       
  1515 		$author_id = intval( get_query_var('author') );
       
  1516 
       
  1517 		$title = esc_attr(sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ));
       
  1518 		$href = get_author_feed_link( $author_id );
       
  1519 	} elseif ( is_search() ) {
       
  1520 		$title = esc_attr(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query() ));
       
  1521 		$href = get_search_feed_link();
       
  1522 	}
       
  1523 
       
  1524 	if ( isset($title) && isset($href) )
       
  1525 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
       
  1526 }
       
  1527 
       
  1528 /**
       
  1529  * Display the link to the Really Simple Discovery service endpoint.
       
  1530  *
       
  1531  * @link http://archipelago.phrasewise.com/rsd
       
  1532  * @since 2.0.0
       
  1533  */
       
  1534 function rsd_link() {
       
  1535 	echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
       
  1536 }
       
  1537 
       
  1538 /**
       
  1539  * Display the link to the Windows Live Writer manifest file.
       
  1540  *
       
  1541  * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
       
  1542  * @since 2.3.1
       
  1543  */
       
  1544 function wlwmanifest_link() {
       
  1545 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
       
  1546 		. get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
       
  1547 }
       
  1548 
       
  1549 /**
       
  1550  * Display a noindex meta tag if required by the blog configuration.
       
  1551  *
       
  1552  * If a blog is marked as not being public then the noindex meta tag will be
       
  1553  * output to tell web robots not to index the page content.
       
  1554  *
       
  1555  * @since 2.1.0
       
  1556  */
       
  1557 function noindex() {
       
  1558 	// If the blog is not public, tell robots to go away.
       
  1559 	if ( '0' == get_option('blog_public') )
       
  1560 		echo "<meta name='robots' content='noindex,nofollow' />\n";
       
  1561 }
       
  1562 
       
  1563 /**
       
  1564  * Determine if TinyMCE is available.
       
  1565  *
       
  1566  * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
       
  1567  *
       
  1568  * @since 2.1.0
       
  1569  *
       
  1570  * @return bool Whether of not TinyMCE exists.
       
  1571  */
       
  1572 function rich_edit_exists() {
       
  1573 	global $wp_rich_edit_exists;
       
  1574 	if ( !isset($wp_rich_edit_exists) )
       
  1575 		$wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
       
  1576 	return $wp_rich_edit_exists;
       
  1577 }
       
  1578 
       
  1579 /**
       
  1580  * Whether or not the user should have a WYSIWIG editor.
       
  1581  *
       
  1582  * Checks that the user requires a WYSIWIG editor and that the editor is
       
  1583  * supported in the users browser.
       
  1584  *
       
  1585  * @since 2.0.0
       
  1586  *
       
  1587  * @return bool
       
  1588  */
       
  1589 function user_can_richedit() {
       
  1590 	global $wp_rich_edit, $pagenow;
       
  1591 
       
  1592 	if ( !isset( $wp_rich_edit) ) {
       
  1593 		if ( get_user_option( 'rich_editing' ) == 'true' &&
       
  1594 			( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
       
  1595 				!preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
       
  1596 				&& 'comment.php' != $pagenow ) {
       
  1597 			$wp_rich_edit = true;
       
  1598 		} else {
       
  1599 			$wp_rich_edit = false;
       
  1600 		}
       
  1601 	}
       
  1602 
       
  1603 	return apply_filters('user_can_richedit', $wp_rich_edit);
       
  1604 }
       
  1605 
       
  1606 /**
       
  1607  * Find out which editor should be displayed by default.
       
  1608  *
       
  1609  * Works out which of the two editors to display as the current editor for a
       
  1610  * user.
       
  1611  *
       
  1612  * @since 2.5.0
       
  1613  *
       
  1614  * @return string Either 'tinymce', or 'html', or 'test'
       
  1615  */
       
  1616 function wp_default_editor() {
       
  1617 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
       
  1618 	if ( $user = wp_get_current_user() ) { // look for cookie
       
  1619 		$ed = get_user_setting('editor', 'tinymce');
       
  1620 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
       
  1621 	}
       
  1622 	return apply_filters( 'wp_default_editor', $r ); // filter
       
  1623 }
       
  1624 
       
  1625 /**
       
  1626  * Display visual editor forms: TinyMCE, or HTML, or both.
       
  1627  *
       
  1628  * The amount of rows the text area will have for the content has to be between
       
  1629  * 3 and 100 or will default at 12. There is only one option used for all users,
       
  1630  * named 'default_post_edit_rows'.
       
  1631  *
       
  1632  * If the user can not use the rich editor (TinyMCE), then the switch button
       
  1633  * will not be displayed.
       
  1634  *
       
  1635  * @since 2.1.0
       
  1636  *
       
  1637  * @param string $content Textarea content.
       
  1638  * @param string $id HTML ID attribute value.
       
  1639  * @param string $prev_id HTML ID name for switching back and forth between visual editors.
       
  1640  * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
       
  1641  * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
       
  1642  */
       
  1643 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
       
  1644 	$rows = get_option('default_post_edit_rows');
       
  1645 	if (($rows < 3) || ($rows > 100))
       
  1646 		$rows = 12;
       
  1647 
       
  1648 	if ( !current_user_can( 'upload_files' ) )
       
  1649 		$media_buttons = false;
       
  1650 
       
  1651 	$richedit =  user_can_richedit();
       
  1652 	$class = '';
       
  1653 
       
  1654 	if ( $richedit || $media_buttons ) { ?>
       
  1655 	<div id="editor-toolbar">
       
  1656 <?php
       
  1657 	if ( $richedit ) {
       
  1658 		$wp_default_editor = wp_default_editor(); ?>
       
  1659 		<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
       
  1660 <?php	if ( 'html' == $wp_default_editor ) {
       
  1661 			add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
       
  1662 			<a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
       
  1663 			<a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
       
  1664 <?php	} else {
       
  1665 			$class = " class='theEditor'";
       
  1666 			add_filter('the_editor_content', 'wp_richedit_pre'); ?>
       
  1667 			<a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
       
  1668 			<a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
       
  1669 <?php	}
       
  1670 	}
       
  1671 
       
  1672 	if ( $media_buttons ) { ?>
       
  1673 		<div id="media-buttons" class="hide-if-no-js">
       
  1674 <?php	do_action( 'media_buttons' ); ?>
       
  1675 		</div>
       
  1676 <?php
       
  1677 	} ?>
       
  1678 	</div>
       
  1679 <?php
       
  1680 	}
       
  1681 ?>
       
  1682 	<div id="quicktags"><?php
       
  1683 	wp_print_scripts( 'quicktags' ); ?>
       
  1684 	<script type="text/javascript">edToolbar()</script>
       
  1685 	</div>
       
  1686 
       
  1687 <?php
       
  1688 	$the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
       
  1689 	$the_editor_content = apply_filters('the_editor_content', $content);
       
  1690 
       
  1691 	printf($the_editor, $the_editor_content);
       
  1692 
       
  1693 ?>
       
  1694 	<script type="text/javascript">
       
  1695 	edCanvas = document.getElementById('<?php echo $id; ?>');
       
  1696 	</script>
       
  1697 <?php
       
  1698 }
       
  1699 
       
  1700 /**
       
  1701  * Retrieve the contents of the search WordPress query variable.
       
  1702  *
       
  1703  * @since 2.3.0
       
  1704  *
       
  1705  * @return string
       
  1706  */
       
  1707 function get_search_query() {
       
  1708 	return apply_filters( 'get_search_query', stripslashes( get_query_var( 's' ) ) );
       
  1709 }
       
  1710 
       
  1711 /**
       
  1712  * Display the contents of the search query variable.
       
  1713  *
       
  1714  * The search query string is passed through {@link esc_attr()}
       
  1715  * to ensure that it is safe for placing in an html attribute.
       
  1716  *
       
  1717  * @uses attr
       
  1718  * @since 2.1.0
       
  1719  */
       
  1720 function the_search_query() {
       
  1721 	echo esc_attr( apply_filters( 'the_search_query', get_search_query() ) );
       
  1722 }
       
  1723 
       
  1724 /**
       
  1725  * Display the language attributes for the html tag.
       
  1726  *
       
  1727  * Builds up a set of html attributes containing the text direction and language
       
  1728  * information for the page.
       
  1729  *
       
  1730  * @since 2.1.0
       
  1731  *
       
  1732  * @param string $doctype The type of html document (xhtml|html).
       
  1733  */
       
  1734 function language_attributes($doctype = 'html') {
       
  1735 	$attributes = array();
       
  1736 	$output = '';
       
  1737 
       
  1738 	if ( $dir = get_bloginfo('text_direction') )
       
  1739 		$attributes[] = "dir=\"$dir\"";
       
  1740 
       
  1741 	if ( $lang = get_bloginfo('language') ) {
       
  1742 		if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
       
  1743 			$attributes[] = "lang=\"$lang\"";
       
  1744 
       
  1745 		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
       
  1746 			$attributes[] = "xml:lang=\"$lang\"";
       
  1747 	}
       
  1748 
       
  1749 	$output = implode(' ', $attributes);
       
  1750 	$output = apply_filters('language_attributes', $output);
       
  1751 	echo $output;
       
  1752 }
       
  1753 
       
  1754 /**
       
  1755  * Retrieve paginated link for archive post pages.
       
  1756  *
       
  1757  * Technically, the function can be used to create paginated link list for any
       
  1758  * area. The 'base' argument is used to reference the url, which will be used to
       
  1759  * create the paginated links. The 'format' argument is then used for replacing
       
  1760  * the page number. It is however, most likely and by default, to be used on the
       
  1761  * archive post pages.
       
  1762  *
       
  1763  * The 'type' argument controls format of the returned value. The default is
       
  1764  * 'plain', which is just a string with the links separated by a newline
       
  1765  * character. The other possible values are either 'array' or 'list'. The
       
  1766  * 'array' value will return an array of the paginated link list to offer full
       
  1767  * control of display. The 'list' value will place all of the paginated links in
       
  1768  * an unordered HTML list.
       
  1769  *
       
  1770  * The 'total' argument is the total amount of pages and is an integer. The
       
  1771  * 'current' argument is the current page number and is also an integer.
       
  1772  *
       
  1773  * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
       
  1774  * and the '%_%' is required. The '%_%' will be replaced by the contents of in
       
  1775  * the 'format' argument. An example for the 'format' argument is "?page=%#%"
       
  1776  * and the '%#%' is also required. The '%#%' will be replaced with the page
       
  1777  * number.
       
  1778  *
       
  1779  * You can include the previous and next links in the list by setting the
       
  1780  * 'prev_next' argument to true, which it is by default. You can set the
       
  1781  * previous text, by using the 'prev_text' argument. You can set the next text
       
  1782  * by setting the 'next_text' argument.
       
  1783  *
       
  1784  * If the 'show_all' argument is set to true, then it will show all of the pages
       
  1785  * instead of a short list of the pages near the current page. By default, the
       
  1786  * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
       
  1787  * arguments. The 'end_size' argument is how many numbers on either the start
       
  1788  * and the end list edges, by default is 1. The 'mid_size' argument is how many
       
  1789  * numbers to either side of current page, but not including current page.
       
  1790  *
       
  1791  * It is possible to add query vars to the link by using the 'add_args' argument
       
  1792  * and see {@link add_query_arg()} for more information.
       
  1793  *
       
  1794  * @since 2.1.0
       
  1795  *
       
  1796  * @param string|array $args Optional. Override defaults.
       
  1797  * @return array|string String of page links or array of page links.
       
  1798  */
       
  1799 function paginate_links( $args = '' ) {
       
  1800 	$defaults = array(
       
  1801 		'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
       
  1802 		'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
       
  1803 		'total' => 1,
       
  1804 		'current' => 0,
       
  1805 		'show_all' => false,
       
  1806 		'prev_next' => true,
       
  1807 		'prev_text' => __('&laquo; Previous'),
       
  1808 		'next_text' => __('Next &raquo;'),
       
  1809 		'end_size' => 1,
       
  1810 		'mid_size' => 2,
       
  1811 		'type' => 'plain',
       
  1812 		'add_args' => false, // array of query args to add
       
  1813 		'add_fragment' => ''
       
  1814 	);
       
  1815 
       
  1816 	$args = wp_parse_args( $args, $defaults );
       
  1817 	extract($args, EXTR_SKIP);
       
  1818 
       
  1819 	// Who knows what else people pass in $args
       
  1820 	$total = (int) $total;
       
  1821 	if ( $total < 2 )
       
  1822 		return;
       
  1823 	$current  = (int) $current;
       
  1824 	$end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
       
  1825 	$mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
       
  1826 	$add_args = is_array($add_args) ? $add_args : false;
       
  1827 	$r = '';
       
  1828 	$page_links = array();
       
  1829 	$n = 0;
       
  1830 	$dots = false;
       
  1831 
       
  1832 	if ( $prev_next && $current && 1 < $current ) :
       
  1833 		$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
       
  1834 		$link = str_replace('%#%', $current - 1, $link);
       
  1835 		if ( $add_args )
       
  1836 			$link = add_query_arg( $add_args, $link );
       
  1837 		$link .= $add_fragment;
       
  1838 		$page_links[] = "<a class='prev page-numbers' href='" . esc_url($link) . "'>$prev_text</a>";
       
  1839 	endif;
       
  1840 	for ( $n = 1; $n <= $total; $n++ ) :
       
  1841 		$n_display = number_format_i18n($n);
       
  1842 		if ( $n == $current ) :
       
  1843 			$page_links[] = "<span class='page-numbers current'>$n_display</span>";
       
  1844 			$dots = true;
       
  1845 		else :
       
  1846 			if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
       
  1847 				$link = str_replace('%_%', 1 == $n ? '' : $format, $base);
       
  1848 				$link = str_replace('%#%', $n, $link);
       
  1849 				if ( $add_args )
       
  1850 					$link = add_query_arg( $add_args, $link );
       
  1851 				$link .= $add_fragment;
       
  1852 				$page_links[] = "<a class='page-numbers' href='" . esc_url($link) . "'>$n_display</a>";
       
  1853 				$dots = true;
       
  1854 			elseif ( $dots && !$show_all ) :
       
  1855 				$page_links[] = "<span class='page-numbers dots'>...</span>";
       
  1856 				$dots = false;
       
  1857 			endif;
       
  1858 		endif;
       
  1859 	endfor;
       
  1860 	if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
       
  1861 		$link = str_replace('%_%', $format, $base);
       
  1862 		$link = str_replace('%#%', $current + 1, $link);
       
  1863 		if ( $add_args )
       
  1864 			$link = add_query_arg( $add_args, $link );
       
  1865 		$link .= $add_fragment;
       
  1866 		$page_links[] = "<a class='next page-numbers' href='" . esc_url($link) . "'>$next_text</a>";
       
  1867 	endif;
       
  1868 	switch ( $type ) :
       
  1869 		case 'array' :
       
  1870 			return $page_links;
       
  1871 			break;
       
  1872 		case 'list' :
       
  1873 			$r .= "<ul class='page-numbers'>\n\t<li>";
       
  1874 			$r .= join("</li>\n\t<li>", $page_links);
       
  1875 			$r .= "</li>\n</ul>\n";
       
  1876 			break;
       
  1877 		default :
       
  1878 			$r = join("\n", $page_links);
       
  1879 			break;
       
  1880 	endswitch;
       
  1881 	return $r;
       
  1882 }
       
  1883 
       
  1884 /**
       
  1885  * Registers an admin colour scheme css file.
       
  1886  *
       
  1887  * Allows a plugin to register a new admin colour scheme. For example:
       
  1888  * <code>
       
  1889  * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
       
  1890  * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
       
  1891  * </code>
       
  1892  *
       
  1893  * @since 2.5.0
       
  1894  *
       
  1895  * @param string $key The unique key for this theme.
       
  1896  * @param string $name The name of the theme.
       
  1897  * @param string $url The url of the css file containing the colour scheme.
       
  1898  * @param array @colors An array of CSS color definitions which are used to give the user a feel for the theme.
       
  1899  */
       
  1900 function wp_admin_css_color($key, $name, $url, $colors = array()) {
       
  1901 	global $_wp_admin_css_colors;
       
  1902 
       
  1903 	if ( !isset($_wp_admin_css_colors) )
       
  1904 		$_wp_admin_css_colors = array();
       
  1905 
       
  1906 	$_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
       
  1907 }
       
  1908 
       
  1909 /**
       
  1910  * Display the URL of a WordPress admin CSS file.
       
  1911  *
       
  1912  * @see WP_Styles::_css_href and its style_loader_src filter.
       
  1913  *
       
  1914  * @since 2.3.0
       
  1915  *
       
  1916  * @param string $file file relative to wp-admin/ without its ".css" extension.
       
  1917  */
       
  1918 function wp_admin_css_uri( $file = 'wp-admin' ) {
       
  1919 	if ( defined('WP_INSTALLING') ) {
       
  1920 		$_file = "./$file.css";
       
  1921 	} else {
       
  1922 		$_file = admin_url("$file.css");
       
  1923 	}
       
  1924 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
       
  1925 
       
  1926 	return apply_filters( 'wp_admin_css_uri', $_file, $file );
       
  1927 }
       
  1928 
       
  1929 /**
       
  1930  * Enqueues or directly prints a stylesheet link to the specified CSS file.
       
  1931  *
       
  1932  * "Intelligently" decides to enqueue or to print the CSS file. If the
       
  1933  * 'wp_print_styles' action has *not* yet been called, the CSS file will be
       
  1934  * enqueued. If the wp_print_styles action *has* been called, the CSS link will
       
  1935  * be printed. Printing may be forced by passing TRUE as the $force_echo
       
  1936  * (second) parameter.
       
  1937  *
       
  1938  * For backward compatibility with WordPress 2.3 calling method: If the $file
       
  1939  * (first) parameter does not correspond to a registered CSS file, we assume
       
  1940  * $file is a file relative to wp-admin/ without its ".css" extension. A
       
  1941  * stylesheet link to that generated URL is printed.
       
  1942  *
       
  1943  * @package WordPress
       
  1944  * @since 2.3.0
       
  1945  * @uses $wp_styles WordPress Styles Object
       
  1946  *
       
  1947  * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
       
  1948  * @param bool $force_echo Optional.  Force the stylesheet link to be printed rather than enqueued.
       
  1949  */
       
  1950 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
       
  1951 	global $wp_styles;
       
  1952 	if ( !is_a($wp_styles, 'WP_Styles') )
       
  1953 		$wp_styles = new WP_Styles();
       
  1954 
       
  1955 	// For backward compatibility
       
  1956 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
       
  1957 
       
  1958 	if ( $wp_styles->query( $handle ) ) {
       
  1959 		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue.  Print this one immediately
       
  1960 			wp_print_styles( $handle );
       
  1961 		else // Add to style queue
       
  1962 			wp_enqueue_style( $handle );
       
  1963 		return;
       
  1964 	}
       
  1965 
       
  1966 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
       
  1967 	if ( 'rtl' == get_bloginfo( 'text_direction' ) )
       
  1968 		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
       
  1969 }
       
  1970 
       
  1971 /**
       
  1972  * Enqueues the default ThickBox js and css.
       
  1973  *
       
  1974  * If any of the settings need to be changed, this can be done with another js
       
  1975  * file similar to media-upload.js and theme-preview.js. That file should
       
  1976  * require array('thickbox') to ensure it is loaded after.
       
  1977  *
       
  1978  * @since 2.5.0
       
  1979  */
       
  1980 function add_thickbox() {
       
  1981 	wp_enqueue_script( 'thickbox' );
       
  1982 	wp_enqueue_style( 'thickbox' );
       
  1983 }
       
  1984 
       
  1985 /**
       
  1986  * Display the XHTML generator that is generated on the wp_head hook.
       
  1987  *
       
  1988  * @since 2.5.0
       
  1989  */
       
  1990 function wp_generator() {
       
  1991 	the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
       
  1992 }
       
  1993 
       
  1994 /**
       
  1995  * Display the generator XML or Comment for RSS, ATOM, etc.
       
  1996  *
       
  1997  * Returns the correct generator type for the requested output format. Allows
       
  1998  * for a plugin to filter generators overall the the_generator filter.
       
  1999  *
       
  2000  * @since 2.5.0
       
  2001  * @uses apply_filters() Calls 'the_generator' hook.
       
  2002  *
       
  2003  * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
       
  2004  */
       
  2005 function the_generator( $type ) {
       
  2006 	echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
       
  2007 }
       
  2008 
       
  2009 /**
       
  2010  * Creates the generator XML or Comment for RSS, ATOM, etc.
       
  2011  *
       
  2012  * Returns the correct generator type for the requested output format. Allows
       
  2013  * for a plugin to filter generators on an individual basis using the
       
  2014  * 'get_the_generator_{$type}' filter.
       
  2015  *
       
  2016  * @since 2.5.0
       
  2017  * @uses apply_filters() Calls 'get_the_generator_$type' hook.
       
  2018  *
       
  2019  * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
       
  2020  * @return string The HTML content for the generator.
       
  2021  */
       
  2022 function get_the_generator( $type ) {
       
  2023 	switch ($type) {
       
  2024 		case 'html':
       
  2025 			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
       
  2026 			break;
       
  2027 		case 'xhtml':
       
  2028 			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
       
  2029 			break;
       
  2030 		case 'atom':
       
  2031 			$gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
       
  2032 			break;
       
  2033 		case 'rss2':
       
  2034 			$gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
       
  2035 			break;
       
  2036 		case 'rdf':
       
  2037 			$gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
       
  2038 			break;
       
  2039 		case 'comment':
       
  2040 			$gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
       
  2041 			break;
       
  2042 		case 'export':
       
  2043 			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '"-->';
       
  2044 			break;
       
  2045 	}
       
  2046 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
       
  2047 }
       
  2048 
       
  2049 ?>