From 74b8c3d13aee89d22e18f30546f5bf5c264a635a Mon Sep 17 00:00:00 2001 From: strarsis Date: Sat, 20 Nov 2021 11:49:00 +0100 Subject: [PATCH 1/7] Template hierarchy filter: Preserve existing paths Instead of solely returning the blade template path locate result, append it to the array of existing files passed to the template hierarchy filter handler, allowing Gutenberg Full Site Editing (FSE) to find and use block templates/template parts in the (Sage 10) theme. --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 75f9ef4b..19b276ce 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -14,7 +14,7 @@ trait FiltersTemplates */ public function filterTemplateHierarchy($files) { - return $this->sageFinder->locate($files); + return $files + [$this->sageFinder->locate($files)]; } /** From 01279f474d4c11eebfb85f37e9031feec22bb536 Mon Sep 17 00:00:00 2001 From: strarsis Date: Thu, 8 Dec 2022 03:20:55 +0100 Subject: [PATCH 2/7] Update FiltersTemplates.php Allow existing files to be used instead of Blade-PHP template (notably `template-canvas.php`). --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 19b276ce..f02d10f0 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -27,6 +27,11 @@ public function filterTemplateHierarchy($files) */ public function filterTemplateInclude($file) { + + if(@file_exists($file)) { + return $file; + } + $view = $this->fileFinder ->getPossibleViewNameFromPath($file = realpath($file)); From b7b8ccc82c15285811752d482cb656d933c0325e Mon Sep 17 00:00:00 2001 From: strarsis Date: Thu, 16 Mar 2023 12:38:09 +0100 Subject: [PATCH 3/7] Fix lint errors. --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index f02d10f0..85862c48 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -28,10 +28,10 @@ public function filterTemplateHierarchy($files) public function filterTemplateInclude($file) { - if(@file_exists($file)) { + if (@file_exists($file)) { return $file; } - + $view = $this->fileFinder ->getPossibleViewNameFromPath($file = realpath($file)); From 639155e939c589f39df972769f568e19ce831640 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 18 Mar 2024 12:09:38 -0500 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=A9=B9=20Do=20not=20return=20blade=20?= =?UTF-8?q?files=20=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Allow=20blade=20vie?= =?UTF-8?q?ws=20to=20override=20FSE=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 85862c48..7dbd5668 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -2,6 +2,8 @@ namespace Roots\Acorn\Sage\Concerns; +use Illuminate\Support\Str; + trait FiltersTemplates { /** @@ -14,7 +16,7 @@ trait FiltersTemplates */ public function filterTemplateHierarchy($files) { - return $files + [$this->sageFinder->locate($files)]; + return [...$this->sageFinder->locate($files), ...$files]; } /** @@ -27,8 +29,7 @@ public function filterTemplateHierarchy($files) */ public function filterTemplateInclude($file) { - - if (@file_exists($file)) { + if (@file_exists($file) && ! Str::endsWith($file, '.blade.php')) { return $file; } From c60978f993c3d7b9694d634ddade0f5d8f6682f6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 18 Mar 2024 12:14:16 -0500 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=8E=A8=20Move=20the=20`file=5Fexists`?= =?UTF-8?q?=20check=20to=20the=20end=20of=20the=20`filterTemplateInclude`?= =?UTF-8?q?=20conditional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 7dbd5668..e41653f6 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -29,7 +29,7 @@ public function filterTemplateHierarchy($files) */ public function filterTemplateInclude($file) { - if (@file_exists($file) && ! Str::endsWith($file, '.blade.php')) { + if (! Str::endsWith($file, '.blade.php') && @file_exists($file)) { return $file; } From 39a26c37bf1b76db114eff28943c3fb7431a23fd Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 18 Mar 2024 12:53:18 -0500 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=8E=A8=20Remove=20unnecessary=20condi?= =?UTF-8?q?tional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index e41653f6..3d06bc65 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -29,10 +29,6 @@ public function filterTemplateHierarchy($files) */ public function filterTemplateInclude($file) { - if (! Str::endsWith($file, '.blade.php') && @file_exists($file)) { - return $file; - } - $view = $this->fileFinder ->getPossibleViewNameFromPath($file = realpath($file)); From 6b7055143dbd2343a4919930eea283cc68177776 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 18 Mar 2024 12:55:09 -0500 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=9A=A8=20Run=20Pint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php index 3d06bc65..4ce3347c 100644 --- a/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php +++ b/src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php @@ -2,8 +2,6 @@ namespace Roots\Acorn\Sage\Concerns; -use Illuminate\Support\Str; - trait FiltersTemplates { /**