From a11c48a6ee5f2ab07c7909220a1887a6f82ec18a Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Mon, 18 Aug 2025 10:16:23 +0200 Subject: [PATCH 1/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf731b3..c9402ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## v2.3.0 - 2024.08.14 + ### Added - Add support for custom taxonomies filtering ([#42](https://github.com/studiometa/wp-toolkit/issues/42), [#43](https://github.com/studiometa/wp-toolkit/pull/43), [ae541b5](https://github.com/studiometa/wp-toolkit/commit/ae541b5)) From 9c098c7e35fa038428d2c1e6ca3959f17484a83f Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 12:28:50 +0200 Subject: [PATCH 2/7] Fix facets applying on non-main queries Fix: #49 --- src/Managers/FacetsManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Managers/FacetsManager.php b/src/Managers/FacetsManager.php index 5dc74d7..dc778bb 100644 --- a/src/Managers/FacetsManager.php +++ b/src/Managers/FacetsManager.php @@ -58,7 +58,7 @@ public function run() */ public function add_facets_to_query(WP_Query &$query): void { - if (!is_array($this->facets)) { + if (!is_array($this->facets) || !$query->is_main_query()) { return; } From b4b8c073dd19f3ff4c93be5ab62fa3b966f9e609 Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 12:28:57 +0200 Subject: [PATCH 3/7] Update tests --- tests/Managers/FacetsManagerTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Managers/FacetsManagerTest.php b/tests/Managers/FacetsManagerTest.php index 25e6236..72603ac 100644 --- a/tests/Managers/FacetsManagerTest.php +++ b/tests/Managers/FacetsManagerTest.php @@ -210,4 +210,21 @@ public function test_it_should_handle_array_values_in_facets() $this->assertEquals(['slug1', 'slug2'], $tax_query[0]['terms']); $this->assertEquals('slug', $tax_query[0]['field']); } + + public function test_it_should_not_add_facets_to_non_main_query() + { + request()->query->set('facets', ['cat' => 1]); + $manager = new FacetsManager(); + $manager->run(); + + // Create a non-main query + $secondary_query = new WP_Query(); + $secondary_query->init(); + + // Manually call the method to simulate what happens on pre_get_posts + $manager->add_facets_to_query($secondary_query); + + // The facets should not be applied to the secondary query + $this->assertFalse(isset($secondary_query->query_vars['cat'])); + } } From c47470f9b1ed72c93f500bb2a3aa2d44a7fab153 Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 13:08:59 +0200 Subject: [PATCH 4/7] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9402ea..a249840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- Fix facets applying on non-main queries ([#49](https://github.com/studiometa/wp-toolkit/issues/49), [#50](https://github.com/studiometa/wp-toolkit/pull/50), [9c098c7](https://github.com/studiometa/wp-toolkit/commit/9c098c7)) + ## v2.3.0 - 2024.08.14 ### Added From 714bdba53827f78d714e9627f844d5618ed1605f Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 13:14:50 +0200 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a249840..cb4f484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## v2.3.1 - 2024.08.19 + ### Fixed - Fix facets applying on non-main queries ([#49](https://github.com/studiometa/wp-toolkit/issues/49), [#50](https://github.com/studiometa/wp-toolkit/pull/50), [9c098c7](https://github.com/studiometa/wp-toolkit/commit/9c098c7)) From c28b253d5f7fbcf8715d671d0a9bfcae368cad56 Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 13:19:32 +0200 Subject: [PATCH 6/7] Add a CLAUDE.md file --- CLAUDE.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..7f2b2ea --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,14 @@ +# WordPress Toolkit by Studio Meta + +## Development commands + +- `ddev start` to start the DDEV project where the PHPUnit tests will be run +- `ddev exec composer test` to run the PHPUnit tests +- `composer lint:style` to check for code quality with PHPCS +- `composer fix:style` to fix fixable errors reported by PHPCS +- `composer lint:static` to do static analysis with PHPStan + +## Guidelines + +- Follow existing patterns +- Follow modern PHP features and standard From 616957ba73a12cc42dd86a5e63e0ee04f307048e Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 19 Aug 2025 13:21:45 +0200 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4f484..b27b969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix facets applying on non-main queries ([#49](https://github.com/studiometa/wp-toolkit/issues/49), [#50](https://github.com/studiometa/wp-toolkit/pull/50), [9c098c7](https://github.com/studiometa/wp-toolkit/commit/9c098c7)) +### Added + +- Add a CLAUDE.md file ([c28b253](https://github.com/studiometa/wp-toolkit/commit/c28b253)) + ## v2.3.0 - 2024.08.14 ### Added