From c60d773c459f8b831e040b24a060ab64319cb870 Mon Sep 17 00:00:00 2001 From: Yurii Pavlov Date: Thu, 26 Jul 2018 21:52:44 +0300 Subject: [PATCH 1/2] add filter to add own templates path --- wpaffiliatemanager/source/Pages/TemplateResponse.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wpaffiliatemanager/source/Pages/TemplateResponse.php b/wpaffiliatemanager/source/Pages/TemplateResponse.php index 0f513a3..c9f907b 100644 --- a/wpaffiliatemanager/source/Pages/TemplateResponse.php +++ b/wpaffiliatemanager/source/Pages/TemplateResponse.php @@ -19,8 +19,16 @@ public function __construct($templateName, $viewData = array()) public function render() { + $templates_path_default = WPAM_BASE_DIRECTORY . "/html/"; + $templates_path = apply_filters('wpam_templates_path', $templates_path_default); + ob_start(); - include WPAM_BASE_DIRECTORY . "/html/{$this->templateName}.php"; + + if ( file_exists($templates_path . "{$this->templateName}.php") ) { + include $templates_path . "{$this->templateName}.php"; + } else { + include $templates_path_default . "{$this->templateName}.php"; + } $buffer = ob_get_contents(); ob_end_clean(); return $buffer; From ef26dd2278121a77af4b52900904c9f7d3f2def6 Mon Sep 17 00:00:00 2001 From: Yurii Pavlov <25429417+yuriipavlov@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:00:33 +0100 Subject: [PATCH 2/2] Update wpaffiliatemanager/source/Pages/TemplateResponse.php with trailingslashit() Co-authored-by: Scott Kingsley Clark --- wpaffiliatemanager/source/Pages/TemplateResponse.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wpaffiliatemanager/source/Pages/TemplateResponse.php b/wpaffiliatemanager/source/Pages/TemplateResponse.php index c9f907b..dffd497 100644 --- a/wpaffiliatemanager/source/Pages/TemplateResponse.php +++ b/wpaffiliatemanager/source/Pages/TemplateResponse.php @@ -21,6 +21,9 @@ public function render() { $templates_path_default = WPAM_BASE_DIRECTORY . "/html/"; $templates_path = apply_filters('wpam_templates_path', $templates_path_default); + + // Normalize the path to ensure it ends with a trailing slash. + $templates_path = trailingslashit($templates_path); ob_start();