[ Index ]

WordPress Cross Reference

title

Body

[close]

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

   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.
  14   *
  15   * For the parameter, if the file is called "header-special.php" then specify
  16   * "special".
  17   *
  18   * @uses locate_template()
  19   * @since 1.5.0
  20   * @uses do_action() Calls 'get_header' action.
  21   *
  22   * @param string $name The name of the specialised header.
  23   */
  24  function get_header( $name = null ) {
  25      do_action( 'get_header', $name );
  26  
  27      $templates = array();
  28      $name = (string) $name;
  29      if ( '' !== $name )
  30          $templates[] = "header-{$name}.php";
  31  
  32      $templates[] = 'header.php';
  33  
  34      // Backward compat code will be removed in a future release
  35      if ('' == locate_template($templates, true))
  36          load_template( ABSPATH . WPINC . '/theme-compat/header.php');
  37  }
  38  
  39  /**
  40   * Load footer template.
  41   *
  42   * Includes the footer template for a theme or if a name is specified then a
  43   * specialised footer 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      $name = (string) $name;
  59      if ( '' !== $name )
  60          $templates[] = "footer-{$name}.php";
  61  
  62      $templates[] = 'footer.php';
  63  
  64      // Backward compat code will be removed in a future release
  65      if ('' == locate_template($templates, true))
  66          load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
  67  }
  68  
  69  /**
  70   * Load sidebar template.
  71   *
  72   * Includes the sidebar template for a theme or if a name is specified then a
  73   * specialised sidebar will be included.
  74   *
  75   * For the parameter, if the file is called "sidebar-special.php" then specify
  76   * "special".
  77   *
  78   * @uses locate_template()
  79   * @since 1.5.0
  80   * @uses do_action() Calls 'get_sidebar' action.
  81   *
  82   * @param string $name The name of the specialised sidebar.
  83   */
  84  function get_sidebar( $name = null ) {
  85      do_action( 'get_sidebar', $name );
  86  
  87      $templates = array();
  88      $name = (string) $name;
  89      if ( '' !== $name )
  90          $templates[] = "sidebar-{$name}.php";
  91  
  92      $templates[] = 'sidebar.php';
  93  
  94      // Backward compat code will be removed in a future release
  95      if ('' == locate_template($templates, true))
  96          load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
  97  }
  98  
  99  /**
 100   * Load a template part into a template
 101   *
 102   * Makes it easy for a theme to reuse sections of code in a easy to overload way
 103   * for child themes.
 104   *
 105   * Includes the named template part for a theme or if a name is specified then a
 106   * specialised part will be included. If the theme contains no {slug}.php file
 107   * then no template will be included.
 108   *
 109   * The template is included using require, not require_once, so you may include the
 110   * same template part multiple times.
 111   *
 112   * For the $name parameter, if the file is called "{slug}-special.php" then specify
 113   * "special".
 114   *
 115   * @uses locate_template()
 116   * @since 3.0.0
 117   * @uses do_action() Calls 'get_template_part_{$slug}' action.
 118   *
 119   * @param string $slug The slug name for the generic template.
 120   * @param string $name The name of the specialised template.
 121   */
 122  function get_template_part( $slug, $name = null ) {
 123      do_action( "get_template_part_{$slug}", $slug, $name );
 124  
 125      $templates = array();
 126      $name = (string) $name;
 127      if ( '' !== $name )
 128          $templates[] = "{$slug}-{$name}.php";
 129  
 130      $templates[] = "{$slug}.php";
 131  
 132      locate_template($templates, true, false);
 133  }
 134  
 135  /**
 136   * Display search form.
 137   *
 138   * Will first attempt to locate the searchform.php file in either the child or
 139   * the parent, then load it. If it doesn't exist, then the default search form
 140   * will be displayed. The default search form is HTML, which will be displayed.
 141   * There is a filter applied to the search form HTML in order to edit or replace
 142   * it. The filter is 'get_search_form'.
 143   *
 144   * This function is primarily used by themes which want to hardcode the search
 145   * form into the sidebar and also by the search widget in WordPress.
 146   *
 147   * There is also an action that is called whenever the function is run called,
 148   * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
 149   * search relies on or various formatting that applies to the beginning of the
 150   * search. To give a few examples of what it can be used for.
 151   *
 152   * @since 2.7.0
 153   * @uses apply_filters() Calls 'search_form_format' filter to determine which type to use for the search field.
 154   *  If set to 'html5', it changes to search input type and adds placeholder text.
 155   *
 156   * @param boolean $echo Default to echo and not return the form.
 157   * @return string|null String when retrieving, null when displaying or if searchform.php exists.
 158   */
 159  function get_search_form( $echo = true ) {
 160      do_action( 'pre_get_search_form' );
 161  
 162      $format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
 163      $format = apply_filters( 'search_form_format', $format );
 164  
 165      $search_form_template = locate_template( 'searchform.php' );
 166      if ( '' != $search_form_template ) {
 167          ob_start();
 168          require( $search_form_template );
 169          $form = ob_get_clean();
 170      } else {
 171          if ( 'html5' == $format ) {
 172              $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
 173                  <label>
 174                      <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
 175                      <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x( 'Search for:', 'label' ) . '" />
 176                  </label>
 177                  <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
 178              </form>';
 179          } else {
 180              $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
 181                  <div>
 182                      <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
 183                      <input type="text" value="' . get_search_query() . '" name="s" id="s" />
 184                      <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
 185                  </div>
 186              </form>';
 187          }
 188      }
 189  
 190      $result = apply_filters( 'get_search_form', $form );
 191      if ( null === $result )
 192          $result = $form;
 193  
 194      if ( $echo )
 195          echo $result;
 196      else
 197          return $result;
 198  }
 199  
 200  /**
 201   * Display the Log In/Out link.
 202   *
 203   * Displays a link, which allows users to navigate to the Log In page to log in
 204   * or log out depending on whether they are currently logged in.
 205   *
 206   * @since 1.5.0
 207   * @uses apply_filters() Calls 'loginout' hook on HTML link content.
 208   *
 209   * @param string $redirect Optional path to redirect to on login/logout.
 210   * @param boolean $echo Default to echo and not return the link.
 211   * @return string|null String when retrieving, null when displaying.
 212   */
 213  function wp_loginout($redirect = '', $echo = true) {
 214      if ( ! is_user_logged_in() )
 215          $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
 216      else
 217          $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
 218  
 219      if ( $echo )
 220          echo apply_filters('loginout', $link);
 221      else
 222          return apply_filters('loginout', $link);
 223  }
 224  
 225  /**
 226   * Returns the Log Out URL.
 227   *
 228   * Returns the URL that allows the user to log out of the site.
 229   *
 230   * @since 2.7.0
 231   * @uses wp_nonce_url() To protect against CSRF.
 232   * @uses site_url() To generate the log out URL.
 233   * @uses apply_filters() calls 'logout_url' hook on final logout URL.
 234   *
 235   * @param string $redirect Path to redirect to on logout.
 236   * @return string A log out URL.
 237   */
 238  function wp_logout_url($redirect = '') {
 239      $args = array( 'action' => 'logout' );
 240      if ( !empty($redirect) ) {
 241          $args['redirect_to'] = urlencode( $redirect );
 242      }
 243  
 244      $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
 245      $logout_url = wp_nonce_url( $logout_url, 'log-out' );
 246  
 247      return apply_filters('logout_url', $logout_url, $redirect);
 248  }
 249  
 250  /**
 251   * Returns the Log In URL.
 252   *
 253   * Returns the URL that allows the user to log in to the site.
 254   *
 255   * @since 2.7.0
 256   * @uses site_url() To generate the log in URL.
 257   * @uses apply_filters() calls 'login_url' hook on final login URL.
 258   *
 259   * @param string $redirect Path to redirect to on login.
 260   * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
 261   * @return string A log in URL.
 262   */
 263  function wp_login_url($redirect = '', $force_reauth = false) {
 264      $login_url = site_url('wp-login.php', 'login');
 265  
 266      if ( !empty($redirect) )
 267          $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
 268  
 269      if ( $force_reauth )
 270          $login_url = add_query_arg('reauth', '1', $login_url);
 271  
 272      return apply_filters('login_url', $login_url, $redirect);
 273  }
 274  
 275  /**
 276   * Returns the user registration URL.
 277   *
 278   * Returns the URL that allows the user to register on the site.
 279   *
 280   * @since 3.6.0
 281   * @uses site_url() To generate the registration URL.
 282   * @uses apply_filters() calls 'register_url' hook on final URL.
 283   *
 284   * @return string
 285   */
 286  function wp_registration_url() {
 287      return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
 288  }
 289  
 290  /**
 291   * Provides a simple login form for use anywhere within WordPress. By default, it echoes
 292   * the HTML immediately. Pass array('echo'=>false) to return the string instead.
 293   *
 294   * @since 3.0.0
 295   * @param array $args Configuration options to modify the form output.
 296   * @return string|null String when retrieving, null when displaying.
 297   */
 298  function wp_login_form( $args = array() ) {
 299      $defaults = array(
 300          'echo' => true,
 301          'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
 302          'form_id' => 'loginform',
 303          'label_username' => __( 'Username' ),
 304          'label_password' => __( 'Password' ),
 305          'label_remember' => __( 'Remember Me' ),
 306          'label_log_in' => __( 'Log In' ),
 307          'id_username' => 'user_login',
 308          'id_password' => 'user_pass',
 309          'id_remember' => 'rememberme',
 310          'id_submit' => 'wp-submit',
 311          'remember' => true,
 312          'value_username' => '',
 313          'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
 314      );
 315      $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
 316  
 317      $form = '
 318          <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
 319              ' . apply_filters( 'login_form_top', '', $args ) . '
 320              <p class="login-username">
 321                  <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
 322                  <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
 323              </p>
 324              <p class="login-password">
 325                  <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
 326                  <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
 327              </p>
 328              ' . apply_filters( 'login_form_middle', '', $args ) . '
 329              ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
 330              <p class="login-submit">
 331                  <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
 332                  <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
 333              </p>
 334              ' . apply_filters( 'login_form_bottom', '', $args ) . '
 335          </form>';
 336  
 337      if ( $args['echo'] )
 338          echo $form;
 339      else
 340          return $form;
 341  }
 342  
 343  /**
 344   * Returns the Lost Password URL.
 345   *
 346   * Returns the URL that allows the user to retrieve the lost password
 347   *
 348   * @since 2.8.0
 349   * @uses site_url() To generate the lost password URL
 350   * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
 351   *
 352   * @param string $redirect Path to redirect to on login.
 353   * @return string Lost password URL.
 354   */
 355  function wp_lostpassword_url( $redirect = '' ) {
 356      $args = array( 'action' => 'lostpassword' );
 357      if ( !empty($redirect) ) {
 358          $args['redirect_to'] = $redirect;
 359      }
 360  
 361      $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
 362      return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
 363  }
 364  
 365  /**
 366   * Display the Registration or Admin link.
 367   *
 368   * Display a link which allows the user to navigate to the registration page if
 369   * not logged in and registration is enabled or to the dashboard if logged in.
 370   *
 371   * @since 1.5.0
 372   * @uses apply_filters() Calls 'register' hook on register / admin link content.
 373   *
 374   * @param string $before Text to output before the link (defaults to <li>).
 375   * @param string $after Text to output after the link (defaults to </li>).
 376   * @param boolean $echo Default to echo and not return the link.
 377   * @return string|null String when retrieving, null when displaying.
 378   */
 379  function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
 380  
 381      if ( ! is_user_logged_in() ) {
 382          if ( get_option('users_can_register') )
 383              $link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
 384          else
 385              $link = '';
 386      } else {
 387          $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
 388      }
 389  
 390      if ( $echo )
 391          echo apply_filters('register', $link);
 392      else
 393          return apply_filters('register', $link);
 394  }
 395  
 396  /**
 397   * Theme container function for the 'wp_meta' action.
 398   *
 399   * The 'wp_meta' action can have several purposes, depending on how you use it,
 400   * but one purpose might have been to allow for theme switching.
 401   *
 402   * @since 1.5.0
 403   * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
 404   * @uses do_action() Calls 'wp_meta' hook.
 405   */
 406  function wp_meta() {
 407      do_action('wp_meta');
 408  }
 409  
 410  /**
 411   * Display information about the blog.
 412   *
 413   * @see get_bloginfo() For possible values for the parameter.
 414   * @since 0.71
 415   *
 416   * @param string $show What to display.
 417   */
 418  function bloginfo( $show='' ) {
 419      echo get_bloginfo( $show, 'display' );
 420  }
 421  
 422  /**
 423   * Retrieve information about the blog.
 424   *
 425   * Some show parameter values are deprecated and will be removed in future
 426   * versions. These options will trigger the _deprecated_argument() function.
 427   * The deprecated blog info options are listed in the function contents.
 428   *
 429   * The possible values for the 'show' parameter are listed below.
 430   * <ol>
 431   * <li><strong>url</strong> - Blog URI to homepage.</li>
 432   * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
 433   * <li><strong>description</strong> - Secondary title</li>
 434   * </ol>
 435   *
 436   * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
 437   * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
 438   * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
 439   * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
 440   *
 441   * @since 0.71
 442   *
 443   * @param string $show Blog info to retrieve.
 444   * @param string $filter How to filter what is retrieved.
 445   * @return string Mostly string values, might be empty.
 446   */
 447  function get_bloginfo( $show = '', $filter = 'raw' ) {
 448  
 449      switch( $show ) {
 450          case 'home' : // DEPRECATED
 451          case 'siteurl' : // DEPRECATED
 452              _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url'  ) );
 453          case 'url' :
 454              $output = home_url();
 455              break;
 456          case 'wpurl' :
 457              $output = site_url();
 458              break;
 459          case 'description':
 460              $output = get_option('blogdescription');
 461              break;
 462          case 'rdf_url':
 463              $output = get_feed_link('rdf');
 464              break;
 465          case 'rss_url':
 466              $output = get_feed_link('rss');
 467              break;
 468          case 'rss2_url':
 469              $output = get_feed_link('rss2');
 470              break;
 471          case 'atom_url':
 472              $output = get_feed_link('atom');
 473              break;
 474          case 'comments_atom_url':
 475              $output = get_feed_link('comments_atom');
 476              break;
 477          case 'comments_rss2_url':
 478              $output = get_feed_link('comments_rss2');
 479              break;
 480          case 'pingback_url':
 481              $output = site_url( 'xmlrpc.php' );
 482              break;
 483          case 'stylesheet_url':
 484              $output = get_stylesheet_uri();
 485              break;
 486          case 'stylesheet_directory':
 487              $output = get_stylesheet_directory_uri();
 488              break;
 489          case 'template_directory':
 490          case 'template_url':
 491              $output = get_template_directory_uri();
 492              break;
 493          case 'admin_email':
 494              $output = get_option('admin_email');
 495              break;
 496          case 'charset':
 497              $output = get_option('blog_charset');
 498              if ('' == $output) $output = 'UTF-8';
 499              break;
 500          case 'html_type' :
 501              $output = get_option('html_type');
 502              break;
 503          case 'version':
 504              global $wp_version;
 505              $output = $wp_version;
 506              break;
 507          case 'language':
 508              $output = get_locale();
 509              $output = str_replace('_', '-', $output);
 510              break;
 511          case 'text_direction':
 512              //_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()'  ) );
 513              if ( function_exists( 'is_rtl' ) ) {
 514                  $output = is_rtl() ? 'rtl' : 'ltr';
 515              } else {
 516                  $output = 'ltr';
 517              }
 518              break;
 519          case 'name':
 520          default:
 521              $output = get_option('blogname');
 522              break;
 523      }
 524  
 525      $url = true;
 526      if (strpos($show, 'url') === false &&
 527          strpos($show, 'directory') === false &&
 528          strpos($show, 'home') === false)
 529          $url = false;
 530  
 531      if ( 'display' == $filter ) {
 532          if ( $url )
 533              $output = apply_filters('bloginfo_url', $output, $show);
 534          else
 535              $output = apply_filters('bloginfo', $output, $show);
 536      }
 537  
 538      return $output;
 539  }
 540  
 541  /**
 542   * Display or retrieve page title for all areas of blog.
 543   *
 544   * By default, the page title will display the separator before the page title,
 545   * so that the blog title will be before the page title. This is not good for
 546   * title display, since the blog title shows up on most tabs and not what is
 547   * important, which is the page that the user is looking at.
 548   *
 549   * There are also SEO benefits to having the blog title after or to the 'right'
 550   * or the page title. However, it is mostly common sense to have the blog title
 551   * to the right with most browsers supporting tabs. You can achieve this by
 552   * using the seplocation parameter and setting the value to 'right'. This change
 553   * was introduced around 2.5.0, in case backwards compatibility of themes is
 554   * important.
 555   *
 556   * @since 1.0.0
 557   *
 558   * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
 559   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 560   * @param string $seplocation Optional. Direction to display title, 'right'.
 561   * @return string|null String on retrieve, null when displaying.
 562   */
 563  function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
 564      global $wpdb, $wp_locale;
 565  
 566      $m = get_query_var('m');
 567      $year = get_query_var('year');
 568      $monthnum = get_query_var('monthnum');
 569      $day = get_query_var('day');
 570      $search = get_query_var('s');
 571      $title = '';
 572  
 573      $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
 574  
 575      // If there is a post
 576      if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
 577          $title = single_post_title( '', false );
 578      }
 579  
 580      // If there's a post type archive
 581      if ( is_post_type_archive() ) {
 582          $post_type = get_query_var( 'post_type' );
 583          if ( is_array( $post_type ) )
 584              $post_type = reset( $post_type );
 585          $post_type_object = get_post_type_object( $post_type );
 586          if ( ! $post_type_object->has_archive )
 587              $title = post_type_archive_title( '', false );
 588      }
 589  
 590      // If there's a category or tag
 591      if ( is_category() || is_tag() ) {
 592          $title = single_term_title( '', false );
 593      }
 594  
 595      // If there's a taxonomy
 596      if ( is_tax() ) {
 597          $term = get_queried_object();
 598          if ( $term ) {
 599              $tax = get_taxonomy( $term->taxonomy );
 600              $title = single_term_title( $tax->labels->name . $t_sep, false );
 601          }
 602      }
 603  
 604      // If there's an author
 605      if ( is_author() ) {
 606          $author = get_queried_object();
 607          if ( $author )
 608              $title = $author->display_name;
 609      }
 610  
 611      // Post type archives with has_archive should override terms.
 612      if ( is_post_type_archive() && $post_type_object->has_archive )
 613          $title = post_type_archive_title( '', false );
 614  
 615      // If there's a month
 616      if ( is_archive() && !empty($m) ) {
 617          $my_year = substr($m, 0, 4);
 618          $my_month = $wp_locale->get_month(substr($m, 4, 2));
 619          $my_day = intval(substr($m, 6, 2));
 620          $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
 621      }
 622  
 623      // If there's a year
 624      if ( is_archive() && !empty($year) ) {
 625          $title = $year;
 626          if ( !empty($monthnum) )
 627              $title .= $t_sep . $wp_locale->get_month($monthnum);
 628          if ( !empty($day) )
 629              $title .= $t_sep . zeroise($day, 2);
 630      }
 631  
 632      // If it's a search
 633      if ( is_search() ) {
 634          /* translators: 1: separator, 2: search phrase */
 635          $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
 636      }
 637  
 638      // If it's a 404 page
 639      if ( is_404() ) {
 640          $title = __('Page not found');
 641      }
 642  
 643      $prefix = '';
 644      if ( !empty($title) )
 645          $prefix = " $sep ";
 646  
 647       // Determines position of the separator and direction of the breadcrumb
 648      if ( 'right' == $seplocation ) { // sep on right, so reverse the order
 649          $title_array = explode( $t_sep, $title );
 650          $title_array = array_reverse( $title_array );
 651          $title = implode( " $sep ", $title_array ) . $prefix;
 652      } else {
 653          $title_array = explode( $t_sep, $title );
 654          $title = $prefix . implode( " $sep ", $title_array );
 655      }
 656  
 657      $title = apply_filters('wp_title', $title, $sep, $seplocation);
 658  
 659      // Send it out
 660      if ( $display )
 661          echo $title;
 662      else
 663          return $title;
 664  
 665  }
 666  
 667  /**
 668   * Display or retrieve page title for post.
 669   *
 670   * This is optimized for single.php template file for displaying the post title.
 671   *
 672   * It does not support placing the separator after the title, but by leaving the
 673   * prefix parameter empty, you can set the title separator manually. The prefix
 674   * does not automatically place a space between the prefix, so if there should
 675   * be a space, the parameter value will need to have it at the end.
 676   *
 677   * @since 0.71
 678   *
 679   * @param string $prefix Optional. What to display before the title.
 680   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 681   * @return string|null Title when retrieving, null when displaying or failure.
 682   */
 683  function single_post_title($prefix = '', $display = true) {
 684      $_post = get_queried_object();
 685  
 686      if ( !isset($_post->post_title) )
 687          return;
 688  
 689      $title = apply_filters('single_post_title', $_post->post_title, $_post);
 690      if ( $display )
 691          echo $prefix . $title;
 692      else
 693          return $prefix . $title;
 694  }
 695  
 696  /**
 697   * Display or retrieve title for a post type archive.
 698   *
 699   * This is optimized for archive.php and archive-{$post_type}.php template files
 700   * for displaying the title of the post type.
 701   *
 702   * @since 3.1.0
 703   *
 704   * @param string $prefix Optional. What to display before the title.
 705   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 706   * @return string|null Title when retrieving, null when displaying or failure.
 707   */
 708  function post_type_archive_title( $prefix = '', $display = true ) {
 709      if ( ! is_post_type_archive() )
 710          return;
 711  
 712      $post_type = get_query_var( 'post_type' );
 713      if ( is_array( $post_type ) )
 714          $post_type = reset( $post_type );
 715  
 716      $post_type_obj = get_post_type_object( $post_type );
 717      /**
 718       * Filter the post type archive title.
 719       *
 720       * @since 3.1.0
 721       *
 722       * @param string $post_type_name Post type 'name' label.
 723       * @param string $post_type      Post type.
 724       */
 725      $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
 726  
 727      if ( $display )
 728          echo $prefix . $title;
 729      else
 730          return $prefix . $title;
 731  }
 732  
 733  /**
 734   * Display or retrieve page title for category archive.
 735   *
 736   * This is useful for category template file or files, because it is optimized
 737   * for category page title and with less overhead than {@link wp_title()}.
 738   *
 739   * It does not support placing the separator after the title, but by leaving the
 740   * prefix parameter empty, you can set the title separator manually. The prefix
 741   * does not automatically place a space between the prefix, so if there should
 742   * be a space, the parameter value will need to have it at the end.
 743   *
 744   * @since 0.71
 745   *
 746   * @param string $prefix Optional. What to display before the title.
 747   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 748   * @return string|null Title when retrieving, null when displaying or failure.
 749   */
 750  function single_cat_title( $prefix = '', $display = true ) {
 751      return single_term_title( $prefix, $display );
 752  }
 753  
 754  /**
 755   * Display or retrieve page title for tag post archive.
 756   *
 757   * Useful for tag template files for displaying the tag page title. It has less
 758   * overhead than {@link wp_title()}, because of its limited implementation.
 759   *
 760   * It does not support placing the separator after the title, but by leaving the
 761   * prefix parameter empty, you can set the title separator manually. The prefix
 762   * does not automatically place a space between the prefix, so if there should
 763   * be a space, the parameter value will need to have it at the end.
 764   *
 765   * @since 2.3.0
 766   *
 767   * @param string $prefix Optional. What to display before the title.
 768   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 769   * @return string|null Title when retrieving, null when displaying or failure.
 770   */
 771  function single_tag_title( $prefix = '', $display = true ) {
 772      return single_term_title( $prefix, $display );
 773  }
 774  
 775  /**
 776   * Display or retrieve page title for taxonomy term archive.
 777   *
 778   * Useful for taxonomy term template files for displaying the taxonomy term page title.
 779   * It has less overhead than {@link wp_title()}, because of its limited implementation.
 780   *
 781   * It does not support placing the separator after the title, but by leaving the
 782   * prefix parameter empty, you can set the title separator manually. The prefix
 783   * does not automatically place a space between the prefix, so if there should
 784   * be a space, the parameter value will need to have it at the end.
 785   *
 786   * @since 3.1.0
 787   *
 788   * @param string $prefix Optional. What to display before the title.
 789   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 790   * @return string|null Title when retrieving, null when displaying or failure.
 791   */
 792  function single_term_title( $prefix = '', $display = true ) {
 793      $term = get_queried_object();
 794  
 795      if ( !$term )
 796          return;
 797  
 798      if ( is_category() )
 799          $term_name = apply_filters( 'single_cat_title', $term->name );
 800      elseif ( is_tag() )
 801          $term_name = apply_filters( 'single_tag_title', $term->name );
 802      elseif ( is_tax() )
 803          $term_name = apply_filters( 'single_term_title', $term->name );
 804      else
 805          return;
 806  
 807      if ( empty( $term_name ) )
 808          return;
 809  
 810      if ( $display )
 811          echo $prefix . $term_name;
 812      else
 813          return $prefix . $term_name;
 814  }
 815  
 816  /**
 817   * Display or retrieve page title for post archive based on date.
 818   *
 819   * Useful for when the template only needs to display the month and year, if
 820   * either are available. Optimized for just this purpose, so if it is all that
 821   * is needed, should be better than {@link wp_title()}.
 822   *
 823   * It does not support placing the separator after the title, but by leaving the
 824   * prefix parameter empty, you can set the title separator manually. The prefix
 825   * does not automatically place a space between the prefix, so if there should
 826   * be a space, the parameter value will need to have it at the end.
 827   *
 828   * @since 0.71
 829   *
 830   * @param string $prefix Optional. What to display before the title.
 831   * @param bool $display Optional, default is true. Whether to display or retrieve title.
 832   * @return string|null Title when retrieving, null when displaying or failure.
 833   */
 834  function single_month_title($prefix = '', $display = true ) {
 835      global $wp_locale;
 836  
 837      $m = get_query_var('m');
 838      $year = get_query_var('year');
 839      $monthnum = get_query_var('monthnum');
 840  
 841      if ( !empty($monthnum) && !empty($year) ) {
 842          $my_year = $year;
 843          $my_month = $wp_locale->get_month($monthnum);
 844      } elseif ( !empty($m) ) {
 845          $my_year = substr($m, 0, 4);
 846          $my_month = $wp_locale->get_month(substr($m, 4, 2));
 847      }
 848  
 849      if ( empty($my_month) )
 850          return false;
 851  
 852      $result = $prefix . $my_month . $prefix . $my_year;
 853  
 854      if ( !$display )
 855          return $result;
 856      echo $result;
 857  }
 858  
 859  /**
 860   * Retrieve archive link content based on predefined or custom code.
 861   *
 862   * The format can be one of four styles. The 'link' for head element, 'option'
 863   * for use in the select element, 'html' for use in list (either ol or ul HTML
 864   * elements). Custom content is also supported using the before and after
 865   * parameters.
 866   *
 867   * The 'link' format uses the link HTML element with the <em>archives</em>
 868   * relationship. The before and after parameters are not used. The text
 869   * parameter is used to describe the link.
 870   *
 871   * The 'option' format uses the option HTML element for use in select element.
 872   * The value is the url parameter and the before and after parameters are used
 873   * between the text description.
 874   *
 875   * The 'html' format, which is the default, uses the li HTML element for use in
 876   * the list HTML elements. The before parameter is before the link and the after
 877   * parameter is after the closing link.
 878   *
 879   * The custom format uses the before parameter before the link ('a' HTML
 880   * element) and the after parameter after the closing link tag. If the above
 881   * three values for the format are not used, then custom format is assumed.
 882   *
 883   * @since 1.0.0
 884   *
 885   * @param string $url URL to archive.
 886   * @param string $text Archive text description.
 887   * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
 888   * @param string $before Optional.
 889   * @param string $after Optional.
 890   * @return string HTML link content for archive.
 891   */
 892  function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
 893      $text = wptexturize($text);
 894      $url = esc_url($url);
 895  
 896      if ('link' == $format)
 897          $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
 898      elseif ('option' == $format)
 899          $link_html = "\t<option value='$url'>$before $text $after</option>\n";
 900      elseif ('html' == $format)
 901          $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
 902      else // custom
 903          $link_html = "\t$before<a href='$url'>$text</a>$after\n";
 904  
 905      $link_html = apply_filters( 'get_archives_link', $link_html );
 906  
 907      return $link_html;
 908  }
 909  
 910  /**
 911   * Display archive links based on type and format.
 912   *
 913   * The 'type' argument offers a few choices and by default will display monthly
 914   * archive links. The other options for values are 'daily', 'weekly', 'monthly',
 915   * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
 916   * same archive link list, the difference between the two is that 'alpha'
 917   * will order by post title and 'postbypost' will order by post date.
 918   *
 919   * The date archives will logically display dates with links to the archive post
 920   * page. The 'postbypost' and 'alpha' values for 'type' argument will display
 921   * the post titles.
 922   *
 923   * The 'limit' argument will only display a limited amount of links, specified
 924   * by the 'limit' integer value. By default, there is no limit. The
 925   * 'show_post_count' argument will show how many posts are within the archive.
 926   * By default, the 'show_post_count' argument is set to false.
 927   *
 928   * For the 'format', 'before', and 'after' arguments, see {@link
 929   * get_archives_link()}. The values of these arguments have to do with that
 930   * function.
 931   *
 932   * @since 1.2.0
 933   *
 934   * @param string|array $args Optional. Override defaults.
 935   * @return string|null String when retrieving, null when displaying.
 936   */
 937  function wp_get_archives($args = '') {
 938      global $wpdb, $wp_locale;
 939  
 940      $defaults = array(
 941          'type' => 'monthly', 'limit' => '',
 942          'format' => 'html', 'before' => '',
 943          'after' => '', 'show_post_count' => false,
 944          'echo' => 1, 'order' => 'DESC',
 945      );
 946  
 947      $r = wp_parse_args( $args, $defaults );
 948      extract( $r, EXTR_SKIP );
 949  
 950      if ( '' == $type )
 951          $type = 'monthly';
 952  
 953      if ( '' != $limit ) {
 954          $limit = absint($limit);
 955          $limit = ' LIMIT '.$limit;
 956      }
 957  
 958      $order = strtoupper( $order );
 959      if ( $order !== 'ASC' )
 960          $order = 'DESC';
 961  
 962      // this is what will separate dates on weekly archive links
 963      $archive_week_separator = '&#8211;';
 964  
 965      // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
 966      $archive_date_format_over_ride = 0;
 967  
 968      // options for daily archive (only if you over-ride the general date format)
 969      $archive_day_date_format = 'Y/m/d';
 970  
 971      // options for weekly archive (only if you over-ride the general date format)
 972      $archive_week_start_date_format = 'Y/m/d';
 973      $archive_week_end_date_format    = 'Y/m/d';
 974  
 975      if ( !$archive_date_format_over_ride ) {
 976          $archive_day_date_format = get_option('date_format');
 977          $archive_week_start_date_format = get_option('date_format');
 978          $archive_week_end_date_format = get_option('date_format');
 979      }
 980  
 981      $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
 982      $join = apply_filters( 'getarchives_join', '', $r );
 983  
 984      $output = '';
 985  
 986      $last_changed = wp_cache_get( 'last_changed', 'posts' );
 987      if ( ! $last_changed ) {
 988          $last_changed = microtime();
 989          wp_cache_set( 'last_changed', $last_changed, 'posts' );
 990      }
 991  
 992      if ( 'monthly' == $type ) {
 993          $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 $order $limit";
 994          $key = md5( $query );
 995          $key = "wp_get_archives:$key:$last_changed";
 996          if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
 997              $results = $wpdb->get_results( $query );
 998              wp_cache_set( $key, $results, 'posts' );
 999          }
1000          if ( $results ) {
1001              $afterafter = $after;
1002              foreach ( (array) $results as $result ) {
1003                  $url = get_month_link( $result->year, $result->month );
1004                  /* translators: 1: month name, 2: 4-digit year */
1005                  $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
1006                  if ( $show_post_count )
1007                      $after = '&nbsp;('.$result->posts.')' . $afterafter;
1008                  $output .= get_archives_link($url, $text, $format, $before, $after);
1009              }
1010          }
1011      } elseif ('yearly' == $type) {
1012          $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 $order $limit";
1013          $key = md5( $query );
1014          $key = "wp_get_archives:$key:$last_changed";
1015          if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1016              $results = $wpdb->get_results( $query );
1017              wp_cache_set( $key, $results, 'posts' );
1018          }
1019          if ( $results ) {
1020              $afterafter = $after;
1021              foreach ( (array) $results as $result) {
1022                  $url = get_year_link($result->year);
1023                  $text = sprintf('%d', $result->year);
1024                  if ($show_post_count)
1025                      $after = '&nbsp;('.$result->posts.')' . $afterafter;
1026                  $output .= get_archives_link($url, $text, $format, $before, $after);
1027              }
1028          }
1029      } elseif ( 'daily' == $type ) {
1030          $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 $order $limit";
1031          $key = md5( $query );
1032          $key = "wp_get_archives:$key:$last_changed";
1033          if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1034              $results = $wpdb->get_results( $query );
1035              $cache[ $key ] = $results;
1036              wp_cache_set( $key, $results, 'posts' );
1037          }
1038          if ( $results ) {
1039              $afterafter = $after;
1040              foreach ( (array) $results as $result ) {
1041                  $url    = get_day_link($result->year, $result->month, $result->dayofmonth);
1042                  $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
1043                  $text = mysql2date($archive_day_date_format, $date);
1044                  if ($show_post_count)
1045                      $after = '&nbsp;('.$result->posts.')'.$afterafter;
1046                  $output .= get_archives_link($url, $text, $format, $before, $after);
1047              }
1048          }
1049      } elseif ( 'weekly' == $type ) {
1050          $week = _wp_mysql_week( '`post_date`' );
1051          $query = "SELECT DISTINCT $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, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
1052          $key = md5( $query );
1053          $key = "wp_get_archives:$key:$last_changed";
1054          if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1055              $results = $wpdb->get_results( $query );
1056              wp_cache_set( $key, $results, 'posts' );
1057          }
1058          $arc_w_last = '';
1059          $afterafter = $after;
1060          if ( $results ) {
1061                  foreach ( (array) $results as $result ) {
1062                      if ( $result->week != $arc_w_last ) {
1063                          $arc_year = $result->yr;
1064                          $arc_w_last = $result->week;
1065                          $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
1066                          $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
1067                          $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
1068                          $url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $result->week);
1069                          $text = $arc_week_start . $archive_week_separator . $arc_week_end;
1070                          if ($show_post_count)
1071                              $after = '&nbsp;('.$result->posts.')'.$afterafter;
1072                          $output .= get_archives_link($url, $text, $format, $before, $after);
1073                      }
1074                  }
1075          }
1076      } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
1077          $orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC ';
1078          $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
1079          $key = md5( $query );
1080          $key = "wp_get_archives:$key:$last_changed";
1081          if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1082              $results = $wpdb->get_results( $query );
1083              wp_cache_set( $key, $results, 'posts' );
1084          }
1085          if ( $results ) {
1086              foreach ( (array) $results as $result ) {
1087                  if ( $result->post_date != '0000-00-00 00:00:00' ) {
1088                      $url  = get_permalink( $result );
1089                      if ( $result->post_title ) {
1090                          /** This filter is documented in wp-includes/post-template.php */
1091                          $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
1092                      } else {
1093                          $text = $result->ID;
1094                      }
1095                      $output .= get_archives_link($url, $text, $format, $before, $after);
1096                  }
1097              }
1098          }
1099      }
1100      if ( $echo )
1101          echo $output;
1102      else
1103          return $output;
1104  }
1105  
1106  /**
1107   * Get number of days since the start of the week.
1108   *
1109   * @since 1.5.0
1110   *
1111   * @param int $num Number of day.
1112   * @return int Days since the start of the week.
1113   */
1114  function calendar_week_mod($num) {
1115      $base = 7;
1116      return ($num - $base*floor($num/$base));
1117  }
1118  
1119  /**
1120   * Display calendar with days that have posts as links.
1121   *
1122   * The calendar is cached, which will be retrieved, if it exists. If there are
1123   * no posts for the month, then it will not be displayed.
1124   *
1125   * @since 1.0.0
1126   * @uses calendar_week_mod()
1127   *
1128   * @param bool $initial Optional, default is true. Use initial calendar names.
1129   * @param bool $echo Optional, default is true. Set to false for return.
1130   * @return string|null String when retrieving, null when displaying.
1131   */
1132  function get_calendar($initial = true, $echo = true) {
1133      global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1134  
1135      $cache = array();
1136      $key = md5( $m . $monthnum . $year );
1137      if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
1138          if ( is_array($cache) && isset( $cache[ $key ] ) ) {
1139              if ( $echo ) {
1140                  echo apply_filters( 'get_calendar',  $cache[$key] );
1141                  return;
1142              } else {
1143                  return apply_filters( 'get_calendar',  $cache[$key] );
1144              }
1145          }
1146      }
1147  
1148      if ( !is_array($cache) )
1149          $cache = array();
1150  
1151      // Quick check. If we have no posts at all, abort!
1152      if ( !$posts ) {
1153          $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1154          if ( !$gotsome ) {
1155              $cache[ $key ] = '';
1156              wp_cache_set( 'get_calendar', $cache, 'calendar' );
1157              return;
1158          }
1159      }
1160  
1161      if ( isset($_GET['w']) )
1162          $w = ''.intval($_GET['w']);
1163  
1164      // week_begins = 0 stands for Sunday
1165      $week_begins = intval(get_option('start_of_week'));
1166  
1167      // Let's figure out when we are
1168      if ( !empty($monthnum) && !empty($year) ) {
1169          $thismonth = ''.zeroise(intval($monthnum), 2);
1170          $thisyear = ''.intval($year);
1171      } elseif ( !empty($w) ) {
1172          // We need to get the month from MySQL
1173          $thisyear = ''.intval(substr($m, 0, 4));
1174          $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
1175          $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1176      } elseif ( !empty($m) ) {
1177          $thisyear = ''.intval(substr($m, 0, 4));
1178          if ( strlen($m) < 6 )
1179                  $thismonth = '01';
1180          else
1181                  $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
1182      } else {
1183          $thisyear = gmdate('Y', current_time('timestamp'));
1184          $thismonth = gmdate('m', current_time('timestamp'));
1185      }
1186  
1187      $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
1188      $last_day = date('t', $unixmonth);
1189  
1190      // Get the next and previous month and year with at least one post
1191      $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1192          FROM $wpdb->posts
1193          WHERE post_date < '$thisyear-$thismonth-01'
1194          AND post_type = 'post' AND post_status = 'publish'
1195              ORDER BY post_date DESC
1196              LIMIT 1");
1197      $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1198          FROM $wpdb->posts
1199          WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1200          AND post_type = 'post' AND post_status = 'publish'
1201              ORDER BY post_date ASC
1202              LIMIT 1");
1203  
1204      /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1205      $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1206      $calendar_output = '<table id="wp-calendar">
1207      <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
1208      <thead>
1209      <tr>';
1210  
1211      $myweek = array();
1212  
1213      for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
1214          $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
1215      }
1216  
1217      foreach ( $myweek as $wd ) {
1218          $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1219          $wd = esc_attr($wd);
1220          $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1221      }
1222  
1223      $calendar_output .= '
1224      </tr>
1225      </thead>
1226  
1227      <tfoot>
1228      <tr>';
1229  
1230      if ( $previous ) {
1231          $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 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>';
1232      } else {
1233          $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
1234      }
1235  
1236      $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
1237  
1238      if ( $next ) {
1239          $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), 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>';
1240      } else {
1241          $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
1242      }
1243  
1244      $calendar_output .= '
1245      </tr>
1246      </tfoot>
1247  
1248      <tbody>
1249      <tr>';
1250  
1251      // Get days with posts
1252      $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
1253          FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
1254          AND post_type = 'post' AND post_status = 'publish'
1255          AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
1256      if ( $dayswithposts ) {
1257          foreach ( (array) $dayswithposts as $daywith ) {
1258              $daywithpost[] = $daywith[0];
1259          }
1260      } else {
1261          $daywithpost = array();
1262      }
1263  
1264      if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
1265          $ak_title_separator = "\n";
1266      else
1267          $ak_title_separator = ', ';
1268  
1269      $ak_titles_for_day = array();
1270      $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
1271          ."FROM $wpdb->posts "
1272          ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
1273          ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
1274          ."AND post_type = 'post' AND post_status = 'publish'"
1275      );
1276      if ( $ak_post_titles ) {
1277          foreach ( (array) $ak_post_titles as $ak_post_title ) {
1278  
1279                  /** This filter is documented in wp-includes/post-template.php */
1280                  $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
1281  
1282                  if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
1283                      $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1284                  if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
1285                      $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
1286                  else
1287                      $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
1288          }
1289      }
1290  
1291      // See how much we should pad in the beginning
1292      $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
1293      if ( 0 != $pad )
1294          $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
1295  
1296      $daysinmonth = intval(date('t', $unixmonth));
1297      for ( $day = 1; $day <= $daysinmonth; ++$day ) {
1298          if ( isset($newrow) && $newrow )
1299              $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
1300          $newrow = false;
1301  
1302          if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
1303              $calendar_output .= '<td id="today">';
1304          else
1305              $calendar_output .= '<td>';
1306  
1307          if ( in_array($day, $daywithpost) ) // any posts today?
1308                  $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
1309          else
1310              $calendar_output .= $day;
1311          $calendar_output .= '</td>';
1312  
1313          if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
1314              $newrow = true;
1315      }
1316  
1317      $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
1318      if ( $pad != 0 && $pad != 7 )
1319          $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
1320  
1321      $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
1322  
1323      $cache[ $key ] = $calendar_output;
1324      wp_cache_set( 'get_calendar', $cache, 'calendar' );
1325  
1326      if ( $echo )
1327          echo apply_filters( 'get_calendar',  $calendar_output );
1328      else
1329          return apply_filters( 'get_calendar',  $calendar_output );
1330  
1331  }
1332  
1333  /**
1334   * Purge the cached results of get_calendar.
1335   *
1336   * @see get_calendar
1337   * @since 2.1.0
1338   */
1339  function delete_get_calendar_cache() {
1340      wp_cache_delete( 'get_calendar', 'calendar' );
1341  }
1342  add_action( 'save_post', 'delete_get_calendar_cache' );
1343  add_action( 'delete_post', 'delete_get_calendar_cache' );
1344  add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
1345  add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
1346  
1347  /**
1348   * Display all of the allowed tags in HTML format with attributes.
1349   *
1350   * This is useful for displaying in the comment area, which elements and
1351   * attributes are supported. As well as any plugins which want to display it.
1352   *
1353   * @since 1.0.1
1354   * @uses $allowedtags
1355   *
1356   * @return string HTML allowed tags entity encoded.
1357   */
1358  function allowed_tags() {
1359      global $allowedtags;
1360      $allowed = '';
1361      foreach ( (array) $allowedtags as $tag => $attributes ) {
1362          $allowed .= '<'.$tag;
1363          if ( 0 < count($attributes) ) {
1364              foreach ( $attributes as $attribute => $limits ) {
1365                  $allowed .= ' '.$attribute.'=""';
1366              }
1367          }
1368          $allowed .= '> ';
1369      }
1370      return htmlentities($allowed);
1371  }
1372  
1373  /***** Date/Time tags *****/
1374  
1375  /**
1376   * Outputs the date in iso8601 format for xml files.
1377   *
1378   * @since 1.0.0
1379   */
1380  function the_date_xml() {
1381      echo mysql2date( 'Y-m-d', get_post()->post_date, false );
1382  }
1383  
1384  /**
1385   * Display or Retrieve the date the current $post was written (once per date)
1386   *
1387   * Will only output the date if the current post's date is different from the
1388   * previous one output.
1389   *
1390   * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
1391   * function is called several times for each post.
1392   *
1393   * HTML output can be filtered with 'the_date'.
1394   * Date string output can be filtered with 'get_the_date'.
1395   *
1396   * @since 0.71
1397   * @uses get_the_date()
1398   * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1399   * @param string $before Optional. Output before the date.
1400   * @param string $after Optional. Output after the date.
1401   * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1402   * @return string|null Null if displaying, string if retrieving.
1403   */
1404  function the_date( $d = '', $before = '', $after = '', $echo = true ) {
1405      global $currentday, $previousday;
1406      $the_date = '';
1407      if ( $currentday != $previousday ) {
1408          $the_date .= $before;
1409          $the_date .= get_the_date( $d );
1410          $the_date .= $after;
1411          $previousday = $currentday;
1412  
1413          $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
1414  
1415          if ( $echo )
1416              echo $the_date;
1417          else
1418              return $the_date;
1419      }
1420  
1421      return null;
1422  }
1423  
1424  /**
1425   * Retrieve the date the current $post was written.
1426   *
1427   * Unlike the_date() this function will always return the date.
1428   * Modify output with 'get_the_date' filter.
1429   *
1430   * @since 3.0.0
1431   *
1432   * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1433   * @return string|null Null if displaying, string if retrieving.
1434   */
1435  function get_the_date( $d = '' ) {
1436      $post = get_post();
1437      $the_date = '';
1438  
1439      if ( '' == $d )
1440          $the_date .= mysql2date(get_option('date_format'), $post->post_date);
1441      else
1442          $the_date .= mysql2date($d, $post->post_date);
1443  
1444      return apply_filters('get_the_date', $the_date, $d);
1445  }
1446  
1447  /**
1448   * Display the date on which the post was last modified.
1449   *
1450   * @since 2.1.0
1451   *
1452   * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1453   * @param string $before Optional. Output before the date.
1454   * @param string $after Optional. Output after the date.
1455   * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1456   * @return string|null Null if displaying, string if retrieving.
1457   */
1458  function the_modified_date($d = '', $before='', $after='', $echo = true) {
1459  
1460      $the_modified_date = $before . get_the_modified_date($d) . $after;
1461      $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after);
1462  
1463      if ( $echo )
1464          echo $the_modified_date;
1465      else
1466          return $the_modified_date;
1467  
1468  }
1469  
1470  /**
1471   * Retrieve the date on which the post was last modified.
1472   *
1473   * @since 2.1.0
1474   *
1475   * @param string $d Optional. PHP date format. Defaults to the "date_format" option
1476   * @return string
1477   */
1478  function get_the_modified_date($d = '') {
1479      if ( '' == $d )
1480          $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
1481      else
1482          $the_time = get_post_modified_time($d, null, null, true);
1483      return apply_filters('get_the_modified_date', $the_time, $d);
1484  }
1485  
1486  /**
1487   * Display the time at which the post was written.
1488   *
1489   * @since 0.71
1490   *
1491   * @param string $d Either 'G', 'U', or php date format.
1492   */
1493  function the_time( $d = '' ) {
1494      echo apply_filters('the_time', get_the_time( $d ), $d);
1495  }
1496  
1497  /**
1498   * Retrieve the time at which the post was written.
1499   *
1500   * @since 1.5.0
1501   *
1502   * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1503   * @param int|object $post Optional post ID or object. Default is global $post object.
1504   * @return string
1505   */
1506  function get_the_time( $d = '', $post = null ) {
1507      $post = get_post($post);
1508  
1509      if ( '' == $d )
1510          $the_time = get_post_time(get_option('time_format'), false, $post, true);
1511      else
1512          $the_time = get_post_time($d, false, $post, true);
1513      return apply_filters('get_the_time', $the_time, $d, $post);
1514  }
1515  
1516  /**
1517   * Retrieve the time at which the post was written.
1518   *
1519   * @since 2.0.0
1520   *
1521   * @param string $d Optional Either 'G', 'U', or php date format.
1522   * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1523   * @param int|object $post Optional post ID or object. Default is global $post object.
1524   * @param bool $translate Whether to translate the time string
1525   * @return string
1526   */
1527  function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
1528      $post = get_post($post);
1529  
1530      if ( $gmt )
1531          $time = $post->post_date_gmt;
1532      else
1533          $time = $post->post_date;
1534  
1535      $time = mysql2date($d, $time, $translate);
1536      return apply_filters('get_post_time', $time, $d, $gmt);
1537  }
1538  
1539  /**
1540   * Display the time at which the post was last modified.
1541   *
1542   * @since 2.0.0
1543   *
1544   * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1545   */
1546  function the_modified_time($d = '') {
1547      echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
1548  }
1549  
1550  /**
1551   * Retrieve the time at which the post was last modified.
1552   *
1553   * @since 2.0.0
1554   *
1555   * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1556   * @return string
1557   */
1558  function get_the_modified_time($d = '') {
1559      if ( '' == $d )
1560          $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
1561      else
1562          $the_time = get_post_modified_time($d, null, null, true);
1563      return apply_filters('get_the_modified_time', $the_time, $d);
1564  }
1565  
1566  /**
1567   * Retrieve the time at which the post was last modified.
1568   *
1569   * @since 2.0.0
1570   *
1571   * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
1572   * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1573   * @param int|object $post Optional, default is global post object. A post_id or post object
1574   * @param bool $translate Optional, default is false. Whether to translate the result
1575   * @return string Returns timestamp
1576   */
1577  function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
1578      $post = get_post($post);
1579  
1580      if ( $gmt )
1581          $time = $post->post_modified_gmt;
1582      else
1583          $time = $post->post_modified;
1584      $time = mysql2date($d, $time, $translate);
1585  
1586      return apply_filters('get_post_modified_time', $time, $d, $gmt);
1587  }
1588  
1589  /**
1590   * Display the weekday on which the post was written.
1591   *
1592   * @since 0.71
1593   * @uses $wp_locale
1594   * @uses $post
1595   */
1596  function the_weekday() {
1597      global $wp_locale;
1598      $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
1599      $the_weekday = apply_filters('the_weekday', $the_weekday);
1600      echo $the_weekday;
1601  }
1602  
1603  /**
1604   * Display the weekday on which the post was written.
1605   *
1606   * Will only output the weekday if the current post's weekday is different from
1607   * the previous one output.
1608   *
1609   * @since 0.71
1610   *
1611   * @param string $before Optional Output before the date.
1612   * @param string $after Optional Output after the date.
1613   */
1614  function the_weekday_date($before='',$after='') {
1615      global $wp_locale, $currentday, $previousweekday;
1616      $the_weekday_date = '';
1617      if ( $currentday != $previousweekday ) {
1618          $the_weekday_date .= $before;
1619          $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
1620          $the_weekday_date .= $after;
1621          $previousweekday = $currentday;
1622      }
1623      $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
1624      echo $the_weekday_date;
1625  }
1626  
1627  /**
1628   * Fire the wp_head action
1629   *
1630   * @since 1.2.0
1631   * @uses do_action() Calls 'wp_head' hook.
1632   */
1633  function wp_head() {
1634      do_action('wp_head');
1635  }
1636  
1637  /**
1638   * Fire the wp_footer action
1639   *
1640   * @since 1.5.1
1641   * @uses do_action() Calls 'wp_footer' hook.
1642   */
1643  function wp_footer() {
1644      do_action('wp_footer');
1645  }
1646  
1647  /**
1648   * Display the links to the general feeds.
1649   *
1650   * @since 2.8.0
1651   *
1652   * @param array $args Optional arguments.
1653   */
1654  function feed_links( $args = array() ) {
1655      if ( !current_theme_supports('automatic-feed-links') )
1656          return;
1657  
1658      $defaults = array(
1659          /* translators: Separator between blog name and feed type in feed links */
1660          'separator'    => _x('&raquo;', 'feed link'),
1661          /* translators: 1: blog title, 2: separator (raquo) */
1662          'feedtitle'    => __('%1$s %2$s Feed'),
1663          /* translators: 1: blog title, 2: separator (raquo) */
1664          'comstitle'    => __('%1$s %2$s Comments Feed'),
1665      );
1666  
1667      $args = wp_parse_args( $args, $defaults );
1668  
1669      echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
1670      echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
1671  }
1672  
1673  /**
1674   * Display the links to the extra feeds such as category feeds.
1675   *
1676   * @since 2.8.0
1677   *
1678   * @param array $args Optional arguments.
1679   */
1680  function feed_links_extra( $args = array() ) {
1681      $defaults = array(
1682          /* translators: Separator between blog name and feed type in feed links */
1683          'separator'   => _x('&raquo;', 'feed link'),
1684          /* translators: 1: blog name, 2: separator(raquo), 3: post title */
1685          'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
1686          /* translators: 1: blog name, 2: separator(raquo), 3: category name */
1687          'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
1688          /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
1689          'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
1690          /* translators: 1: blog name, 2: separator(raquo), 3: author name  */
1691          'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
1692          /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
1693          'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
1694          /* translators: 1: blog name, 2: separator(raquo), 3: post type name */
1695          'posttypetitle' => __('%1$s %2$s %3$s Feed'),
1696      );
1697  
1698      $args = wp_parse_args( $args, $defaults );
1699  
1700      if ( is_singular() ) {
1701          $id = 0;
1702          $post = get_post( $id );
1703  
1704          if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
1705              $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );
1706              $href = get_post_comments_feed_link( $post->ID );
1707          }
1708      } elseif ( is_post_type_archive() ) {
1709          $post_type = get_query_var( 'post_type' );
1710          if ( is_array( $post_type ) )
1711              $post_type = reset( $post_type );
1712  
1713          $post_type_obj = get_post_type_object( $post_type );
1714          $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
1715          $href = get_post_type_archive_feed_link( $post_type_obj->name );
1716      } elseif ( is_category() ) {
1717          $term = get_queried_object();
1718  
1719          if ( $term ) {
1720              $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
1721              $href = get_category_feed_link( $term->term_id );
1722          }
1723      } elseif ( is_tag() ) {
1724          $term = get_queried_object();
1725  
1726          if ( $term ) {
1727              $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
1728              $href = get_tag_feed_link( $term->term_id );
1729          }
1730      } elseif ( is_author() ) {
1731          $author_id = intval( get_query_var('author') );
1732  
1733          $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
1734          $href = get_author_feed_link( $author_id );
1735      } elseif ( is_search() ) {
1736          $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
1737          $href = get_search_feed_link();
1738      } elseif ( is_post_type_archive() ) {
1739          $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
1740          $post_type_obj = get_queried_object();
1741          if ( $post_type_obj )
1742              $href = get_post_type_archive_feed_link( $post_type_obj->name );
1743      }
1744  
1745      if ( isset($title) && isset($href) )
1746          echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
1747  }
1748  
1749  /**
1750   * Display the link to the Really Simple Discovery service endpoint.
1751   *
1752   * @link http://archipelago.phrasewise.com/rsd
1753   * @since 2.0.0
1754   */
1755  function rsd_link() {
1756      echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
1757  }
1758  
1759  /**
1760   * Display the link to the Windows Live Writer manifest file.
1761   *
1762   * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
1763   * @since 2.3.1
1764   */
1765  function wlwmanifest_link() {
1766      echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
1767          . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
1768  }
1769  
1770  /**
1771   * Display a noindex meta tag if required by the blog configuration.
1772   *
1773   * If a blog is marked as not being public then the noindex meta tag will be
1774   * output to tell web robots not to index the page content. Add this to the wp_head action.
1775   * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
1776   *
1777   * @see wp_no_robots
1778   *
1779   * @since 2.1.0
1780   */
1781  function noindex() {
1782      // If the blog is not public, tell robots to go away.
1783      if ( '0' == get_option('blog_public') )
1784          wp_no_robots();
1785  }
1786  
1787  /**
1788   * Display a noindex meta tag.
1789   *
1790   * Outputs a noindex meta tag that tells web robots not to index the page content.
1791   * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
1792   *
1793   * @since 3.3.0
1794   */
1795  function wp_no_robots() {
1796      echo "<meta name='robots' content='noindex,follow' />\n";
1797  }
1798  
1799  /**
1800   * Determine if TinyMCE is available.
1801   *
1802   * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
1803   *
1804   * @since 2.1.0
1805   *
1806   * @return bool Whether TinyMCE exists.
1807   */
1808  function rich_edit_exists() {
1809      global $wp_rich_edit_exists;
1810      if ( !isset($wp_rich_edit_exists) )
1811          $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
1812      return $wp_rich_edit_exists;
1813  }
1814  
1815  /**
1816   * Whether the user should have a WYSIWIG editor.
1817   *
1818   * Checks that the user requires a WYSIWIG editor and that the editor is
1819   * supported in the users browser.
1820   *
1821   * @since 2.0.0
1822   *
1823   * @return bool
1824   */
1825  function user_can_richedit() {
1826      global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
1827  
1828      if ( !isset($wp_rich_edit) ) {
1829          $wp_rich_edit = false;
1830  
1831          if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
1832              if ( $is_safari ) {
1833                  $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
1834              } elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) {
1835                  $wp_rich_edit = true;
1836              }
1837          }
1838      }
1839  
1840      return apply_filters('user_can_richedit', $wp_rich_edit);
1841  }
1842  
1843  /**
1844   * Find out which editor should be displayed by default.
1845   *
1846   * Works out which of the two editors to display as the current editor for a
1847   * user. The 'html' setting is for the "Text" editor tab.
1848   *
1849   * @since 2.5.0
1850   *
1851   * @return string Either 'tinymce', or 'html', or 'test'
1852   */
1853  function wp_default_editor() {
1854      $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
1855      if ( $user = wp_get_current_user() ) { // look for cookie
1856          $ed = get_user_setting('editor', 'tinymce');
1857          $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
1858      }
1859      return apply_filters( 'wp_default_editor', $r ); // filter
1860  }
1861  
1862  /**
1863   * Renders an editor.
1864   *
1865   * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
1866   * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144.
1867   *
1868   * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
1869   * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
1870   * On the post edit screen several actions can be used to include additional editors
1871   * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
1872   * See http://core.trac.wordpress.org/ticket/19173 for more information.
1873   *
1874   * @see wp-includes/class-wp-editor.php
1875   * @since 3.3.0
1876   *
1877   * @param string $content Initial content for the editor.
1878   * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
1879   * @param array $settings See _WP_Editors::editor().
1880   */
1881  function wp_editor( $content, $editor_id, $settings = array() ) {
1882      if ( ! class_exists( '_WP_Editors' ) )
1883          require ( ABSPATH . WPINC . '/class-wp-editor.php' );
1884  
1885      _WP_Editors::editor($content, $editor_id, $settings);
1886  }
1887  
1888  /**
1889   * Retrieve the contents of the search WordPress query variable.
1890   *
1891   * The search query string is passed through {@link esc_attr()}
1892   * to ensure that it is safe for placing in an html attribute.
1893   *
1894   * @since 2.3.0
1895   * @uses esc_attr()
1896   *
1897   * @param bool $escaped Whether the result is escaped. Default true.
1898   *     Only use when you are later escaping it. Do not use unescaped.
1899   * @return string
1900   */
1901  function get_search_query( $escaped = true ) {
1902      $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
1903      if ( $escaped )
1904          $query = esc_attr( $query );
1905      return $query;
1906  }
1907  
1908  /**
1909   * Display the contents of the search query variable.
1910   *
1911   * The search query string is passed through {@link esc_attr()}
1912   * to ensure that it is safe for placing in an html attribute.
1913   *
1914   * @uses esc_attr()
1915   * @since 2.1.0
1916   */
1917  function the_search_query() {
1918      echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
1919  }
1920  
1921  /**
1922   * Display the language attributes for the html tag.
1923   *
1924   * Builds up a set of html attributes containing the text direction and language
1925   * information for the page.
1926   *
1927   * @since 2.1.0
1928   *
1929   * @param string $doctype The type of html document (xhtml|html).
1930   */
1931  function language_attributes($doctype = 'html') {
1932      $attributes = array();
1933      $output = '';
1934  
1935      if ( function_exists( 'is_rtl' ) && is_rtl() )
1936          $attributes[] = 'dir="rtl"';
1937  
1938      if ( $lang = get_bloginfo('language') ) {
1939          if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
1940              $attributes[] = "lang=\"$lang\"";
1941  
1942          if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1943              $attributes[] = "xml:lang=\"$lang\"";
1944      }
1945  
1946      $output = implode(' ', $attributes);
1947      $output = apply_filters('language_attributes', $output);
1948      echo $output;
1949  }
1950  
1951  /**
1952   * Retrieve paginated link for archive post pages.
1953   *
1954   * Technically, the function can be used to create paginated link list for any
1955   * area. The 'base' argument is used to reference the url, which will be used to
1956   * create the paginated links. The 'format' argument is then used for replacing
1957   * the page number. It is however, most likely and by default, to be used on the
1958   * archive post pages.
1959   *
1960   * The 'type' argument controls format of the returned value. The default is
1961   * 'plain', which is just a string with the links separated by a newline
1962   * character. The other possible values are either 'array' or 'list'. The
1963   * 'array' value will return an array of the paginated link list to offer full
1964   * control of display. The 'list' value will place all of the paginated links in
1965   * an unordered HTML list.
1966   *
1967   * The 'total' argument is the total amount of pages and is an integer. The
1968   * 'current' argument is the current page number and is also an integer.
1969   *
1970   * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
1971   * and the '%_%' is required. The '%_%' will be replaced by the contents of in
1972   * the 'format' argument. An example for the 'format' argument is "?page=%#%"
1973   * and the '%#%' is also required. The '%#%' will be replaced with the page
1974   * number.
1975   *
1976   * You can include the previous and next links in the list by setting the
1977   * 'prev_next' argument to true, which it is by default. You can set the
1978   * previous text, by using the 'prev_text' argument. You can set the next text
1979   * by setting the 'next_text' argument.
1980   *
1981   * If the 'show_all' argument is set to true, then it will show all of the pages
1982   * instead of a short list of the pages near the current page. By default, the
1983   * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
1984   * arguments. The 'end_size' argument is how many numbers on either the start
1985   * and the end list edges, by default is 1. The 'mid_size' argument is how many
1986   * numbers to either side of current page, but not including current page.
1987   *
1988   * It is possible to add query vars to the link by using the 'add_args' argument
1989   * and see {@link add_query_arg()} for more information.
1990   *
1991   * @since 2.1.0
1992   *
1993   * @param string|array $args Optional. Override defaults.
1994   * @return array|string String of page links or array of page links.
1995   */
1996  function paginate_links( $args = '' ) {
1997      $defaults = array(
1998          'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
1999          'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
2000          'total' => 1,
2001          'current' => 0,
2002          'show_all' => false,
2003          'prev_next' => true,
2004          'prev_text' => __('&laquo; Previous'),
2005          'next_text' => __('Next &raquo;'),
2006          'end_size' => 1,
2007          'mid_size' => 2,
2008          'type' => 'plain',
2009          'add_args' => false, // array of query args to add
2010          'add_fragment' => ''
2011      );
2012  
2013      $args = wp_parse_args( $args, $defaults );
2014      extract($args, EXTR_SKIP);
2015  
2016      // Who knows what else people pass in $args
2017      $total = (int) $total;
2018      if ( $total < 2 )
2019          return;
2020      $current  = (int) $current;
2021      $end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
2022      $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
2023      $add_args = is_array($add_args) ? $add_args : false;
2024      $r = '';
2025      $page_links = array();
2026      $n = 0;
2027      $dots = false;
2028  
2029      if ( $prev_next && $current && 1 < $current ) :
2030          $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
2031          $link = str_replace('%#%', $current - 1, $link);
2032          if ( $add_args )
2033              $link = add_query_arg( $add_args, $link );
2034          $link .= $add_fragment;
2035          $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
2036      endif;
2037      for ( $n = 1; $n <= $total; $n++ ) :
2038          $n_display = number_format_i18n($n);
2039          if ( $n == $current ) :
2040              $page_links[] = "<span class='page-numbers current'>$n_display</span>";
2041              $dots = true;
2042          else :
2043              if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2044                  $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
2045                  $link = str_replace('%#%', $n, $link);
2046                  if ( $add_args )
2047                      $link = add_query_arg( $add_args, $link );
2048                  $link .= $add_fragment;
2049                  $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
2050                  $dots = true;
2051              elseif ( $dots && !$show_all ) :
2052                  $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
2053                  $dots = false;
2054              endif;
2055          endif;
2056      endfor;
2057      if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
2058          $link = str_replace('%_%', $format, $base);
2059          $link = str_replace('%#%', $current + 1, $link);
2060          if ( $add_args )
2061              $link = add_query_arg( $add_args, $link );
2062          $link .= $add_fragment;
2063          $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
2064      endif;
2065      switch ( $type ) :
2066          case 'array' :
2067              return $page_links;
2068              break;
2069          case 'list' :
2070              $r .= "<ul class='page-numbers'>\n\t<li>";
2071              $r .= join("</li>\n\t<li>", $page_links);
2072              $r .= "</li>\n</ul>\n";
2073              break;
2074          default :
2075              $r = join("\n", $page_links);
2076              break;
2077      endswitch;
2078      return $r;
2079  }
2080  
2081  /**
2082   * Registers an admin colour scheme css file.
2083   *
2084   * Allows a plugin to register a new admin colour scheme. For example:
2085   * <code>
2086   * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
2087   * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
2088   * </code>
2089   *
2090   * @since 2.5.0
2091   *
2092   * @param string $key The unique key for this theme.
2093   * @param string $name The name of the theme.
2094   * @param string $url The url of the css file containing the colour scheme.
2095   * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
2096   * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
2097   */
2098  function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
2099      global $_wp_admin_css_colors;
2100  
2101      if ( !isset($_wp_admin_css_colors) )
2102          $_wp_admin_css_colors = array();
2103  
2104      $_wp_admin_css_colors[$key] = (object) array(
2105          'name' => $name,
2106          'url' => $url,
2107          'colors' => $colors,
2108          'icon_colors' => $icons,
2109      );
2110  }
2111  
2112  /**
2113   * Registers the default Admin color schemes
2114   *
2115   * @since 3.0.0
2116   */
2117  function register_admin_color_schemes() {
2118      $suffix = is_rtl() ? '-rtl' : '';
2119      $suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
2120  
2121      wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
2122          admin_url( "css/colors$suffix.css" ),
2123          array( '#222', '#333', '#0074a2', '#2ea2cc' ),
2124          array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' )
2125      );
2126  
2127      // Other color schemes are not available when running out of src
2128      if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
2129          return;
2130  
2131      wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
2132          admin_url( "css/colors/light/colors$suffix.css" ),
2133          array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
2134          array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
2135      );
2136  
2137      wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
2138          admin_url( "css/colors/blue/colors$suffix.css" ),
2139          array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
2140          array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
2141      );
2142  
2143      wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
2144          admin_url( "css/colors/midnight/colors$suffix.css" ),
2145          array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
2146          array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
2147      );
2148  
2149      wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
2150          admin_url( "css/colors/sunrise/colors$suffix.css" ),
2151          array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
2152          array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
2153      );
2154  
2155      wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
2156          admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
2157          array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
2158          array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
2159      );
2160  
2161      wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
2162          admin_url( "css/colors/ocean/colors$suffix.css" ),
2163          array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
2164          array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
2165      );
2166  
2167      wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
2168          admin_url( "css/colors/coffee/colors$suffix.css" ),
2169          array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
2170          array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
2171      );
2172  
2173  }
2174  
2175  /**
2176   * Display the URL of a WordPress admin CSS file.
2177   *
2178   * @see WP_Styles::_css_href and its style_loader_src filter.
2179   *
2180   * @since 2.3.0
2181   *
2182   * @param string $file file relative to wp-admin/ without its ".css" extension.
2183   */
2184  function wp_admin_css_uri( $file = 'wp-admin' ) {
2185      if ( defined('WP_INSTALLING') ) {
2186          $_file = "./$file.css";
2187      } else {
2188          $_file = admin_url("$file.css");
2189      }
2190      $_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
2191  
2192      return apply_filters( 'wp_admin_css_uri', $_file, $file );
2193  }
2194  
2195  /**
2196   * Enqueues or directly prints a stylesheet link to the specified CSS file.
2197   *
2198   * "Intelligently" decides to enqueue or to print the CSS file. If the
2199   * 'wp_print_styles' action has *not* yet been called, the CSS file will be
2200   * enqueued. If the wp_print_styles action *has* been called, the CSS link will
2201   * be printed. Printing may be forced by passing true as the $force_echo
2202   * (second) parameter.
2203   *
2204   * For backward compatibility with WordPress 2.3 calling method: If the $file
2205   * (first) parameter does not correspond to a registered CSS file, we assume
2206   * $file is a file relative to wp-admin/ without its ".css" extension. A
2207   * stylesheet link to that generated URL is printed.
2208   *
2209   * @package WordPress
2210   * @since 2.3.0
2211   * @uses $wp_styles WordPress Styles Object
2212   *
2213   * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
2214   *      to wp-admin/. Defaults to 'wp-admin'.
2215   * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
2216   */
2217  function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
2218      global $wp_styles;
2219      if ( !is_a($wp_styles, 'WP_Styles') )
2220          $wp_styles = new WP_Styles();
2221  
2222      // For backward compatibility
2223      $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
2224  
2225      if ( $wp_styles->query( $handle ) ) {
2226          if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
2227              wp_print_styles( $handle );
2228          else // Add to style queue
2229              wp_enqueue_style( $handle );
2230          return;
2231      }
2232  
2233      echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
2234      if ( function_exists( 'is_rtl' ) && is_rtl() )
2235          echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
2236  }
2237  
2238  /**
2239   * Enqueues the default ThickBox js and css.
2240   *
2241   * If any of the settings need to be changed, this can be done with another js
2242   * file similar to media-upload.js. That file should
2243   * require array('thickbox') to ensure it is loaded after.
2244   *
2245   * @since 2.5.0
2246   */
2247  function add_thickbox() {
2248      wp_enqueue_script( 'thickbox' );
2249      wp_enqueue_style( 'thickbox' );
2250  
2251      if ( is_network_admin() )
2252          add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
2253  }
2254  
2255  /**
2256   * Display the XHTML generator that is generated on the wp_head hook.
2257   *
2258   * @since 2.5.0
2259   */
2260  function wp_generator() {
2261      the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
2262  }
2263  
2264  /**
2265   * Display the generator XML or Comment for RSS, ATOM, etc.
2266   *
2267   * Returns the correct generator type for the requested output format. Allows
2268   * for a plugin to filter generators overall the the_generator filter.
2269   *
2270   * @since 2.5.0
2271   * @uses apply_filters() Calls 'the_generator' hook.
2272   *
2273   * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
2274   */
2275  function the_generator( $type ) {
2276      echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
2277  }
2278  
2279  /**
2280   * Creates the generator XML or Comment for RSS, ATOM, etc.
2281   *
2282   * Returns the correct generator type for the requested output format. Allows
2283   * for a plugin to filter generators on an individual basis using the
2284   * 'get_the_generator_{$type}' filter.
2285   *
2286   * @since 2.5.0
2287   * @uses apply_filters() Calls 'get_the_generator_$type' hook.
2288   *
2289   * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
2290   * @return string The HTML content for the generator.
2291   */
2292  function get_the_generator( $type = '' ) {
2293      if ( empty( $type ) ) {
2294  
2295          $current_filter = current_filter();
2296          if ( empty( $current_filter ) )
2297              return;
2298  
2299          switch ( $current_filter ) {
2300              case 'rss2_head' :
2301              case 'commentsrss2_head' :
2302                  $type = 'rss2';
2303                  break;
2304              case 'rss_head' :
2305              case 'opml_head' :
2306                  $type = 'comment';
2307                  break;
2308              case 'rdf_header' :
2309                  $type = 'rdf';
2310                  break;
2311              case 'atom_head' :
2312              case 'comments_atom_head' :
2313              case 'app_head' :
2314                  $type = 'atom';
2315                  break;
2316          }
2317      }
2318  
2319      switch ( $type ) {
2320          case 'html':
2321              $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
2322              break;
2323          case 'xhtml':
2324              $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
2325              break;
2326          case 'atom':
2327              $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
2328              break;
2329          case 'rss2':
2330              $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
2331              break;
2332          case 'rdf':
2333              $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
2334              break;
2335          case 'comment':
2336              $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
2337              break;
2338          case 'export':
2339              $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
2340              break;
2341      }
2342      return apply_filters( "get_the_generator_{$type}", $gen, $type );
2343  }
2344  
2345  /**
2346   * Outputs the html checked attribute.
2347   *
2348   * Compares the first two arguments and if identical marks as checked
2349   *
2350   * @since 1.0.0
2351   *
2352   * @param mixed $checked One of the values to compare
2353   * @param mixed $current (true) The other value to compare if not just true
2354   * @param bool $echo Whether to echo or just return the string
2355   * @return string html attribute or empty string
2356   */
2357  function checked( $checked, $current = true, $echo = true ) {
2358      return __checked_selected_helper( $checked, $current, $echo, 'checked' );
2359  }
2360  
2361  /**
2362   * Outputs the html selected attribute.
2363   *
2364   * Compares the first two arguments and if identical marks as selected
2365   *
2366   * @since 1.0.0
2367   *
2368   * @param mixed $selected One of the values to compare
2369   * @param mixed $current (true) The other value to compare if not just true
2370   * @param bool $echo Whether to echo or just return the string
2371   * @return string html attribute or empty string
2372   */
2373  function selected( $selected, $current = true, $echo = true ) {
2374      return __checked_selected_helper( $selected, $current, $echo, 'selected' );
2375  }
2376  
2377  /**
2378   * Outputs the html disabled attribute.
2379   *
2380   * Compares the first two arguments and if identical marks as disabled
2381   *
2382   * @since 3.0.0
2383   *
2384   * @param mixed $disabled One of the values to compare
2385   * @param mixed $current (true) The other value to compare if not just true
2386   * @param bool $echo Whether to echo or just return the string
2387   * @return string html attribute or empty string
2388   */
2389  function disabled( $disabled, $current = true, $echo = true ) {
2390      return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
2391  }
2392  
2393  /**
2394   * Private helper function for checked, selected, and disabled.
2395   *
2396   * Compares the first two arguments and if identical marks as $type
2397   *
2398   * @since 2.8.0
2399   * @access private
2400   *
2401   * @param mixed $helper One of the values to compare
2402   * @param mixed $current (true) The other value to compare if not just true
2403   * @param bool $echo Whether to echo or just return the string
2404   * @param string $type The type of checked|selected|disabled we are doing
2405   * @return string html attribute or empty string
2406   */
2407  function __checked_selected_helper( $helper, $current, $echo, $type ) {
2408      if ( (string) $helper === (string) $current )
2409          $result = " $type='$type'";
2410      else
2411          $result = '';
2412  
2413      if ( $echo )
2414          echo $result;
2415  
2416      return $result;
2417  }
2418  
2419  /**
2420   * Default settings for heartbeat
2421   *
2422   * Outputs the nonce used in the heartbeat XHR
2423   *
2424   * @since 3.6.0
2425   *
2426   * @param array $settings
2427   * @return array $settings
2428   */
2429  function wp_heartbeat_settings( $settings ) {
2430      if ( ! is_admin() )
2431          $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
2432  
2433      if ( is_user_logged_in() )
2434          $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
2435  
2436      return $settings;
2437  }


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu