Advertisement
Guest User

Untitled

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