Skip to content

Commit

Permalink
Fix email template rendering issue (#2256)
Browse files Browse the repository at this point in the history
* Handle global $email_template properly

- Ensure that it is reset after it is used.
- Ensure that we do not mangle template loading for emails when
  $email_template is set.

* Fix issue in test
  • Loading branch information
alexsanford committed Sep 25, 2018
1 parent eb73876 commit 9a9a928
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions includes/class-sensei-emails.php
Expand Up @@ -215,6 +215,7 @@ function load_template( $template = '' ) {
include( $template );
do_action( 'sensei_after_email_template', $email_template );

$email_template = '';
return ob_get_clean();
}

Expand Down
14 changes: 8 additions & 6 deletions includes/class-sensei-templates.php
Expand Up @@ -140,12 +140,6 @@ public static function template_loader ( $template = '' ) {

global $wp_query, $email_template;

// If our unsupported theme renderer is handling the request, we do not
// need to find a custom template.
if ( Sensei_Unsupported_Themes::get_instance()->is_handling_request() ) {
return $template;
}

$find = array( 'woothemes-sensei.php' );
$file = '';

Expand All @@ -155,6 +149,14 @@ public static function template_loader ( $template = '' ) {
$find[] = $file;
$find[] = Sensei()->template_url . $file;

} elseif ( Sensei_Unsupported_Themes::get_instance()->is_handling_request() ) {

/*
* If our unsupported theme renderer is handling the request, we do
* not need to find a custom template.
*/
$file = null;

} elseif ( is_single() && get_post_type() == 'course' ) {

// possible backward compatible template include if theme overrides content-single-course.php
Expand Down
Expand Up @@ -156,9 +156,8 @@ private function setupUnsupportedPage() {
$this->course = $this->factory->course->create_and_get();
$this->factory->post->create_many( 2 );

// Setup $wp_query to be for the lessons in Module 2.
$args = array(
'post_type' => 'post',
'post_type' => 'course',
);
$wp_query = new WP_Query( $args );
$wp_the_query = $wp_query;
Expand Down

0 comments on commit 9a9a928

Please sign in to comment.