Skip to content

Commit

Permalink
Save both template and stylesheet.
Browse files Browse the repository at this point in the history
This way we don't have to instantiate WP_Theme on every page request.
  • Loading branch information
Michael Sisk committed Nov 6, 2012
1 parent b98afc1 commit 7d3ba39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions -/php/config.php
Expand Up @@ -450,9 +450,10 @@ public function collection_theme() {
<?php
foreach ( wp_get_themes() as $theme ) {
printf(
'<option value="%s"%s>%s</option>',
'<option value="%s|%s"%s>%s</option>',
$theme[ 'Template' ],
$theme[ 'Stylesheet' ],
selected( $theme[ 'Stylesheet' ], self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'theme' ], false ),
selected( $theme[ 'Template' ] . '|' . $theme[ 'Stylesheet' ], self::$config[ 'collections' ][ $_GET[ 'post_type' ] ][ 'theme' ], false ),
esc_html( $theme[ 'Name' ] )
);
}
Expand Down
8 changes: 2 additions & 6 deletions webcomic.php
Expand Up @@ -575,11 +575,7 @@ public function template_redirect() {
* @hook template
*/
public function template( $theme ) {
if ( self::$collection and self::$config[ 'collections' ][ self::$collection ][ 'theme' ] ) {
return ( $child = new WP_Theme( get_stylesheet_directory(), '' ) and $child->get( 'Template' ) ) ? $child->get( 'Template' ) : self::$config[ 'collections' ][ self::$collection ][ 'theme' ];
}

return $theme;
return ( self::$collection and self::$config[ 'collections' ][ self::$collection ][ 'theme' ] ) ? substr( self::$config[ 'collections' ][ self::$collection ][ 'theme' ], 0, strpos( self::$config[ 'collections' ][ self::$collection ][ 'theme' ], '|' ) ) : $theme;
}

/** Return the appropriate theme ID for custom collection themes.
Expand All @@ -591,7 +587,7 @@ public function template( $theme ) {
* @hook stylesheet
*/
public function stylesheet( $theme ) {
return ( self::$collection and self::$config[ 'collections' ][ self::$collection ][ 'theme' ] ) ? self::$config[ 'collections' ][ self::$collection ][ 'theme' ] : $theme;
return ( self::$collection and self::$config[ 'collections' ][ self::$collection ][ 'theme' ] ) ? substr( self::$config[ 'collections' ][ self::$collection ][ 'theme' ], strpos( self::$config[ 'collections' ][ self::$collection ][ 'theme' ], '|' ) + 1 ) : $theme;
}

/** Integrate webcomics into the main site feed.
Expand Down

0 comments on commit 7d3ba39

Please sign in to comment.