Permalink
Browse files

Correct template loading

Can't use `locate_template` directly here because we need templates to
have access to some local variables.
  • Loading branch information...
1 parent 40672a8 commit b207e8a170911d07c2a921685097a2cdc6b692de Michael Sisk committed Aug 21, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 webcomic.php
View
@@ -823,7 +823,9 @@ public function the_content_feed( $content ) {
$feed_size = self::$config[ 'collections' ][ $post->post_type ][ 'feeds' ][ 'size' ];
- if ( !locate_template( array( "webcomic/feed-{$post->post_type}.php", 'webcomic/feed.php' ), true, false ) and $attachments = self::get_attachments( $post->ID ) ) {
+ if ( $template = locate_template( array( "webcomic/feed-{$post->post_type}.php", 'webcomic/feed.php' ) ) ) {
+ require $template;
+ } else {
require self::$dir . '-/php/integrate/feed.php';
}
@@ -921,7 +923,9 @@ public function the_excerpt( $excerpt ) {
if ( self::$integrate and in_the_loop() and $wp_query->is_main_query() and !is_feed() and $collection = get_post_type( $post ) and isset( self::$config[ 'collections' ][ $collection ] ) ) {
$prepend = $append = '';
- if ( !locate_template( array( "webcomic/the_excerpt-{$collection}.php", 'webcomic/the_excerpt.php' ), true, false ) ) {
+ if ( $template = locate_template( array( "webcomic/the_excerpt-{$collection}.php", 'webcomic/the_excerpt.php' ) ) ) {
+ require $template;
+ } else {
require self::$dir . '-/php/integrate/the_excerpt.php';
}
}
@@ -943,7 +947,9 @@ public function the_content( $content ) {
if ( self::$integrate and in_the_loop() and $wp_query->is_main_query() and !is_feed() and $collection = get_post_type( $post ) and isset( self::$config[ 'collections' ][ $collection ] ) ) {
$prepend = $append = '';
- if ( !locate_template( array( "webcomic/the_content-{$collection}.php", 'webcomic/the_content.php' ), true, false ) ) {
+ if ( $template = locate_template( array( "webcomic/the_content-{$collection}.php", 'webcomic/the_content.php' ) ) ) {
+ require $template;
+ } else {
require self::$dir . '-/php/integrate/the_content.php';
}

0 comments on commit b207e8a

Please sign in to comment.