Skip to content

Commit

Permalink
Merge pull request #362 from woocommerce/fix/361-template-preview
Browse files Browse the repository at this point in the history
Adjust the template check for the Certificate template preview
  • Loading branch information
donnapep authored Nov 14, 2024
2 parents a166d8a + 832ee54 commit 98694f7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions classes/class-woothemes-sensei-certificate-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function __construct() {
}

// Preview Template
add_filter( 'single_template', array( $this, 'certificate_templates_locate_preview_template' ) );
add_filter( 'single_template', array( $this, 'certificate_templates_locate_preview_template' ), 10, 2 );

}

Expand Down Expand Up @@ -191,18 +191,19 @@ public function plugin_path() {
* @access public
* @since 1.0
* @param string $locate locate path
* @param string $type type of template
*
* @return string the location path for the certificate template preview file
*/
function certificate_templates_locate_preview_template( $locate ) {
public function certificate_templates_locate_preview_template( $locate, $type ) {

$post_type = get_query_var( 'post_type' );

if ( 'certificate_template' == $post_type && strpos( $locate, 'single.php' ) ) {
if ( 'certificate_template' === $post_type && 'single' === $type ) {
$locate = $this->plugin_path() . '/templates/single-certificate_template.php';
}

return $locate;

}


Expand Down

0 comments on commit 98694f7

Please sign in to comment.