109 * 'get_search_form'. This can be useful for outputting JavaScript that the |
144 * 'get_search_form'. This can be useful for outputting JavaScript that the |
110 * search relies on or various formatting that applies to the beginning of the |
145 * search relies on or various formatting that applies to the beginning of the |
111 * search. To give a few examples of what it can be used for. |
146 * search. To give a few examples of what it can be used for. |
112 * |
147 * |
113 * @since 2.7.0 |
148 * @since 2.7.0 |
114 */ |
149 * @param boolean $echo Default to echo and not return the form. |
115 function get_search_form() { |
150 */ |
|
151 function get_search_form($echo = true) { |
116 do_action( 'get_search_form' ); |
152 do_action( 'get_search_form' ); |
117 |
153 |
118 $search_form_template = locate_template(array('searchform.php')); |
154 $search_form_template = locate_template('searchform.php'); |
119 if ( '' != $search_form_template ) { |
155 if ( '' != $search_form_template ) { |
120 require($search_form_template); |
156 require($search_form_template); |
121 return; |
157 return; |
122 } |
158 } |
123 |
159 |
124 $form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" > |
160 $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" > |
125 <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label> |
161 <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label> |
126 <input type="text" value="' . esc_attr(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" /> |
162 <input type="text" value="' . get_search_query() . '" name="s" id="s" /> |
127 <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /> |
163 <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /> |
128 </div> |
164 </div> |
129 </form>'; |
165 </form>'; |
130 |
166 |
131 echo apply_filters('get_search_form', $form); |
167 if ( $echo ) |
|
168 echo apply_filters('get_search_form', $form); |
|
169 else |
|
170 return apply_filters('get_search_form', $form); |
132 } |
171 } |
133 |
172 |
134 /** |
173 /** |
135 * Display the Log In/Out link. |
174 * Display the Log In/Out link. |
136 * |
175 * |
137 * Displays a link, which allows the user to navigate to the Log In page to log in |
176 * Displays a link, which allows users to navigate to the Log In page to log in |
138 * or log out depending on whether or not they are currently logged in. |
177 * or log out depending on whether they are currently logged in. |
139 * |
178 * |
140 * @since 1.5.0 |
179 * @since 1.5.0 |
141 * @uses apply_filters() Calls 'loginout' hook on HTML link content. |
180 * @uses apply_filters() Calls 'loginout' hook on HTML link content. |
142 * |
181 * |
143 * @param string $redirect Optional path to redirect to on login/logout. |
182 * @param string $redirect Optional path to redirect to on login/logout. |
144 */ |
183 * @param boolean $echo Default to echo and not return the link. |
145 function wp_loginout($redirect = '') { |
184 */ |
|
185 function wp_loginout($redirect = '', $echo = true) { |
146 if ( ! is_user_logged_in() ) |
186 if ( ! is_user_logged_in() ) |
147 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; |
187 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; |
148 else |
188 else |
149 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; |
189 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; |
150 |
190 |
151 echo apply_filters('loginout', $link); |
191 if ( $echo ) |
|
192 echo apply_filters('loginout', $link); |
|
193 else |
|
194 return apply_filters('loginout', $link); |
152 } |
195 } |
153 |
196 |
154 /** |
197 /** |
155 * Returns the Log Out URL. |
198 * Returns the Log Out URL. |
156 * |
199 * |
157 * Returns the URL that allows the user to log out of the site |
200 * Returns the URL that allows the user to log out of the site |
158 * |
201 * |
159 * @since 2.7 |
202 * @since 2.7.0 |
160 * @uses wp_nonce_url() To protect against CSRF |
203 * @uses wp_nonce_url() To protect against CSRF |
161 * @uses site_url() To generate the log in URL |
204 * @uses site_url() To generate the log in URL |
162 * @uses apply_filters() calls 'logout_url' hook on final logout url |
205 * @uses apply_filters() calls 'logout_url' hook on final logout url |
163 * |
206 * |
164 * @param string $redirect Path to redirect to on logout. |
207 * @param string $redirect Path to redirect to on logout. |
178 /** |
221 /** |
179 * Returns the Log In URL. |
222 * Returns the Log In URL. |
180 * |
223 * |
181 * Returns the URL that allows the user to log in to the site |
224 * Returns the URL that allows the user to log in to the site |
182 * |
225 * |
183 * @since 2.7 |
226 * @since 2.7.0 |
184 * @uses site_url() To generate the log in URL |
227 * @uses site_url() To generate the log in URL |
185 * @uses apply_filters() calls 'login_url' hook on final login url |
228 * @uses apply_filters() calls 'login_url' hook on final login url |
186 * |
229 * |
187 * @param string $redirect Path to redirect to on login. |
230 * @param string $redirect Path to redirect to on login. |
188 */ |
231 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false. |
189 function wp_login_url($redirect = '') { |
232 * @return string A log in url |
|
233 */ |
|
234 function wp_login_url($redirect = '', $force_reauth = false) { |
190 $login_url = site_url('wp-login.php', 'login'); |
235 $login_url = site_url('wp-login.php', 'login'); |
191 |
236 |
192 if ( !empty($redirect) ) { |
237 if ( !empty($redirect) ) |
193 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url); |
238 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url); |
194 } |
239 |
|
240 if ( $force_reauth ) |
|
241 $login_url = add_query_arg('reauth', '1', $login_url); |
195 |
242 |
196 return apply_filters('login_url', $login_url, $redirect); |
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' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_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="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post"> |
|
274 ' . apply_filters( 'login_form_top', '', $args ) . ' |
|
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', '', $args ) . ' |
|
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_url( $args['redirect'] ) . '" /> |
|
288 </p> |
|
289 ' . apply_filters( 'login_form_bottom', '', $args ) . ' |
|
290 </form>'; |
|
291 |
|
292 if ( $args['echo'] ) |
|
293 echo $form; |
|
294 else |
|
295 return $form; |
197 } |
296 } |
198 |
297 |
199 /** |
298 /** |
200 * Returns the Lost Password URL. |
299 * Returns the Lost Password URL. |
201 * |
300 * |
263 * @see get_bloginfo() For possible values for the parameter. |
366 * @see get_bloginfo() For possible values for the parameter. |
264 * @since 0.71 |
367 * @since 0.71 |
265 * |
368 * |
266 * @param string $show What to display. |
369 * @param string $show What to display. |
267 */ |
370 */ |
268 function bloginfo($show='') { |
371 function bloginfo( $show='' ) { |
269 echo get_bloginfo($show, 'display'); |
372 echo get_bloginfo( $show, 'display' ); |
270 } |
373 } |
271 |
374 |
272 /** |
375 /** |
273 * Retrieve information about the blog. |
376 * Retrieve information about the blog. |
274 * |
377 * |
275 * Some show parameter values are deprecated and will be removed in future |
378 * Some show parameter values are deprecated and will be removed in future |
276 * versions. Care should be taken to check the function contents and know what |
379 * versions. These options will trigger the _deprecated_argument() function. |
277 * the deprecated blog info options are. Options without "// DEPRECATED" are |
380 * The deprecated blog info options are listed in the function contents. |
278 * the preferred and recommended ways to get the information. |
|
279 * |
381 * |
280 * The possible values for the 'show' parameter are listed below. |
382 * The possible values for the 'show' parameter are listed below. |
281 * <ol> |
383 * <ol> |
282 * <li><strong>url<strong> - Blog URI to homepage.</li> |
384 * <li><strong>url</strong> - Blog URI to homepage.</li> |
283 * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li> |
385 * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li> |
284 * <li><strong>description</strong> - Secondary title</li> |
386 * <li><strong>description</strong> - Secondary title</li> |
285 * </ol> |
387 * </ol> |
286 * |
388 * |
287 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91), |
389 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91), |
288 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The |
390 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The |
289 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment |
391 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment |
290 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed). |
392 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed). |
291 * |
393 * |
292 * There are many other options and you should check the function contents: |
|
293 * {@source 32 37} |
|
294 * |
|
295 * @since 0.71 |
394 * @since 0.71 |
296 * |
395 * |
297 * @param string $show Blog info to retrieve. |
396 * @param string $show Blog info to retrieve. |
298 * @param string $filter How to filter what is retrieved. |
397 * @param string $filter How to filter what is retrieved. |
299 * @return string Mostly string values, might be empty. |
398 * @return string Mostly string values, might be empty. |
300 */ |
399 */ |
301 function get_bloginfo($show = '', $filter = 'raw') { |
400 function get_bloginfo( $show = '', $filter = 'raw' ) { |
302 |
401 |
303 switch($show) { |
402 switch( $show ) { |
304 case 'url' : |
|
305 case 'home' : // DEPRECATED |
403 case 'home' : // DEPRECATED |
306 case 'siteurl' : // DEPRECATED |
404 case 'siteurl' : // DEPRECATED |
307 $output = get_option('home'); |
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(); |
308 break; |
408 break; |
309 case 'wpurl' : |
409 case 'wpurl' : |
310 $output = get_option('siteurl'); |
410 $output = site_url(); |
311 break; |
411 break; |
312 case 'description': |
412 case 'description': |
313 $output = get_option('blogdescription'); |
413 $output = get_option('blogdescription'); |
314 break; |
414 break; |
315 case 'rdf_url': |
415 case 'rdf_url': |
408 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
524 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
409 * @param string $seplocation Optional. Direction to display title, 'right'. |
525 * @param string $seplocation Optional. Direction to display title, 'right'. |
410 * @return string|null String on retrieve, null when displaying. |
526 * @return string|null String on retrieve, null when displaying. |
411 */ |
527 */ |
412 function wp_title($sep = '»', $display = true, $seplocation = '') { |
528 function wp_title($sep = '»', $display = true, $seplocation = '') { |
413 global $wpdb, $wp_locale, $wp_query; |
529 global $wpdb, $wp_locale; |
414 |
530 |
415 $cat = get_query_var('cat'); |
|
416 $tag = get_query_var('tag_id'); |
|
417 $category_name = get_query_var('category_name'); |
|
418 $author = get_query_var('author'); |
|
419 $author_name = get_query_var('author_name'); |
|
420 $m = get_query_var('m'); |
531 $m = get_query_var('m'); |
421 $year = get_query_var('year'); |
532 $year = get_query_var('year'); |
422 $monthnum = get_query_var('monthnum'); |
533 $monthnum = get_query_var('monthnum'); |
423 $day = get_query_var('day'); |
534 $day = get_query_var('day'); |
424 $search = get_query_var('s'); |
535 $search = get_query_var('s'); |
425 $title = ''; |
536 $title = ''; |
426 |
537 |
427 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary |
538 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary |
428 |
539 |
429 // If there's a category |
540 // If there is a post |
430 if ( !empty($cat) ) { |
541 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { |
431 // category exclusion |
542 $title = single_post_title( '', false ); |
432 if ( !stristr($cat,'-') ) |
543 } |
433 $title = apply_filters('single_cat_title', get_the_category_by_ID($cat)); |
544 |
434 } elseif ( !empty($category_name) ) { |
545 // If there's a category or tag |
435 if ( stristr($category_name,'/') ) { |
546 if ( is_category() || is_tag() ) { |
436 $category_name = explode('/',$category_name); |
547 $title = single_term_title( '', false ); |
437 if ( $category_name[count($category_name)-1] ) |
548 } |
438 $category_name = $category_name[count($category_name)-1]; // no trailing slash |
549 |
439 else |
550 // If there's a taxonomy |
440 $category_name = $category_name[count($category_name)-2]; // there was a trailling slash |
551 if ( is_tax() ) { |
441 } |
552 $term = get_queried_object(); |
442 $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display'); |
553 $tax = get_taxonomy( $term->taxonomy ); |
443 if ( $cat ) |
554 $title = single_term_title( $tax->labels->name . $t_sep, false ); |
444 $title = apply_filters('single_cat_title', $cat->name); |
|
445 } |
|
446 |
|
447 if ( !empty($tag) ) { |
|
448 $tag = get_term($tag, 'post_tag', OBJECT, 'display'); |
|
449 if ( is_wp_error( $tag ) ) |
|
450 return $tag; |
|
451 if ( ! empty($tag->name) ) |
|
452 $title = apply_filters('single_tag_title', $tag->name); |
|
453 } |
555 } |
454 |
556 |
455 // If there's an author |
557 // If there's an author |
456 if ( !empty($author) ) { |
558 if ( is_author() ) { |
457 $title = get_userdata($author); |
559 $author = get_queried_object(); |
458 $title = $title->display_name; |
560 $title = $author->display_name; |
459 } |
561 } |
460 if ( !empty($author_name) ) { |
562 |
461 // We do a direct query here because we don't cache by nicename. |
563 // If there's a post type archive |
462 $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); |
564 if ( is_post_type_archive() ) |
463 } |
565 $title = post_type_archive_title( '', false ); |
464 |
566 |
465 // If there's a month |
567 // If there's a month |
466 if ( !empty($m) ) { |
568 if ( is_archive() && !empty($m) ) { |
467 $my_year = substr($m, 0, 4); |
569 $my_year = substr($m, 0, 4); |
468 $my_month = $wp_locale->get_month(substr($m, 4, 2)); |
570 $my_month = $wp_locale->get_month(substr($m, 4, 2)); |
469 $my_day = intval(substr($m, 6, 2)); |
571 $my_day = intval(substr($m, 6, 2)); |
470 $title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : ""); |
572 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' ); |
471 } |
573 } |
472 |
574 |
473 if ( !empty($year) ) { |
575 // If there's a year |
|
576 if ( is_archive() && !empty($year) ) { |
474 $title = $year; |
577 $title = $year; |
475 if ( !empty($monthnum) ) |
578 if ( !empty($monthnum) ) |
476 $title .= "$t_sep" . $wp_locale->get_month($monthnum); |
579 $title .= $t_sep . $wp_locale->get_month($monthnum); |
477 if ( !empty($day) ) |
580 if ( !empty($day) ) |
478 $title .= "$t_sep" . zeroise($day, 2); |
581 $title .= $t_sep . zeroise($day, 2); |
479 } |
582 } |
480 |
583 |
481 // If there is a post |
584 // If it's a search |
482 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { |
|
483 $post = $wp_query->get_queried_object(); |
|
484 $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) ); |
|
485 } |
|
486 |
|
487 // If there's a taxonomy |
|
488 if ( is_tax() ) { |
|
489 $taxonomy = get_query_var( 'taxonomy' ); |
|
490 $tax = get_taxonomy( $taxonomy ); |
|
491 $tax = $tax->label; |
|
492 $term = $wp_query->get_queried_object(); |
|
493 $term = $term->name; |
|
494 $title = "$tax$t_sep$term"; |
|
495 } |
|
496 |
|
497 //If it's a search |
|
498 if ( is_search() ) { |
585 if ( is_search() ) { |
499 /* translators: 1: separator, 2: search phrase */ |
586 /* translators: 1: separator, 2: search phrase */ |
500 $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search)); |
587 $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search)); |
501 } |
588 } |
502 |
589 |
|
590 // If it's a 404 page |
503 if ( is_404() ) { |
591 if ( is_404() ) { |
504 $title = __('Page not found'); |
592 $title = __('Page not found'); |
505 } |
593 } |
506 |
594 |
507 $prefix = ''; |
595 $prefix = ''; |
530 |
618 |
531 /** |
619 /** |
532 * Display or retrieve page title for post. |
620 * Display or retrieve page title for post. |
533 * |
621 * |
534 * This is optimized for single.php template file for displaying the post title. |
622 * This is optimized for single.php template file for displaying the post title. |
535 * Only useful for posts, does not support pages for example. |
|
536 * |
623 * |
537 * It does not support placing the separator after the title, but by leaving the |
624 * It does not support placing the separator after the title, but by leaving the |
538 * prefix parameter empty, you can set the title separator manually. The prefix |
625 * prefix parameter empty, you can set the title separator manually. The prefix |
539 * does not automatically place a space between the prefix, so if there should |
626 * does not automatically place a space between the prefix, so if there should |
540 * be a space, the parameter value will need to have it at the end. |
627 * be a space, the parameter value will need to have it at the end. |
541 * |
628 * |
542 * @since 0.71 |
629 * @since 0.71 |
543 * @uses $wpdb |
|
544 * |
630 * |
545 * @param string $prefix Optional. What to display before the title. |
631 * @param string $prefix Optional. What to display before the title. |
546 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
632 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
547 * @return string|null Title when retrieving, null when displaying or failure. |
633 * @return string|null Title when retrieving, null when displaying or failure. |
548 */ |
634 */ |
549 function single_post_title($prefix = '', $display = true) { |
635 function single_post_title($prefix = '', $display = true) { |
550 global $wpdb; |
636 $_post = get_queried_object(); |
551 $p = get_query_var('p'); |
637 |
552 $name = get_query_var('name'); |
638 if ( !isset($_post->post_title) ) |
553 |
639 return; |
554 if ( intval($p) || '' != $name ) { |
640 |
555 if ( !$p ) |
641 $title = apply_filters('single_post_title', $_post->post_title, $_post); |
556 $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name)); |
642 if ( $display ) |
557 $post = & get_post($p); |
643 echo $prefix . $title; |
558 $title = $post->post_title; |
644 else |
559 $title = apply_filters('single_post_title', $title); |
645 return $title; |
560 if ( $display ) |
646 } |
561 echo $prefix.strip_tags($title); |
647 |
562 else |
648 /** |
563 return strip_tags($title); |
649 * Display or retrieve title for a post type archive. |
564 } |
650 * |
|
651 * This is optimized for archive.php and archive-{$post_type}.php template files |
|
652 * for displaying the title of the post type. |
|
653 * |
|
654 * @since 3.1.0 |
|
655 * |
|
656 * @param string $prefix Optional. What to display before the title. |
|
657 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
|
658 * @return string|null Title when retrieving, null when displaying or failure. |
|
659 */ |
|
660 function post_type_archive_title( $prefix = '', $display = true ) { |
|
661 if ( ! is_post_type_archive() ) |
|
662 return; |
|
663 |
|
664 $post_type_obj = get_queried_object(); |
|
665 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); |
|
666 |
|
667 if ( $display ) |
|
668 echo $prefix . $title; |
|
669 else |
|
670 return $title; |
565 } |
671 } |
566 |
672 |
567 /** |
673 /** |
568 * Display or retrieve page title for category archive. |
674 * Display or retrieve page title for category archive. |
569 * |
675 * |
611 * |
706 * |
612 * @param string $prefix Optional. What to display before the title. |
707 * @param string $prefix Optional. What to display before the title. |
613 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
708 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
614 * @return string|null Title when retrieving, null when displaying or failure. |
709 * @return string|null Title when retrieving, null when displaying or failure. |
615 */ |
710 */ |
616 function single_tag_title($prefix = '', $display = true ) { |
711 function single_tag_title( $prefix = '', $display = true ) { |
617 if ( !is_tag() ) |
712 return single_term_title( $prefix, $display ); |
|
713 } |
|
714 |
|
715 /** |
|
716 * Display or retrieve page title for taxonomy term archive. |
|
717 * |
|
718 * Useful for taxonomy term template files for displaying the taxonomy term page title. |
|
719 * It has less overhead than {@link wp_title()}, because of its limited implementation. |
|
720 * |
|
721 * It does not support placing the separator after the title, but by leaving the |
|
722 * prefix parameter empty, you can set the title separator manually. The prefix |
|
723 * does not automatically place a space between the prefix, so if there should |
|
724 * be a space, the parameter value will need to have it at the end. |
|
725 * |
|
726 * @since 3.1.0 |
|
727 * |
|
728 * @param string $prefix Optional. What to display before the title. |
|
729 * @param bool $display Optional, default is true. Whether to display or retrieve title. |
|
730 * @return string|null Title when retrieving, null when displaying or failure. |
|
731 */ |
|
732 function single_term_title( $prefix = '', $display = true ) { |
|
733 $term = get_queried_object(); |
|
734 |
|
735 if ( !$term ) |
618 return; |
736 return; |
619 |
737 |
620 $tag_id = intval( get_query_var('tag_id') ); |
738 if ( is_category() ) |
621 |
739 $term_name = apply_filters( 'single_cat_title', $term->name ); |
622 if ( !empty($tag_id) ) { |
740 elseif ( is_tag() ) |
623 $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); |
741 $term_name = apply_filters( 'single_tag_title', $term->name ); |
624 if ( is_wp_error( $my_tag ) ) |
742 elseif ( is_tax() ) |
625 return false; |
743 $term_name = apply_filters( 'single_term_title', $term->name ); |
626 $my_tag_name = apply_filters('single_tag_title', $my_tag->name); |
744 else |
627 if ( !empty($my_tag_name) ) { |
745 return; |
628 if ( $display ) |
746 |
629 echo $prefix . $my_tag_name; |
747 if ( empty( $term_name ) ) |
630 else |
748 return; |
631 return $my_tag_name; |
749 |
632 } |
750 if ( $display ) |
633 } |
751 echo $prefix . $term_name; |
|
752 else |
|
753 return $term_name; |
634 } |
754 } |
635 |
755 |
636 /** |
756 /** |
637 * Display or retrieve page title for post archive based on date. |
757 * Display or retrieve page title for post archive based on date. |
638 * |
758 * |
795 $archive_week_start_date_format = get_option('date_format'); |
913 $archive_week_start_date_format = get_option('date_format'); |
796 $archive_week_end_date_format = get_option('date_format'); |
914 $archive_week_end_date_format = get_option('date_format'); |
797 } |
915 } |
798 |
916 |
799 //filters |
917 //filters |
800 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); |
918 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); |
801 $join = apply_filters('getarchives_join', "", $r); |
919 $join = apply_filters( 'getarchives_join', '', $r ); |
802 |
920 |
803 $output = ''; |
921 $output = ''; |
804 |
922 |
805 if ( 'monthly' == $type ) { |
923 if ( 'monthly' == $type ) { |
806 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; |
924 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; |
807 $key = md5($query); |
925 $key = md5($query); |
808 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
926 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
809 if ( !isset( $cache[ $key ] ) ) { |
927 if ( !isset( $cache[ $key ] ) ) { |
810 $arcresults = $wpdb->get_results($query); |
928 $arcresults = $wpdb->get_results($query); |
811 $cache[ $key ] = $arcresults; |
929 $cache[ $key ] = $arcresults; |
812 wp_cache_add( 'wp_get_archives', $cache, 'general' ); |
930 wp_cache_set( 'wp_get_archives', $cache, 'general' ); |
813 } else { |
931 } else { |
814 $arcresults = $cache[ $key ]; |
932 $arcresults = $cache[ $key ]; |
815 } |
933 } |
816 if ( $arcresults ) { |
934 if ( $arcresults ) { |
817 $afterafter = $after; |
935 $afterafter = $after; |
866 $after = ' ('.$arcresult->posts.')'.$afterafter; |
984 $after = ' ('.$arcresult->posts.')'.$afterafter; |
867 $output .= get_archives_link($url, $text, $format, $before, $after); |
985 $output .= get_archives_link($url, $text, $format, $before, $after); |
868 } |
986 } |
869 } |
987 } |
870 } elseif ( 'weekly' == $type ) { |
988 } elseif ( 'weekly' == $type ) { |
871 $start_of_week = get_option('start_of_week'); |
989 $week = _wp_mysql_week( '`post_date`' ); |
872 $query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit"; |
990 $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"; |
873 $key = md5($query); |
991 $key = md5($query); |
874 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
992 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
875 if ( !isset( $cache[ $key ] ) ) { |
993 if ( !isset( $cache[ $key ] ) ) { |
876 $arcresults = $wpdb->get_results($query); |
994 $arcresults = $wpdb->get_results($query); |
877 $cache[ $key ] = $arcresults; |
995 $cache[ $key ] = $arcresults; |
878 wp_cache_add( 'wp_get_archives', $cache, 'general' ); |
996 wp_cache_set( 'wp_get_archives', $cache, 'general' ); |
879 } else { |
997 } else { |
880 $arcresults = $cache[ $key ]; |
998 $arcresults = $cache[ $key ]; |
881 } |
999 } |
882 $arc_w_last = ''; |
1000 $arc_w_last = ''; |
883 $afterafter = $after; |
1001 $afterafter = $after; |
887 $arc_year = $arcresult->yr; |
1005 $arc_year = $arcresult->yr; |
888 $arc_w_last = $arcresult->week; |
1006 $arc_w_last = $arcresult->week; |
889 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week')); |
1007 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week')); |
890 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); |
1008 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); |
891 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); |
1009 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); |
892 $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); |
1010 $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $arcresult->week); |
893 $text = $arc_week_start . $archive_week_separator . $arc_week_end; |
1011 $text = $arc_week_start . $archive_week_separator . $arc_week_end; |
894 if ($show_post_count) |
1012 if ($show_post_count) |
895 $after = ' ('.$arcresult->posts.')'.$afterafter; |
1013 $after = ' ('.$arcresult->posts.')'.$afterafter; |
896 $output .= get_archives_link($url, $text, $format, $before, $after); |
1014 $output .= get_archives_link($url, $text, $format, $before, $after); |
897 } |
1015 } |
898 } |
1016 } |
899 } |
1017 } |
900 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { |
1018 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { |
901 $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC "; |
1019 $orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC '; |
902 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; |
1020 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; |
903 $key = md5($query); |
1021 $key = md5($query); |
904 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
1022 $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
905 if ( !isset( $cache[ $key ] ) ) { |
1023 if ( !isset( $cache[ $key ] ) ) { |
906 $arcresults = $wpdb->get_results($query); |
1024 $arcresults = $wpdb->get_results($query); |
907 $cache[ $key ] = $arcresults; |
1025 $cache[ $key ] = $arcresults; |
908 wp_cache_add( 'wp_get_archives', $cache, 'general' ); |
1026 wp_cache_set( 'wp_get_archives', $cache, 'general' ); |
909 } else { |
1027 } else { |
910 $arcresults = $cache[ $key ]; |
1028 $arcresults = $cache[ $key ]; |
911 } |
1029 } |
912 if ( $arcresults ) { |
1030 if ( $arcresults ) { |
913 foreach ( (array) $arcresults as $arcresult ) { |
1031 foreach ( (array) $arcresults as $arcresult ) { |
914 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { |
1032 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { |
915 $url = get_permalink($arcresult); |
1033 $url = get_permalink( $arcresult ); |
916 $arc_title = $arcresult->post_title; |
1034 if ( $arcresult->post_title ) |
917 if ( $arc_title ) |
1035 $text = strip_tags( apply_filters( 'the_title', $arcresult->post_title, $arcresult->ID ) ); |
918 $text = strip_tags(apply_filters('the_title', $arc_title)); |
|
919 else |
1036 else |
920 $text = $arcresult->ID; |
1037 $text = $arcresult->ID; |
921 $output .= get_archives_link($url, $text, $format, $before, $after); |
1038 $output .= get_archives_link($url, $text, $format, $before, $after); |
922 } |
1039 } |
923 } |
1040 } |
1004 $thisyear = gmdate('Y', current_time('timestamp')); |
1125 $thisyear = gmdate('Y', current_time('timestamp')); |
1005 $thismonth = gmdate('m', current_time('timestamp')); |
1126 $thismonth = gmdate('m', current_time('timestamp')); |
1006 } |
1127 } |
1007 |
1128 |
1008 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); |
1129 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); |
|
1130 $last_day = date('t', $unixmonth); |
1009 |
1131 |
1010 // Get the next and previous month and year with at least one post |
1132 // Get the next and previous month and year with at least one post |
1011 $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year |
1133 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year |
1012 FROM $wpdb->posts |
1134 FROM $wpdb->posts |
1013 WHERE post_date < '$thisyear-$thismonth-01' |
1135 WHERE post_date < '$thisyear-$thismonth-01' |
1014 AND post_type = 'post' AND post_status = 'publish' |
1136 AND post_type = 'post' AND post_status = 'publish' |
1015 ORDER BY post_date DESC |
1137 ORDER BY post_date DESC |
1016 LIMIT 1"); |
1138 LIMIT 1"); |
1017 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year |
1139 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year |
1018 FROM $wpdb->posts |
1140 FROM $wpdb->posts |
1019 WHERE post_date > '$thisyear-$thismonth-01' |
1141 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' |
1020 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) |
|
1021 AND post_type = 'post' AND post_status = 'publish' |
1142 AND post_type = 'post' AND post_status = 'publish' |
1022 ORDER BY post_date ASC |
1143 ORDER BY post_date ASC |
1023 LIMIT 1"); |
1144 LIMIT 1"); |
1024 |
1145 |
1025 /* translators: Calendar caption: 1: month name, 2: 4-digit year */ |
1146 /* translators: Calendar caption: 1: month name, 2: 4-digit year */ |
1026 $calendar_caption = _x('%1$s %2$s', 'calendar caption'); |
1147 $calendar_caption = _x('%1$s %2$s', 'calendar caption'); |
1027 echo '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '"> |
1148 $calendar_output = '<table id="wp-calendar"> |
1028 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> |
1149 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> |
1029 <thead> |
1150 <thead> |
1030 <tr>'; |
1151 <tr>'; |
1031 |
1152 |
1032 $myweek = array(); |
1153 $myweek = array(); |
1036 } |
1157 } |
1037 |
1158 |
1038 foreach ( $myweek as $wd ) { |
1159 foreach ( $myweek as $wd ) { |
1039 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); |
1160 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); |
1040 $wd = esc_attr($wd); |
1161 $wd = esc_attr($wd); |
1041 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; |
1162 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; |
1042 } |
1163 } |
1043 |
1164 |
1044 echo ' |
1165 $calendar_output .= ' |
1045 </tr> |
1166 </tr> |
1046 </thead> |
1167 </thead> |
1047 |
1168 |
1048 <tfoot> |
1169 <tfoot> |
1049 <tr>'; |
1170 <tr>'; |
1050 |
1171 |
1051 if ( $previous ) { |
1172 if ( $previous ) { |
1052 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . |
1173 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; |
1053 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), |
|
1054 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; |
|
1055 } else { |
1174 } else { |
1056 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; |
1175 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; |
1057 } |
1176 } |
1058 |
1177 |
1059 echo "\n\t\t".'<td class="pad"> </td>'; |
1178 $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; |
1060 |
1179 |
1061 if ( $next ) { |
1180 if ( $next ) { |
1062 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . |
1181 $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)) . ' »</a></td>'; |
1063 get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month) , |
|
1064 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; |
|
1065 } else { |
1182 } else { |
1066 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; |
1183 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; |
1067 } |
1184 } |
1068 |
1185 |
1069 echo ' |
1186 $calendar_output .= ' |
1070 </tr> |
1187 </tr> |
1071 </tfoot> |
1188 </tfoot> |
1072 |
1189 |
1073 <tbody> |
1190 <tbody> |
1074 <tr>'; |
1191 <tr>'; |
1075 |
1192 |
1076 // Get days with posts |
1193 // Get days with posts |
1077 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) |
1194 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) |
1078 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' |
1195 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' |
1079 AND YEAR(post_date) = '$thisyear' |
|
1080 AND post_type = 'post' AND post_status = 'publish' |
1196 AND post_type = 'post' AND post_status = 'publish' |
1081 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); |
1197 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); |
1082 if ( $dayswithposts ) { |
1198 if ( $dayswithposts ) { |
1083 foreach ( (array) $dayswithposts as $daywith ) { |
1199 foreach ( (array) $dayswithposts as $daywith ) { |
1084 $daywithpost[] = $daywith[0]; |
1200 $daywithpost[] = $daywith[0]; |
1085 } |
1201 } |
1086 } else { |
1202 } else { |
1087 $daywithpost = array(); |
1203 $daywithpost = array(); |
1088 } |
1204 } |
1089 |
1205 |
1090 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) |
1206 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) |
1091 $ak_title_separator = "\n"; |
1207 $ak_title_separator = "\n"; |
1092 else |
1208 else |
1093 $ak_title_separator = ', '; |
1209 $ak_title_separator = ', '; |
1094 |
1210 |
1095 $ak_titles_for_day = array(); |
1211 $ak_titles_for_day = array(); |
1096 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " |
1212 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " |
1097 ."FROM $wpdb->posts " |
1213 ."FROM $wpdb->posts " |
1098 ."WHERE YEAR(post_date) = '$thisyear' " |
1214 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " |
1099 ."AND MONTH(post_date) = '$thismonth' " |
1215 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " |
1100 ."AND post_date < '".current_time('mysql')."' " |
|
1101 ."AND post_type = 'post' AND post_status = 'publish'" |
1216 ."AND post_type = 'post' AND post_status = 'publish'" |
1102 ); |
1217 ); |
1103 if ( $ak_post_titles ) { |
1218 if ( $ak_post_titles ) { |
1104 foreach ( (array) $ak_post_titles as $ak_post_title ) { |
1219 foreach ( (array) $ak_post_titles as $ak_post_title ) { |
1105 |
1220 |
1106 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title ) ); |
1221 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) ); |
1107 |
1222 |
1108 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) |
1223 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) |
1109 $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; |
1224 $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; |
1110 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one |
1225 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one |
1111 $ak_titles_for_day["$ak_post_title->dom"] = $post_title; |
1226 $ak_titles_for_day["$ak_post_title->dom"] = $post_title; |
1112 else |
1227 else |
1113 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; |
1228 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; |
1114 } |
1229 } |
1115 } |
1230 } |
1116 |
1231 |
1117 |
|
1118 // See how much we should pad in the beginning |
1232 // See how much we should pad in the beginning |
1119 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); |
1233 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); |
1120 if ( 0 != $pad ) |
1234 if ( 0 != $pad ) |
1121 echo "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; |
1235 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; |
1122 |
1236 |
1123 $daysinmonth = intval(date('t', $unixmonth)); |
1237 $daysinmonth = intval(date('t', $unixmonth)); |
1124 for ( $day = 1; $day <= $daysinmonth; ++$day ) { |
1238 for ( $day = 1; $day <= $daysinmonth; ++$day ) { |
1125 if ( isset($newrow) && $newrow ) |
1239 if ( isset($newrow) && $newrow ) |
1126 echo "\n\t</tr>\n\t<tr>\n\t\t"; |
1240 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; |
1127 $newrow = false; |
1241 $newrow = false; |
1128 |
1242 |
1129 if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) |
1243 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) ) |
1130 echo '<td id="today">'; |
1244 $calendar_output .= '<td id="today">'; |
1131 else |
1245 else |
1132 echo '<td>'; |
1246 $calendar_output .= '<td>'; |
1133 |
1247 |
1134 if ( in_array($day, $daywithpost) ) // any posts today? |
1248 if ( in_array($day, $daywithpost) ) // any posts today? |
1135 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>"; |
1249 $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>"; |
1136 else |
1250 else |
1137 echo $day; |
1251 $calendar_output .= $day; |
1138 echo '</td>'; |
1252 $calendar_output .= '</td>'; |
1139 |
1253 |
1140 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) |
1254 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) |
1141 $newrow = true; |
1255 $newrow = true; |
1142 } |
1256 } |
1143 |
1257 |
1144 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); |
1258 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); |
1145 if ( $pad != 0 && $pad != 7 ) |
1259 if ( $pad != 0 && $pad != 7 ) |
1146 echo "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; |
1260 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; |
1147 |
1261 |
1148 echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
1262 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; |
1149 |
1263 |
1150 $output = ob_get_contents(); |
1264 $cache[ $key ] = $calendar_output; |
1151 ob_end_clean(); |
|
1152 echo $output; |
|
1153 $cache[ $key ] = $output; |
|
1154 wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
1265 wp_cache_set( 'get_calendar', $cache, 'calendar' ); |
|
1266 |
|
1267 if ( $echo ) |
|
1268 echo apply_filters( 'get_calendar', $calendar_output ); |
|
1269 else |
|
1270 return apply_filters( 'get_calendar', $calendar_output ); |
|
1271 |
1155 } |
1272 } |
1156 |
1273 |
1157 /** |
1274 /** |
1158 * Purge the cached results of get_calendar. |
1275 * Purge the cached results of get_calendar. |
1159 * |
1276 * |
1205 global $post; |
1322 global $post; |
1206 echo mysql2date('Y-m-d', $post->post_date, false); |
1323 echo mysql2date('Y-m-d', $post->post_date, false); |
1207 } |
1324 } |
1208 |
1325 |
1209 /** |
1326 /** |
1210 * Display or Retrieve the date the post was written. |
1327 * Display or Retrieve the date the current $post was written (once per date) |
1211 * |
1328 * |
1212 * Will only output the date if the current post's date is different from the |
1329 * Will only output the date if the current post's date is different from the |
1213 * previous one output. |
1330 * previous one output. |
1214 * |
1331 * |
|
1332 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the |
|
1333 * function is called several times for each post. |
|
1334 * |
|
1335 * HTML output can be filtered with 'the_date'. |
|
1336 * Date string output can be filtered with 'get_the_date'. |
|
1337 * |
1215 * @since 0.71 |
1338 * @since 0.71 |
1216 * |
1339 * @uses get_the_date() |
1217 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. |
1340 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. |
1218 * @param string $before Optional. Output before the date. |
1341 * @param string $before Optional. Output before the date. |
1219 * @param string $after Optional. Output after the date. |
1342 * @param string $after Optional. Output after the date. |
1220 * @param bool $echo Optional, default is display. Whether to echo the date or return it. |
1343 * @param bool $echo Optional, default is display. Whether to echo the date or return it. |
1221 * @return string|null Null if displaying, string if retrieving. |
1344 * @return string|null Null if displaying, string if retrieving. |
1222 */ |
1345 */ |
1223 function the_date($d='', $before='', $after='', $echo = true) { |
1346 function the_date( $d = '', $before = '', $after = '', $echo = true ) { |
1224 global $post, $day, $previousday; |
1347 global $currentday, $previousday; |
1225 $the_date = ''; |
1348 $the_date = ''; |
1226 if ( $day != $previousday ) { |
1349 if ( $currentday != $previousday ) { |
1227 $the_date .= $before; |
1350 $the_date .= $before; |
1228 if ( $d=='' ) |
1351 $the_date .= get_the_date( $d ); |
1229 $the_date .= mysql2date(get_option('date_format'), $post->post_date); |
1352 $the_date .= $after; |
|
1353 $previousday = $currentday; |
|
1354 |
|
1355 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); |
|
1356 |
|
1357 if ( $echo ) |
|
1358 echo $the_date; |
1230 else |
1359 else |
1231 $the_date .= mysql2date($d, $post->post_date); |
1360 return $the_date; |
1232 $the_date .= $after; |
1361 } |
1233 $previousday = $day; |
1362 |
1234 |
1363 return null; |
1235 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); |
1364 } |
|
1365 |
|
1366 /** |
|
1367 * Retrieve the date the current $post was written. |
|
1368 * |
|
1369 * Unlike the_date() this function will always return the date. |
|
1370 * Modify output with 'get_the_date' filter. |
|
1371 * |
|
1372 * @since 3.0.0 |
|
1373 * |
|
1374 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. |
|
1375 * @return string|null Null if displaying, string if retrieving. |
|
1376 */ |
|
1377 function get_the_date( $d = '' ) { |
|
1378 global $post; |
|
1379 $the_date = ''; |
|
1380 |
|
1381 if ( '' == $d ) |
|
1382 $the_date .= mysql2date(get_option('date_format'), $post->post_date); |
|
1383 else |
|
1384 $the_date .= mysql2date($d, $post->post_date); |
|
1385 |
|
1386 return apply_filters('get_the_date', $the_date, $d); |
|
1387 } |
|
1388 |
|
1389 /** |
|
1390 * Display the date on which the post was last modified. |
|
1391 * |
|
1392 * @since 2.1.0 |
|
1393 * |
|
1394 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. |
|
1395 * @param string $before Optional. Output before the date. |
|
1396 * @param string $after Optional. Output after the date. |
|
1397 * @param bool $echo Optional, default is display. Whether to echo the date or return it. |
|
1398 * @return string|null Null if displaying, string if retrieving. |
|
1399 */ |
|
1400 function the_modified_date($d = '', $before='', $after='', $echo = true) { |
|
1401 |
|
1402 $the_modified_date = $before . get_the_modified_date($d) . $after; |
|
1403 $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after); |
|
1404 |
1236 if ( $echo ) |
1405 if ( $echo ) |
1237 echo $the_date; |
1406 echo $the_modified_date; |
1238 else |
1407 else |
1239 return $the_date; |
1408 return $the_modified_date; |
1240 } |
1409 |
1241 } |
|
1242 |
|
1243 /** |
|
1244 * Display the date on which the post was last modified. |
|
1245 * |
|
1246 * @since 2.1.0 |
|
1247 * |
|
1248 * @param string $d Optional. PHP date format. |
|
1249 * @return string |
|
1250 */ |
|
1251 function the_modified_date($d = '') { |
|
1252 echo apply_filters('the_modified_date', get_the_modified_date($d), $d); |
|
1253 } |
1410 } |
1254 |
1411 |
1255 /** |
1412 /** |
1256 * Retrieve the date on which the post was last modified. |
1413 * Retrieve the date on which the post was last modified. |
1257 * |
1414 * |
1391 * Will only output the weekday if the current post's weekday is different from |
1548 * Will only output the weekday if the current post's weekday is different from |
1392 * the previous one output. |
1549 * the previous one output. |
1393 * |
1550 * |
1394 * @since 0.71 |
1551 * @since 0.71 |
1395 * |
1552 * |
1396 * @param string $before output before the date. |
1553 * @param string $before Optional Output before the date. |
1397 * @param string $after output after the date. |
1554 * @param string $after Optional Output after the date. |
1398 */ |
1555 */ |
1399 function the_weekday_date($before='',$after='') { |
1556 function the_weekday_date($before='',$after='') { |
1400 global $wp_locale, $post, $day, $previousweekday; |
1557 global $wp_locale, $post, $day, $previousweekday; |
1401 $the_weekday_date = ''; |
1558 $the_weekday_date = ''; |
1402 if ( $day != $previousweekday ) { |
1559 if ( $currentday != $previousweekday ) { |
1403 $the_weekday_date .= $before; |
1560 $the_weekday_date .= $before; |
1404 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false)); |
1561 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false)); |
1405 $the_weekday_date .= $after; |
1562 $the_weekday_date .= $after; |
1406 $previousweekday = $day; |
1563 $previousweekday = $currentday; |
1407 } |
1564 } |
1408 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); |
1565 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); |
1409 echo $the_weekday_date; |
1566 echo $the_weekday_date; |
1410 } |
1567 } |
1411 |
1568 |
1492 ); |
1636 ); |
1493 |
1637 |
1494 $args = wp_parse_args( $args, $defaults ); |
1638 $args = wp_parse_args( $args, $defaults ); |
1495 |
1639 |
1496 if ( is_single() || is_page() ) { |
1640 if ( is_single() || is_page() ) { |
1497 $post = &get_post( $id = 0 ); |
1641 $id = 0; |
|
1642 $post = &get_post( $id ); |
1498 |
1643 |
1499 if ( comments_open() || pings_open() || $post->comment_count > 0 ) { |
1644 if ( comments_open() || pings_open() || $post->comment_count > 0 ) { |
1500 $title = esc_attr(sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) )); |
1645 $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ); |
1501 $href = get_post_comments_feed_link( $post->ID ); |
1646 $href = get_post_comments_feed_link( $post->ID ); |
1502 } |
1647 } |
1503 } elseif ( is_category() ) { |
1648 } elseif ( is_category() ) { |
1504 $cat_id = intval( get_query_var('cat') ); |
1649 $term = get_queried_object(); |
1505 |
1650 |
1506 $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], get_cat_name( $cat_id ) )); |
1651 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); |
1507 $href = get_category_feed_link( $cat_id ); |
1652 $href = get_category_feed_link( $term->term_id ); |
1508 } elseif ( is_tag() ) { |
1653 } elseif ( is_tag() ) { |
1509 $tag_id = intval( get_query_var('tag_id') ); |
1654 $term = get_queried_object(); |
1510 $tag = get_tag( $tag_id ); |
1655 |
1511 |
1656 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); |
1512 $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name )); |
1657 $href = get_tag_feed_link( $term->term_id ); |
1513 $href = get_tag_feed_link( $tag_id ); |
|
1514 } elseif ( is_author() ) { |
1658 } elseif ( is_author() ) { |
1515 $author_id = intval( get_query_var('author') ); |
1659 $author_id = intval( get_query_var('author') ); |
1516 |
1660 |
1517 $title = esc_attr(sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) )); |
1661 $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); |
1518 $href = get_author_feed_link( $author_id ); |
1662 $href = get_author_feed_link( $author_id ); |
1519 } elseif ( is_search() ) { |
1663 } elseif ( is_search() ) { |
1520 $title = esc_attr(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query() )); |
1664 $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); |
1521 $href = get_search_feed_link(); |
1665 $href = get_search_feed_link(); |
1522 } |
1666 } |
1523 |
1667 |
1524 if ( isset($title) && isset($href) ) |
1668 if ( isset($title) && isset($href) ) |
1525 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n"; |
1669 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n"; |
1526 } |
1670 } |
1527 |
1671 |
1528 /** |
1672 /** |
1529 * Display the link to the Really Simple Discovery service endpoint. |
1673 * Display the link to the Really Simple Discovery service endpoint. |
1530 * |
1674 * |
1548 |
1692 |
1549 /** |
1693 /** |
1550 * Display a noindex meta tag if required by the blog configuration. |
1694 * Display a noindex meta tag if required by the blog configuration. |
1551 * |
1695 * |
1552 * If a blog is marked as not being public then the noindex meta tag will be |
1696 * If a blog is marked as not being public then the noindex meta tag will be |
1553 * output to tell web robots not to index the page content. |
1697 * output to tell web robots not to index the page content. Add this to the wp_head action. |
|
1698 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' ); |
|
1699 * |
|
1700 * @see wp_no_robots |
1554 * |
1701 * |
1555 * @since 2.1.0 |
1702 * @since 2.1.0 |
1556 */ |
1703 */ |
1557 function noindex() { |
1704 function noindex() { |
1558 // If the blog is not public, tell robots to go away. |
1705 // If the blog is not public, tell robots to go away. |
1559 if ( '0' == get_option('blog_public') ) |
1706 if ( '0' == get_option('blog_public') ) |
1560 echo "<meta name='robots' content='noindex,nofollow' />\n"; |
1707 wp_no_robots(); |
|
1708 } |
|
1709 |
|
1710 /** |
|
1711 * Display a noindex meta tag. |
|
1712 * |
|
1713 * Outputs a noindex meta tag that tells web robots not to index the page content. |
|
1714 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' ); |
|
1715 * |
|
1716 * @since 3.3.0 |
|
1717 */ |
|
1718 function wp_no_robots() { |
|
1719 echo "<meta name='robots' content='noindex,nofollow' />\n"; |
1561 } |
1720 } |
1562 |
1721 |
1563 /** |
1722 /** |
1564 * Determine if TinyMCE is available. |
1723 * Determine if TinyMCE is available. |
1565 * |
1724 * |
1566 * Checks to see if the user has deleted the tinymce files to slim down there WordPress install. |
1725 * Checks to see if the user has deleted the tinymce files to slim down there WordPress install. |
1567 * |
1726 * |
1568 * @since 2.1.0 |
1727 * @since 2.1.0 |
1569 * |
1728 * |
1570 * @return bool Whether of not TinyMCE exists. |
1729 * @return bool Whether TinyMCE exists. |
1571 */ |
1730 */ |
1572 function rich_edit_exists() { |
1731 function rich_edit_exists() { |
1573 global $wp_rich_edit_exists; |
1732 global $wp_rich_edit_exists; |
1574 if ( !isset($wp_rich_edit_exists) ) |
1733 if ( !isset($wp_rich_edit_exists) ) |
1575 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js'); |
1734 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js'); |
1576 return $wp_rich_edit_exists; |
1735 return $wp_rich_edit_exists; |
1577 } |
1736 } |
1578 |
1737 |
1579 /** |
1738 /** |
1580 * Whether or not the user should have a WYSIWIG editor. |
1739 * Whether the user should have a WYSIWIG editor. |
1581 * |
1740 * |
1582 * Checks that the user requires a WYSIWIG editor and that the editor is |
1741 * Checks that the user requires a WYSIWIG editor and that the editor is |
1583 * supported in the users browser. |
1742 * supported in the users browser. |
1584 * |
1743 * |
1585 * @since 2.0.0 |
1744 * @since 2.0.0 |
1586 * |
1745 * |
1587 * @return bool |
1746 * @return bool |
1588 */ |
1747 */ |
1589 function user_can_richedit() { |
1748 function user_can_richedit() { |
1590 global $wp_rich_edit, $pagenow; |
1749 global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE; |
1591 |
1750 |
1592 if ( !isset( $wp_rich_edit) ) { |
1751 if ( !isset($wp_rich_edit) ) { |
1593 if ( get_user_option( 'rich_editing' ) == 'true' && |
1752 $wp_rich_edit = false; |
1594 ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || |
1753 |
1595 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) |
1754 if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users |
1596 && 'comment.php' != $pagenow ) { |
1755 if ( $is_safari ) { |
1597 $wp_rich_edit = true; |
1756 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); |
1598 } else { |
1757 } elseif ( $is_gecko || $is_opera || $is_chrome || $is_IE ) { |
1599 $wp_rich_edit = false; |
1758 $wp_rich_edit = true; |
|
1759 } |
1600 } |
1760 } |
1601 } |
1761 } |
1602 |
1762 |
1603 return apply_filters('user_can_richedit', $wp_rich_edit); |
1763 return apply_filters('user_can_richedit', $wp_rich_edit); |
1604 } |
1764 } |
1621 } |
1781 } |
1622 return apply_filters( 'wp_default_editor', $r ); // filter |
1782 return apply_filters( 'wp_default_editor', $r ); // filter |
1623 } |
1783 } |
1624 |
1784 |
1625 /** |
1785 /** |
1626 * Display visual editor forms: TinyMCE, or HTML, or both. |
1786 * Renders an editor. |
1627 * |
1787 * |
1628 * The amount of rows the text area will have for the content has to be between |
1788 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. |
1629 * 3 and 100 or will default at 12. There is only one option used for all users, |
1789 * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144. |
1630 * named 'default_post_edit_rows'. |
1790 * |
1631 * |
1791 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason |
1632 * If the user can not use the rich editor (TinyMCE), then the switch button |
1792 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used. |
1633 * will not be displayed. |
1793 * On the post edit screen several actions can be used to include additional editors |
1634 * |
1794 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'. |
1635 * @since 2.1.0 |
1795 * See http://core.trac.wordpress.org/ticket/19173 for more information. |
1636 * |
1796 * |
1637 * @param string $content Textarea content. |
1797 * @see wp-includes/class-wp-editor.php |
1638 * @param string $id HTML ID attribute value. |
1798 * @since 3.3.0 |
1639 * @param string $prev_id HTML ID name for switching back and forth between visual editors. |
1799 * |
1640 * @param bool $media_buttons Optional, default is true. Whether to display media buttons. |
1800 * @param string $content Initial content for the editor. |
1641 * @param int $tab_index Optional, default is 2. Tabindex for textarea element. |
1801 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/. |
1642 */ |
1802 * @param array $settings See _WP_Editors::editor(). |
1643 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) { |
1803 */ |
1644 $rows = get_option('default_post_edit_rows'); |
1804 function wp_editor( $content, $editor_id, $settings = array() ) { |
1645 if (($rows < 3) || ($rows > 100)) |
1805 if ( ! class_exists( '_WP_Editors' ) ) |
1646 $rows = 12; |
1806 require( ABSPATH . WPINC . '/class-wp-editor.php' ); |
1647 |
1807 |
1648 if ( !current_user_can( 'upload_files' ) ) |
1808 _WP_Editors::editor($content, $editor_id, $settings); |
1649 $media_buttons = false; |
|
1650 |
|
1651 $richedit = user_can_richedit(); |
|
1652 $class = ''; |
|
1653 |
|
1654 if ( $richedit || $media_buttons ) { ?> |
|
1655 <div id="editor-toolbar"> |
|
1656 <?php |
|
1657 if ( $richedit ) { |
|
1658 $wp_default_editor = wp_default_editor(); ?> |
|
1659 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div> |
|
1660 <?php if ( 'html' == $wp_default_editor ) { |
|
1661 add_filter('the_editor_content', 'wp_htmledit_pre'); ?> |
|
1662 <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a> |
|
1663 <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a> |
|
1664 <?php } else { |
|
1665 $class = " class='theEditor'"; |
|
1666 add_filter('the_editor_content', 'wp_richedit_pre'); ?> |
|
1667 <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a> |
|
1668 <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a> |
|
1669 <?php } |
|
1670 } |
|
1671 |
|
1672 if ( $media_buttons ) { ?> |
|
1673 <div id="media-buttons" class="hide-if-no-js"> |
|
1674 <?php do_action( 'media_buttons' ); ?> |
|
1675 </div> |
|
1676 <?php |
|
1677 } ?> |
|
1678 </div> |
|
1679 <?php |
|
1680 } |
|
1681 ?> |
|
1682 <div id="quicktags"><?php |
|
1683 wp_print_scripts( 'quicktags' ); ?> |
|
1684 <script type="text/javascript">edToolbar()</script> |
|
1685 </div> |
|
1686 |
|
1687 <?php |
|
1688 $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n"); |
|
1689 $the_editor_content = apply_filters('the_editor_content', $content); |
|
1690 |
|
1691 printf($the_editor, $the_editor_content); |
|
1692 |
|
1693 ?> |
|
1694 <script type="text/javascript"> |
|
1695 edCanvas = document.getElementById('<?php echo $id; ?>'); |
|
1696 </script> |
|
1697 <?php |
|
1698 } |
1809 } |
1699 |
1810 |
1700 /** |
1811 /** |
1701 * Retrieve the contents of the search WordPress query variable. |
1812 * Retrieve the contents of the search WordPress query variable. |
1702 * |
|
1703 * @since 2.3.0 |
|
1704 * |
|
1705 * @return string |
|
1706 */ |
|
1707 function get_search_query() { |
|
1708 return apply_filters( 'get_search_query', get_query_var( 's' ) ); |
|
1709 } |
|
1710 |
|
1711 /** |
|
1712 * Display the contents of the search query variable. |
|
1713 * |
1813 * |
1714 * The search query string is passed through {@link esc_attr()} |
1814 * The search query string is passed through {@link esc_attr()} |
1715 * to ensure that it is safe for placing in an html attribute. |
1815 * to ensure that it is safe for placing in an html attribute. |
1716 * |
1816 * |
1717 * @uses attr |
1817 * @since 2.3.0 |
|
1818 * @uses esc_attr() |
|
1819 * |
|
1820 * @param bool $escaped Whether the result is escaped. Default true. |
|
1821 * Only use when you are later escaping it. Do not use unescaped. |
|
1822 * @return string |
|
1823 */ |
|
1824 function get_search_query( $escaped = true ) { |
|
1825 $query = apply_filters( 'get_search_query', get_query_var( 's' ) ); |
|
1826 if ( $escaped ) |
|
1827 $query = esc_attr( $query ); |
|
1828 return $query; |
|
1829 } |
|
1830 |
|
1831 /** |
|
1832 * Display the contents of the search query variable. |
|
1833 * |
|
1834 * The search query string is passed through {@link esc_attr()} |
|
1835 * to ensure that it is safe for placing in an html attribute. |
|
1836 * |
|
1837 * @uses esc_attr() |
1718 * @since 2.1.0 |
1838 * @since 2.1.0 |
1719 */ |
1839 */ |
1720 function the_search_query() { |
1840 function the_search_query() { |
1721 echo esc_attr( apply_filters( 'the_search_query', get_search_query() ) ); |
1841 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); |
1722 } |
1842 } |
1723 |
1843 |
1724 /** |
1844 /** |
1725 * Display the language attributes for the html tag. |
1845 * Display the language attributes for the html tag. |
1726 * |
1846 * |
1847 $link = str_replace('%_%', 1 == $n ? '' : $format, $base); |
1967 $link = str_replace('%_%', 1 == $n ? '' : $format, $base); |
1848 $link = str_replace('%#%', $n, $link); |
1968 $link = str_replace('%#%', $n, $link); |
1849 if ( $add_args ) |
1969 if ( $add_args ) |
1850 $link = add_query_arg( $add_args, $link ); |
1970 $link = add_query_arg( $add_args, $link ); |
1851 $link .= $add_fragment; |
1971 $link .= $add_fragment; |
1852 $page_links[] = "<a class='page-numbers' href='" . esc_url($link) . "'>$n_display</a>"; |
1972 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>"; |
1853 $dots = true; |
1973 $dots = true; |
1854 elseif ( $dots && !$show_all ) : |
1974 elseif ( $dots && !$show_all ) : |
1855 $page_links[] = "<span class='page-numbers dots'>...</span>"; |
1975 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; |
1856 $dots = false; |
1976 $dots = false; |
1857 endif; |
1977 endif; |
1858 endif; |
1978 endif; |
1859 endfor; |
1979 endfor; |
1860 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) : |
1980 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) : |
1861 $link = str_replace('%_%', $format, $base); |
1981 $link = str_replace('%_%', $format, $base); |
1862 $link = str_replace('%#%', $current + 1, $link); |
1982 $link = str_replace('%#%', $current + 1, $link); |
1863 if ( $add_args ) |
1983 if ( $add_args ) |
1864 $link = add_query_arg( $add_args, $link ); |
1984 $link = add_query_arg( $add_args, $link ); |
1865 $link .= $add_fragment; |
1985 $link .= $add_fragment; |
1866 $page_links[] = "<a class='next page-numbers' href='" . esc_url($link) . "'>$next_text</a>"; |
1986 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>'; |
1867 endif; |
1987 endif; |
1868 switch ( $type ) : |
1988 switch ( $type ) : |
1869 case 'array' : |
1989 case 'array' : |
1870 return $page_links; |
1990 return $page_links; |
1871 break; |
1991 break; |
1893 * @since 2.5.0 |
2013 * @since 2.5.0 |
1894 * |
2014 * |
1895 * @param string $key The unique key for this theme. |
2015 * @param string $key The unique key for this theme. |
1896 * @param string $name The name of the theme. |
2016 * @param string $name The name of the theme. |
1897 * @param string $url The url of the css file containing the colour scheme. |
2017 * @param string $url The url of the css file containing the colour scheme. |
1898 * @param array @colors An array of CSS color definitions which are used to give the user a feel for the theme. |
2018 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. |
1899 */ |
2019 */ |
1900 function wp_admin_css_color($key, $name, $url, $colors = array()) { |
2020 function wp_admin_css_color($key, $name, $url, $colors = array()) { |
1901 global $_wp_admin_css_colors; |
2021 global $_wp_admin_css_colors; |
1902 |
2022 |
1903 if ( !isset($_wp_admin_css_colors) ) |
2023 if ( !isset($_wp_admin_css_colors) ) |
1904 $_wp_admin_css_colors = array(); |
2024 $_wp_admin_css_colors = array(); |
1905 |
2025 |
1906 $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors); |
2026 $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors); |
|
2027 } |
|
2028 |
|
2029 /** |
|
2030 * Registers the default Admin color schemes |
|
2031 * |
|
2032 * @since 3.0.0 |
|
2033 */ |
|
2034 function register_admin_color_schemes() { |
|
2035 wp_admin_css_color( 'classic', _x( 'Blue', 'admin color scheme' ), admin_url( 'css/colors-classic.css' ), |
|
2036 array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) ); |
|
2037 wp_admin_css_color( 'fresh', _x( 'Gray', 'admin color scheme' ), admin_url( 'css/colors-fresh.css' ), |
|
2038 array( '#555', '#a0a0a0', '#ccc', '#f1f1f1' ) ); |
1907 } |
2039 } |
1908 |
2040 |
1909 /** |
2041 /** |
1910 * Display the URL of a WordPress admin CSS file. |
2042 * Display the URL of a WordPress admin CSS file. |
1911 * |
2043 * |
1942 * |
2074 * |
1943 * @package WordPress |
2075 * @package WordPress |
1944 * @since 2.3.0 |
2076 * @since 2.3.0 |
1945 * @uses $wp_styles WordPress Styles Object |
2077 * @uses $wp_styles WordPress Styles Object |
1946 * |
2078 * |
1947 * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/ |
2079 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative |
1948 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. |
2080 * to wp-admin/. Defaults to 'wp-admin'. |
|
2081 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. |
1949 */ |
2082 */ |
1950 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { |
2083 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { |
1951 global $wp_styles; |
2084 global $wp_styles; |
1952 if ( !is_a($wp_styles, 'WP_Styles') ) |
2085 if ( !is_a($wp_styles, 'WP_Styles') ) |
1953 $wp_styles = new WP_Styles(); |
2086 $wp_styles = new WP_Styles(); |
1954 |
2087 |
1955 // For backward compatibility |
2088 // For backward compatibility |
1956 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; |
2089 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; |
1957 |
2090 |
1958 if ( $wp_styles->query( $handle ) ) { |
2091 if ( $wp_styles->query( $handle ) ) { |
1959 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately |
2092 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately |
1960 wp_print_styles( $handle ); |
2093 wp_print_styles( $handle ); |
1961 else // Add to style queue |
2094 else // Add to style queue |
1962 wp_enqueue_style( $handle ); |
2095 wp_enqueue_style( $handle ); |
1963 return; |
2096 return; |
1964 } |
2097 } |
1965 |
2098 |
1966 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file ); |
2099 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file ); |
1967 if ( 'rtl' == get_bloginfo( 'text_direction' ) ) |
2100 if ( function_exists( 'is_rtl' ) && is_rtl() ) |
1968 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" ); |
2101 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" ); |
1969 } |
2102 } |
1970 |
2103 |
1971 /** |
2104 /** |
1972 * Enqueues the default ThickBox js and css. |
2105 * Enqueues the default ThickBox js and css. |
1973 * |
2106 * |
1974 * If any of the settings need to be changed, this can be done with another js |
2107 * If any of the settings need to be changed, this can be done with another js |
1975 * file similar to media-upload.js and theme-preview.js. That file should |
2108 * file similar to media-upload.js. That file should |
1976 * require array('thickbox') to ensure it is loaded after. |
2109 * require array('thickbox') to ensure it is loaded after. |
1977 * |
2110 * |
1978 * @since 2.5.0 |
2111 * @since 2.5.0 |
1979 */ |
2112 */ |
1980 function add_thickbox() { |
2113 function add_thickbox() { |
1981 wp_enqueue_script( 'thickbox' ); |
2114 wp_enqueue_script( 'thickbox' ); |
1982 wp_enqueue_style( 'thickbox' ); |
2115 wp_enqueue_style( 'thickbox' ); |
|
2116 |
|
2117 if ( is_network_admin() ) |
|
2118 add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); |
1983 } |
2119 } |
1984 |
2120 |
1985 /** |
2121 /** |
1986 * Display the XHTML generator that is generated on the wp_head hook. |
2122 * Display the XHTML generator that is generated on the wp_head hook. |
1987 * |
2123 * |
2038 break; |
2200 break; |
2039 case 'comment': |
2201 case 'comment': |
2040 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->'; |
2202 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->'; |
2041 break; |
2203 break; |
2042 case 'export': |
2204 case 'export': |
2043 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '"-->'; |
2205 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->'; |
2044 break; |
2206 break; |
2045 } |
2207 } |
2046 return apply_filters( "get_the_generator_{$type}", $gen, $type ); |
2208 return apply_filters( "get_the_generator_{$type}", $gen, $type ); |
2047 } |
2209 } |
2048 |
2210 |
2049 ?> |
2211 /** |
|
2212 * Outputs the html checked attribute. |
|
2213 * |
|
2214 * Compares the first two arguments and if identical marks as checked |
|
2215 * |
|
2216 * @since 1.0.0 |
|
2217 * |
|
2218 * @param mixed $checked One of the values to compare |
|
2219 * @param mixed $current (true) The other value to compare if not just true |
|
2220 * @param bool $echo Whether to echo or just return the string |
|
2221 * @return string html attribute or empty string |
|
2222 */ |
|
2223 function checked( $checked, $current = true, $echo = true ) { |
|
2224 return __checked_selected_helper( $checked, $current, $echo, 'checked' ); |
|
2225 } |
|
2226 |
|
2227 /** |
|
2228 * Outputs the html selected attribute. |
|
2229 * |
|
2230 * Compares the first two arguments and if identical marks as selected |
|
2231 * |
|
2232 * @since 1.0.0 |
|
2233 * |
|
2234 * @param mixed $selected 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 selected( $selected, $current = true, $echo = true ) { |
|
2240 return __checked_selected_helper( $selected, $current, $echo, 'selected' ); |
|
2241 } |
|
2242 |
|
2243 /** |
|
2244 * Outputs the html disabled attribute. |
|
2245 * |
|
2246 * Compares the first two arguments and if identical marks as disabled |
|
2247 * |
|
2248 * @since 3.0.0 |
|
2249 * |
|
2250 * @param mixed $disabled 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 disabled( $disabled, $current = true, $echo = true ) { |
|
2256 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' ); |
|
2257 } |
|
2258 |
|
2259 /** |
|
2260 * Private helper function for checked, selected, and disabled. |
|
2261 * |
|
2262 * Compares the first two arguments and if identical marks as $type |
|
2263 * |
|
2264 * @since 2.8.0 |
|
2265 * @access private |
|
2266 * |
|
2267 * @param any $helper One of the values to compare |
|
2268 * @param any $current (true) The other value to compare if not just true |
|
2269 * @param bool $echo Whether to echo or just return the string |
|
2270 * @param string $type The type of checked|selected|disabled we are doing |
|
2271 * @return string html attribute or empty string |
|
2272 */ |
|
2273 function __checked_selected_helper( $helper, $current, $echo, $type ) { |
|
2274 if ( (string) $helper === (string) $current ) |
|
2275 $result = " $type='$type'"; |
|
2276 else |
|
2277 $result = ''; |
|
2278 |
|
2279 if ( $echo ) |
|
2280 echo $result; |
|
2281 |
|
2282 return $result; |
|
2283 } |