Changes from trunk/wp-includes/general-template.php at r17187 to branches/3.0/wp-includes/general-template.php at r15461
- File:
-
- 1 edited
-
branches/3.0/wp-includes/general-template.php (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-includes/general-template.php
r17187 r15461 152 152 do_action( 'get_search_form' ); 153 153 154 $search_form_template = locate_template( 'searchform.php');154 $search_form_template = locate_template(array('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 .0202 * @since 2.7 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 .0226 * @since 2.7 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', '' , $args) . '274 ' . apply_filters( 'login_form_top', '' ) . ' 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', '' , $args) . '283 ' . apply_filters( 'login_form_middle', '' ) . ' 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', '' , $args) . '289 ' . apply_filters( 'login_form_bottom', '' ) . ' 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 id496 *497 * @since 3.1.0498 *499 * @return int Blog id500 */501 function get_current_blog_id() {502 global $blog_id;503 return absint($blog_id);504 }505 506 /**507 495 * Display or retrieve page title for all areas of blog. 508 496 * … … 527 515 */ 528 516 function wp_title($sep = '»', $display = true, $seplocation = '') { 529 global $wpdb, $wp_locale; 530 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'); 531 524 $m = get_query_var('m'); 532 525 $year = get_query_var('year'); … … 538 531 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary 539 532 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 ); 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); 555 557 } 556 558 557 559 // If there's an author 558 if ( is_author() ) {559 $ author = get_queried_object();560 $title = $ author->display_name;561 } 562 563 // If there's a post type archive564 if ( is_post_type_archive() )565 $title = post_type_archive_title( '', false );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 } 566 568 567 569 // If there's a month 568 if ( is_archive() &&!empty($m) ) {570 if ( !empty($m) ) { 569 571 $my_year = substr($m, 0, 4); 570 572 $my_month = $wp_locale->get_month(substr($m, 4, 2)); … … 573 575 } 574 576 575 // If there's a year 576 if ( is_archive() && !empty($year) ) { 577 if ( !empty($year) ) { 577 578 $title = $year; 578 579 if ( !empty($monthnum) ) … … 582 583 } 583 584 584 // If it's a search 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 585 601 if ( is_search() ) { 586 602 /* translators: 1: separator, 2: search phrase */ … … 588 604 } 589 605 590 // If it's a 404 page591 606 if ( is_404() ) { 592 607 $title = __('Page not found'); … … 621 636 * 622 637 * This is optimized for single.php template file for displaying the post title. 638 * Only useful for posts, does not support pages for example. 623 639 * 624 640 * It does not support placing the separator after the title, but by leaving the … … 628 644 * 629 645 * @since 0.71 646 * @uses $wpdb 630 647 * 631 648 * @param string $prefix Optional. What to display before the title. … … 634 651 */ 635 652 function single_post_title($prefix = '', $display = true) { 636 $_post = get_queried_object(); 653 global $wp_query, $post; 654 655 if ( ! $post ) 656 $_post = $wp_query->get_queried_object(); 657 else 658 $_post = $post; 637 659 638 660 if ( !isset($_post->post_title) ) … … 647 669 648 670 /** 649 * Display or retrieve title for a post type archive.650 *651 * This is optimized for archive.php and archive-{$post_type}.php template files652 * for displaying the title of the post type.653 *654 * @since 3.1.0655 *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 else670 return $title;671 }672 673 /**674 671 * Display or retrieve page title for category archive. 675 672 * … … 688 685 * @return string|null Title when retrieving, null when displaying or failure. 689 686 */ 690 function single_cat_title( $prefix = '', $display = true ) { 691 return single_term_title( $prefix, $display ); 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 } 692 704 } 693 705 … … 709 721 * @return string|null Title when retrieving, null when displaying or failure. 710 722 */ 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 ) 723 function single_tag_title($prefix = '', $display = true ) { 724 global $wp_query; 725 if ( !is_tag() ) 736 726 return; 737 727 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 728 $tag = $wp_query->get_queried_object(); 729 730 if ( ! $tag ) 745 731 return; 746 732 747 if ( empty( $term_name ) )748 return;749 750 if ( $display )751 e cho $prefix . $term_name;752 else753 return $term_name;733 $my_tag_name = apply_filters('single_tag_title', $tag->name); 734 if ( !empty($my_tag_name) ) { 735 if ( $display ) 736 echo $prefix . $my_tag_name; 737 else 738 return $my_tag_name; 739 } 754 740 } 755 741 … … 1116 1102 $thisyear = ''.intval(substr($m, 0, 4)); 1117 1103 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 1118 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD(' {$thisyear}0101', INTERVAL $d DAY) ), '%m')");1104 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 1119 1105 } elseif ( !empty($m) ) { 1120 1106 $thisyear = ''.intval(substr($m, 0, 4)); … … 1129 1115 1130 1116 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 1131 $last_day = date('t', $unixmonth);1132 1117 1133 1118 // Get the next and previous month and year with at least one post 1134 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year1119 $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 1135 1120 FROM $wpdb->posts 1136 1121 WHERE post_date < '$thisyear-$thismonth-01' … … 1138 1123 ORDER BY post_date DESC 1139 1124 LIMIT 1"); 1140 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year1125 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 1141 1126 FROM $wpdb->posts 1142 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 1127 WHERE post_date > '$thisyear-$thismonth-01' 1128 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 1143 1129 AND post_type = 'post' AND post_status = 'publish' 1144 ORDER BY post_date ASC1130 ORDER BY post_date ASC 1145 1131 LIMIT 1"); 1146 1132 … … 1172 1158 1173 1159 if ( $previous ) { 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>';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>'; 1175 1161 } else { 1176 1162 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; … … 1194 1180 // Get days with posts 1195 1181 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 1196 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1182 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 1183 AND YEAR(post_date) = '$thisyear' 1197 1184 AND post_type = 'post' AND post_status = 'publish' 1198 AND post_date < = '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);1185 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 1199 1186 if ( $dayswithposts ) { 1200 1187 foreach ( (array) $dayswithposts as $daywith ) { … … 1213 1200 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " 1214 1201 ."FROM $wpdb->posts " 1215 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 1216 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " 1202 ."WHERE YEAR(post_date) = '$thisyear' " 1203 ."AND MONTH(post_date) = '$thismonth' " 1204 ."AND post_date < '".current_time('mysql')."' " 1217 1205 ."AND post_type = 'post' AND post_status = 'publish'" 1218 1206 ); … … 1331 1319 * Will only output the date if the current post's date is different from the 1332 1320 * previous one output. 1333 * 1321 1334 1322 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the 1335 1323 * function is called several times for each post. … … 1347 1335 */ 1348 1336 function the_date( $d = '', $before = '', $after = '', $echo = true ) { 1349 global $ currentday, $previousday;1337 global $day, $previousday; 1350 1338 $the_date = ''; 1351 if ( $ currentday != $previousday ) {1339 if ( $day != $previousday ) { 1352 1340 $the_date .= $before; 1353 1341 $the_date .= get_the_date( $d ); 1354 1342 $the_date .= $after; 1355 $previousday = $ currentday;1343 $previousday = $day; 1356 1344 1357 1345 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); … … 1555 1543 * @param string $before Optional Output before the date. 1556 1544 * @param string $after Optional Output after the date. 1557 */1545 */ 1558 1546 function the_weekday_date($before='',$after='') { 1559 1547 global $wp_locale, $post, $day, $previousweekday; 1560 1548 $the_weekday_date = ''; 1561 if ( $ currentday != $previousweekday ) {1549 if ( $day != $previousweekday ) { 1562 1550 $the_weekday_date .= $before; 1563 1551 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false)); 1564 1552 $the_weekday_date .= $after; 1565 $previousweekday = $ currentday;1553 $previousweekday = $day; 1566 1554 } 1567 1555 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); … … 1648 1636 } 1649 1637 } elseif ( is_category() ) { 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 );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 ); 1654 1642 } elseif ( is_tag() ) { 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 ); 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 ); 1659 1648 } elseif ( is_author() ) { 1660 1649 $author_id = intval( get_query_var('author') ); … … 2051 2040 * @param string $name The name of the theme. 2052 2041 * @param string $url The url of the css file containing the colour scheme. 2053 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.2042 * @param array @colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. 2054 2043 */ 2055 2044 function wp_admin_css_color($key, $name, $url, $colors = array()) { … … 2068 2057 */ 2069 2058 function register_admin_color_schemes() { 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 } 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'));} 2075 2061 2076 2062 /** … … 2112 2098 * @uses $wp_styles WordPress Styles Object 2113 2099 * 2114 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative 2115 * to wp-admin/. Defaults to 'wp-admin'. 2100 * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/ 2116 2101 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. 2117 2102 */ … … 2149 2134 wp_enqueue_script( 'thickbox' ); 2150 2135 wp_enqueue_style( 'thickbox' ); 2151 2152 if ( is_network_admin() )2153 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );2154 2136 } 2155 2137 … … 2238 2220 break; 2239 2221 case 'export': 2240 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';2222 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '"-->'; 2241 2223 break; 2242 2224 } … … 2249 2231 * Compares the first two arguments and if identical marks as checked 2250 2232 * 2251 * @since 1.0 .02233 * @since 1.0 2252 2234 * 2253 2235 * @param mixed $checked One of the values to compare … … 2265 2247 * Compares the first two arguments and if identical marks as selected 2266 2248 * 2267 * @since 1.0 .02268 * 2269 * @param mixed $selected One of the values to compare2249 * @since 1.0 2250 * 2251 * @param mixed selected One of the values to compare 2270 2252 * @param mixed $current (true) The other value to compare if not just true 2271 2253 * @param bool $echo Whether to echo or just return the string … … 2297 2279 * Compares the first two arguments and if identical marks as $type 2298 2280 * 2299 * @since 2.8 .02281 * @since 2.8 2300 2282 * @access private 2301 2283 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)