Changes from branches/3.0/wp-includes/general-template.php at r15461 to trunk/wp-includes/general-template.php at r17187
- File:
-
- 1 edited
-
trunk/wp-includes/general-template.php (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r15461 r17187 152 152 do_action( 'get_search_form' ); 153 153 154 $search_form_template = locate_template( array('searchform.php'));154 $search_form_template = locate_template('searchform.php'); 155 155 if ( '' != $search_form_template ) { 156 156 require($search_form_template); … … 200 200 * Returns the URL that allows the user to log out of the site 201 201 * 202 * @since 2.7 202 * @since 2.7.0 203 203 * @uses wp_nonce_url() To protect against CSRF 204 204 * @uses site_url() To generate the log in URL … … 224 224 * Returns the URL that allows the user to log in to the site 225 225 * 226 * @since 2.7 226 * @since 2.7.0 227 227 * @uses site_url() To generate the log in URL 228 228 * @uses apply_filters() calls 'login_url' hook on final login url … … 272 272 $form = ' 273 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', '' ) . '274 ' . apply_filters( 'login_form_top', '', $args ) . ' 275 275 <p class="login-username"> 276 276 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label> … … 281 281 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" tabindex="20" /> 282 282 </p> 283 ' . apply_filters( 'login_form_middle', '' ) . '283 ' . apply_filters( 'login_form_middle', '', $args ) . ' 284 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 285 <p class="login-submit"> … … 287 287 <input type="hidden" name="redirect_to" value="' . esc_attr( $args['redirect'] ) . '" /> 288 288 </p> 289 ' . apply_filters( 'login_form_bottom', '' ) . '289 ' . apply_filters( 'login_form_bottom', '', $args ) . ' 290 290 </form>'; 291 291 … … 382 382 * The possible values for the 'show' parameter are listed below. 383 383 * <ol> 384 * <li><strong>url< strong> - Blog URI to homepage.</li>384 * <li><strong>url</strong> - Blog URI to homepage.</li> 385 385 * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li> 386 386 * <li><strong>description</strong> - Secondary title</li> … … 493 493 494 494 /** 495 * Retrieve the current blog id 496 * 497 * @since 3.1.0 498 * 499 * @return int Blog id 500 */ 501 function get_current_blog_id() { 502 global $blog_id; 503 return absint($blog_id); 504 } 505 506 /** 495 507 * Display or retrieve page title for all areas of blog. 496 508 * … … 515 527 */ 516 528 function wp_title($sep = '»', $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'); 529 global $wpdb, $wp_locale; 530 524 531 $m = get_query_var('m'); 525 532 $year = get_query_var('year'); … … 531 538 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary 532 539 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); 540 // If there is a post 541 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { 542 $title = single_post_title( '', false ); 543 } 544 545 // If there's a category or tag 546 if ( is_category() || is_tag() ) { 547 $title = single_term_title( '', false ); 548 } 549 550 // If there's a taxonomy 551 if ( is_tax() ) { 552 $term = get_queried_object(); 553 $tax = get_taxonomy( $term->taxonomy ); 554 $title = single_term_title( $tax->labels->name . $t_sep, false ); 557 555 } 558 556 559 557 // 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 }558 if ( is_author() ) { 559 $author = get_queried_object(); 560 $title = $author->display_name; 561 } 562 563 // If there's a post type archive 564 if ( is_post_type_archive() ) 565 $title = post_type_archive_title( '', false ); 568 566 569 567 // If there's a month 570 if ( !empty($m) ) {568 if ( is_archive() && !empty($m) ) { 571 569 $my_year = substr($m, 0, 4); 572 570 $my_month = $wp_locale->get_month(substr($m, 4, 2)); … … 575 573 } 576 574 577 if ( !empty($year) ) { 575 // If there's a year 576 if ( is_archive() && !empty($year) ) { 578 577 $title = $year; 579 578 if ( !empty($monthnum) ) … … 583 582 } 584 583 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 584 // If it's a search 601 585 if ( is_search() ) { 602 586 /* translators: 1: separator, 2: search phrase */ … … 604 588 } 605 589 590 // If it's a 404 page 606 591 if ( is_404() ) { 607 592 $title = __('Page not found'); … … 636 621 * 637 622 * 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 623 * 640 624 * It does not support placing the separator after the title, but by leaving the … … 644 628 * 645 629 * @since 0.71 646 * @uses $wpdb647 630 * 648 631 * @param string $prefix Optional. What to display before the title. … … 651 634 */ 652 635 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; 636 $_post = get_queried_object(); 659 637 660 638 if ( !isset($_post->post_title) ) … … 669 647 670 648 /** 649 * Display or retrieve title for a post type archive. 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; 671 } 672 673 /** 671 674 * Display or retrieve page title for category archive. 672 675 * … … 685 688 * @return string|null Title when retrieving, null when displaying or failure. 686 689 */ 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 } 690 function single_cat_title( $prefix = '', $display = true ) { 691 return single_term_title( $prefix, $display ); 704 692 } 705 693 … … 721 709 * @return string|null Title when retrieving, null when displaying or failure. 722 710 */ 723 function single_tag_title($prefix = '', $display = true ) { 724 global $wp_query; 725 if ( !is_tag() ) 711 function single_tag_title( $prefix = '', $display = true ) { 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 ) 726 736 return; 727 737 728 $tag = $wp_query->get_queried_object(); 729 730 if ( ! $tag ) 738 if ( is_category() ) 739 $term_name = apply_filters( 'single_cat_title', $term->name ); 740 elseif ( is_tag() ) 741 $term_name = apply_filters( 'single_tag_title', $term->name ); 742 elseif ( is_tax() ) 743 $term_name = apply_filters( 'single_term_title', $term->name ); 744 else 731 745 return; 732 746 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 e lse738 return $my_tag_name;739 }747 if ( empty( $term_name ) ) 748 return; 749 750 if ( $display ) 751 echo $prefix . $term_name; 752 else 753 return $term_name; 740 754 } 741 755 … … 1102 1116 $thisyear = ''.intval(substr($m, 0, 4)); 1103 1117 $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')");1118 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')"); 1105 1119 } elseif ( !empty($m) ) { 1106 1120 $thisyear = ''.intval(substr($m, 0, 4)); … … 1115 1129 1116 1130 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 1131 $last_day = date('t', $unixmonth); 1117 1132 1118 1133 // Get the next and previous month and year with at least one post 1119 $previous = $wpdb->get_row("SELECT DISTINCTMONTH(post_date) AS month, YEAR(post_date) AS year1134 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 1120 1135 FROM $wpdb->posts 1121 1136 WHERE post_date < '$thisyear-$thismonth-01' … … 1123 1138 ORDER BY post_date DESC 1124 1139 LIMIT 1"); 1125 $next = $wpdb->get_row("SELECT DISTINCTMONTH(post_date) AS month, YEAR(post_date) AS year1140 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 1126 1141 FROM $wpdb->posts 1127 WHERE post_date > '$thisyear-$thismonth-01' 1128 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 1142 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 1129 1143 AND post_type = 'post' AND post_status = 'publish' 1130 ORDER BY post_date ASC1144 ORDER BY post_date ASC 1131 1145 LIMIT 1"); 1132 1146 … … 1158 1172 1159 1173 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))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';1174 $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>'; 1161 1175 } else { 1162 1176 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; … … 1180 1194 // Get days with posts 1181 1195 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 1182 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 1183 AND YEAR(post_date) = '$thisyear' 1196 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1184 1197 AND post_type = 'post' AND post_status = 'publish' 1185 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);1198 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); 1186 1199 if ( $dayswithposts ) { 1187 1200 foreach ( (array) $dayswithposts as $daywith ) { … … 1200 1213 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " 1201 1214 ."FROM $wpdb->posts " 1202 ."WHERE YEAR(post_date) = '$thisyear' " 1203 ."AND MONTH(post_date) = '$thismonth' " 1204 ."AND post_date < '".current_time('mysql')."' " 1215 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 1216 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " 1205 1217 ."AND post_type = 'post' AND post_status = 'publish'" 1206 1218 ); … … 1319 1331 * Will only output the date if the current post's date is different from the 1320 1332 * previous one output. 1321 1333 * 1322 1334 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the 1323 1335 * function is called several times for each post. … … 1335 1347 */ 1336 1348 function the_date( $d = '', $before = '', $after = '', $echo = true ) { 1337 global $ day, $previousday;1349 global $currentday, $previousday; 1338 1350 $the_date = ''; 1339 if ( $ day != $previousday ) {1351 if ( $currentday != $previousday ) { 1340 1352 $the_date .= $before; 1341 1353 $the_date .= get_the_date( $d ); 1342 1354 $the_date .= $after; 1343 $previousday = $ day;1355 $previousday = $currentday; 1344 1356 1345 1357 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); … … 1543 1555 * @param string $before Optional Output before the date. 1544 1556 * @param string $after Optional Output after the date. 1545 */1557 */ 1546 1558 function the_weekday_date($before='',$after='') { 1547 1559 global $wp_locale, $post, $day, $previousweekday; 1548 1560 $the_weekday_date = ''; 1549 if ( $ day != $previousweekday ) {1561 if ( $currentday != $previousweekday ) { 1550 1562 $the_weekday_date .= $before; 1551 1563 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false)); 1552 1564 $the_weekday_date .= $after; 1553 $previousweekday = $ day;1565 $previousweekday = $currentday; 1554 1566 } 1555 1567 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); … … 1636 1648 } 1637 1649 } 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 );1650 $term = get_queried_object(); 1651 1652 $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name )); 1653 $href = get_category_feed_link( $term->term_id ); 1642 1654 } 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 ); 1655 $term = get_queried_object(); 1656 1657 $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name )); 1658 $href = get_tag_feed_link( $term->term_id ); 1648 1659 } elseif ( is_author() ) { 1649 1660 $author_id = intval( get_query_var('author') ); … … 2040 2051 * @param string $name The name of the theme. 2041 2052 * @param string $url The url of the css file containing the colour scheme. 2042 * @param array @colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.2053 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. 2043 2054 */ 2044 2055 function wp_admin_css_color($key, $name, $url, $colors = array()) { … … 2057 2068 */ 2058 2069 function register_admin_color_schemes() { 2059 wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); 2060 wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));} 2070 wp_admin_css_color( 'classic', __( 'Blue' ), admin_url( 'css/colors-classic.css' ), 2071 array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) ); 2072 wp_admin_css_color( 'fresh', __( 'Gray' ), admin_url( 'css/colors-fresh.css' ), 2073 array( '#7c7976', '#c6c6c6', '#e0e0e0', '#f1f1f1' ) ); 2074 } 2061 2075 2062 2076 /** … … 2098 2112 * @uses $wp_styles WordPress Styles Object 2099 2113 * 2100 * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/ 2114 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative 2115 * to wp-admin/. Defaults to 'wp-admin'. 2101 2116 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. 2102 2117 */ … … 2134 2149 wp_enqueue_script( 'thickbox' ); 2135 2150 wp_enqueue_style( 'thickbox' ); 2151 2152 if ( is_network_admin() ) 2153 add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); 2136 2154 } 2137 2155 … … 2220 2238 break; 2221 2239 case 'export': 2222 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';2240 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->'; 2223 2241 break; 2224 2242 } … … 2231 2249 * Compares the first two arguments and if identical marks as checked 2232 2250 * 2233 * @since 1.0 2251 * @since 1.0.0 2234 2252 * 2235 2253 * @param mixed $checked One of the values to compare … … 2247 2265 * Compares the first two arguments and if identical marks as selected 2248 2266 * 2249 * @since 1.0 2250 * 2251 * @param mixed selected One of the values to compare2267 * @since 1.0.0 2268 * 2269 * @param mixed $selected One of the values to compare 2252 2270 * @param mixed $current (true) The other value to compare if not just true 2253 2271 * @param bool $echo Whether to echo or just return the string … … 2279 2297 * Compares the first two arguments and if identical marks as $type 2280 2298 * 2281 * @since 2.8 2299 * @since 2.8.0 2282 2300 * @access private 2283 2301 *
Note: See TracChangeset
for help on using the changeset viewer.