Changeset 20075 for trunk/wp-includes/post-template.php
- Timestamp:
- 03/02/2012 06:56:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.