Changeset 20075
- Timestamp:
- 03/02/2012 06:56:54 PM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-xmlrpc-server.php
r20074 r20075 1178 1178 $author = get_userdata($page->post_author); 1179 1179 1180 $page_template = get_p ost_meta( $page->ID, '_wp_page_template', true);1180 $page_template = get_page_template_slug( $page->ID ); 1181 1181 if ( empty( $page_template ) ) 1182 1182 $page_template = 'default'; -
trunk/wp-includes/post-template.php
r19925 r20075 488 488 if ( is_page_template() ) { 489 489 $classes[] = 'page-template'; 490 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_p ost_meta( $page_id, '_wp_page_template', true ) ), '');490 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) ); 491 491 } else { 492 492 $classes[] = 'page-template-default'; … … 1242 1242 * @return bool False on failure, true if success. 1243 1243 */ 1244 function is_page_template( $template = '') {1245 if ( !is_page()) {1244 function is_page_template( $template = '' ) { 1245 if ( ! is_page() ) 1246 1246 return false; 1247 } 1248 1249 global $wp_query; 1250 1251 $page = $wp_query->get_queried_object(); 1252 $custom_fields = get_post_custom_values('_wp_page_template',$page->ID); 1253 $page_template = $custom_fields[0]; 1254 1255 // We have no argument passed so just see if a page_template has been specified 1256 if ( empty( $template ) ) { 1257 if ( !empty( $page_template ) and ( 'default' != $page_template ) ) { 1258 return true; 1259 } 1260 } elseif ( $template == $page_template) { 1247 1248 $page_template = get_page_template_slug( get_queried_object_id() ); 1249 1250 if ( empty( $template ) ) 1251 return (bool) $page_template; 1252 1253 if ( $template == $page_template ) 1261 1254 return true; 1262 } 1255 1256 if ( 'default' == $template && ! $page_template ) 1257 return true; 1263 1258 1264 1259 return false; 1260 } 1261 1262 /** 1263 * Get the specific template name for a page. 1264 * 1265 * @since 3.4.0 1266 * 1267 * @param int $id The page ID to check. Defaults to the current post, when used in the loop. 1268 * @return string|bool Page template filename. Returns an empty string when the default page template 1269 * is in use. Returns false if the post is not a page. 1270 */ 1271 function get_page_template_slug( $post_id = null ) { 1272 $post = get_post( $post_id ); 1273 if ( 'page' != $post->post_type ) 1274 return false; 1275 $template = get_post_meta( $post->ID, '_wp_page_template', true ); 1276 if ( ! $template || 'default' == $template ) 1277 return ''; 1278 return $template; 1265 1279 } 1266 1280 -
trunk/wp-includes/post.php
r20023 r20075 5340 5340 } 5341 5341 } 5342 -
trunk/wp-includes/template.php
r20002 r20075 226 226 function get_page_template() { 227 227 $id = get_queried_object_id(); 228 $template = get_p ost_meta($id, '_wp_page_template', true);228 $template = get_page_template_slug(); 229 229 $pagename = get_query_var('pagename'); 230 230 231 if ( ! $pagename && $id > 0) {231 if ( ! $pagename && $id ) { 232 232 // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object 233 233 $post = get_queried_object(); … … 235 235 } 236 236 237 if ( 'default' == $template ) 238 $template = ''; 239 240 $templates = array(); 241 if ( !empty($template) && !validate_file($template) ) 237 $templates = array(); 238 if ( $template && 0 === validate_file( $template ) ) 242 239 $templates[] = $template; 243 240 if ( $pagename )
Note: See TracChangeset
for help on using the changeset viewer.