diff --git a/includes/class-wc-template-loader.php b/includes/class-wc-template-loader.php index 7f0bdbcc4f0..28e0606f6b4 100644 --- a/includes/class-wc-template-loader.php +++ b/includes/class-wc-template-loader.php @@ -127,7 +127,16 @@ class WC_Template_Loader { $templates[] = 'woocommerce.php'; if ( is_page_template() ) { - $templates[] = get_page_template_slug(); + $page_template = get_page_template_slug(); + + if ( $page_template ) { + $validated_file = validate_file( $page_template ); + if ( 0 === $validated_file ) { + $templates[] = $page_template; + } else { + error_log( "WooCommerce: Unable to validate template path: \"$page_template\". Error Code: $validated_file." ); + } + } } if ( is_singular( 'product' ) ) {