Changes in trunk/wp-includes/post-template.php [19240:21054]
- File:
-
- 1 edited
-
trunk/wp-includes/post-template.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-template.php
r19240 r21054 79 79 $r = wp_parse_args($args, $defaults); 80 80 extract( $r, EXTR_SKIP ); 81 82 81 83 82 $title = $before . $title . $after; … … 189 188 190 189 // If post password required and it doesn't match the cookie. 191 if ( post_password_required($post) ) { 192 $output = get_the_password_form(); 193 return $output; 194 } 190 if ( post_password_required($post) ) 191 return get_the_password_form(); 195 192 196 193 if ( $page > count($pages) ) // if the requested page doesn't exist … … 415 412 if ( is_date() ) 416 413 $classes[] = 'date'; 417 if ( is_search() ) 414 if ( is_search() ) { 418 415 $classes[] = 'search'; 416 $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results'; 417 } 419 418 if ( is_paged() ) 420 419 $classes[] = 'paged'; … … 491 490 if ( is_page_template() ) { 492 491 $classes[] = 'page-template'; 493 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_p ost_meta( $page_id, '_wp_page_template', true ) ), '');492 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) ); 494 493 } else { 495 494 $classes[] = 'page-template-default'; 496 495 } 497 } elseif ( is_search() ) {498 if ( !empty( $wp_query->posts ) )499 $classes[] = 'search-results';500 else501 $classes[] = 'search-no-results';502 496 } 503 497 … … 508 502 $classes[] = 'admin-bar'; 509 503 510 if ( get_ background_image() || get_background_color() )504 if ( get_theme_mod( 'background_color' ) || get_background_image() ) 511 505 $classes[] = 'custom-background'; 512 506 … … 556 550 * @since 2.7.0 557 551 * 558 * @param int|object $post An optional post. Global $post used if not provided.552 * @param int|object $post An optional post. Global $post used if not provided. 559 553 * @return bool false if a password is not required or the correct password cookie is present, true otherwise. 560 554 */ 561 555 function post_password_required( $post = null ) { 556 global $wp_hasher; 557 562 558 $post = get_post($post); 563 559 564 if ( empty( $post->post_password) )560 if ( empty( $post->post_password ) ) 565 561 return false; 566 562 567 if ( ! isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )563 if ( ! isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) 568 564 return true; 569 565 570 if ( stripslashes( $_COOKIE['wp-postpass_' . COOKIEHASH] ) != $post->post_password ) 571 return true; 572 573 return false; 566 if ( empty( $wp_hasher ) ) { 567 require_once( ABSPATH . 'wp-includes/class-phpass.php'); 568 // By default, use the portable hash from phpass 569 $wp_hasher = new PasswordHash(8, true); 570 } 571 572 $hash = stripslashes( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ); 573 574 return ! $wp_hasher->CheckPassword( $post->post_password, $hash ); 574 575 } 575 576 … … 995 996 * @param int $depth Depth of page. Used for padding. 996 997 */ 997 function start_lvl( &$output, $depth) {998 function start_lvl( &$output, $depth = 0, $args = array() ) { 998 999 $indent = str_repeat("\t", $depth); 999 1000 $output .= "\n$indent<ul class='children'>\n"; … … 1007 1008 * @param int $depth Depth of page. Used for padding. 1008 1009 */ 1009 function end_lvl( &$output, $depth) {1010 function end_lvl( &$output, $depth = 0, $args = array() ) { 1010 1011 $indent = str_repeat("\t", $depth); 1011 1012 $output .= "$indent</ul>\n"; … … 1022 1023 * @param array $args 1023 1024 */ 1024 function start_el( &$output, $page, $depth, $args, $current_page) {1025 function start_el( &$output, $page, $depth, $args, $current_page = 0 ) { 1025 1026 if ( $depth ) 1026 1027 $indent = str_repeat("\t", $depth); … … 1065 1066 * @param int $depth Depth of page. Not Used. 1066 1067 */ 1067 function end_el( &$output, $page, $depth) {1068 function end_el( &$output, $page, $depth = 0, $args = array() ) { 1068 1069 $output .= "</li>\n"; 1069 1070 } … … 1103 1104 * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. 1104 1105 */ 1105 function start_el(&$output, $page, $depth, $args ) {1106 function start_el(&$output, $page, $depth, $args, $id = 0) { 1106 1107 $pad = str_repeat(' ', $depth * 3); 1107 1108 … … 1166 1167 1167 1168 if ( $text ) 1168 $link_text = esc_attr( $text );1169 $link_text = $text; 1169 1170 elseif ( $size && 'none' != $size ) 1170 1171 $link_text = wp_get_attachment_image( $id, $size, $icon ); … … 1216 1217 function get_the_password_form() { 1217 1218 global $post; 1218 $label = 'pwbox-' .(empty($post->ID) ? rand() : $post->ID);1219 $output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">1219 $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID ); 1220 $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> 1220 1221 <p>' . __("This post is password protected. To view it please enter your password below:") . '</p> 1221 1222 <p><label for="' . $label . '">' . __("Password:") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /></p> … … 1238 1239 * @return bool False on failure, true if success. 1239 1240 */ 1240 function is_page_template( $template = '') {1241 if ( !is_page()) {1241 function is_page_template( $template = '' ) { 1242 if ( ! is_page() ) 1242 1243 return false; 1243 } 1244 1245 global $wp_query; 1246 1247 $page = $wp_query->get_queried_object(); 1248 $custom_fields = get_post_custom_values('_wp_page_template',$page->ID); 1249 $page_template = $custom_fields[0]; 1250 1251 // We have no argument passed so just see if a page_template has been specified 1252 if ( empty( $template ) ) { 1253 if ( !empty( $page_template ) and ( 'default' != $page_template ) ) { 1254 return true; 1255 } 1256 } elseif ( $template == $page_template) { 1244 1245 $page_template = get_page_template_slug( get_queried_object_id() ); 1246 1247 if ( empty( $template ) ) 1248 return (bool) $page_template; 1249 1250 if ( $template == $page_template ) 1257 1251 return true; 1258 } 1252 1253 if ( 'default' == $template && ! $page_template ) 1254 return true; 1259 1255 1260 1256 return false; 1257 } 1258 1259 /** 1260 * Get the specific template name for a page. 1261 * 1262 * @since 3.4.0 1263 * 1264 * @param int $id The page ID to check. Defaults to the current post, when used in the loop. 1265 * @return string|bool Page template filename. Returns an empty string when the default page template 1266 * is in use. Returns false if the post is not a page. 1267 */ 1268 function get_page_template_slug( $post_id = null ) { 1269 $post = get_post( $post_id ); 1270 if ( 'page' != $post->post_type ) 1271 return false; 1272 $template = get_post_meta( $post->ID, '_wp_page_template', true ); 1273 if ( ! $template || 'default' == $template ) 1274 return ''; 1275 return $template; 1261 1276 } 1262 1277 … … 1308 1323 * Second argument controls parameters: 1309 1324 * (bool) parent : include the parent (the "Current Revision") in the list. 1310 * (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'1325 * (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table' 1311 1326 * outputs TABLE with UI. 1312 1327 * (int) right : what revision is currently being viewed - used in
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)