feat: implement brand override backend logic #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Add support for overriding the current brand via URL parameter (
?brand=brand-slug) and filters.newspack_brand_overridefilter for custom override logic.Rules:
The brand override system follows these rules:
How to test the changes in this Pull Request:
Posts (Single Brand)
brand‑a)./my‑post) and verify that the post's brand (brand‑a) is used.?brand=brand‑b(or any other brand slug) to the URL and reload.brand‑a) is still used (i.e. the override is ignored).Posts (Multiple Brands)
brand‑aandbrand‑b). Optionally, set a primary brand./my‑multi‑brand‑post) and verify that (if a primary brand is set) that brand is used.?brand=brand‑a(or?brand=brand‑b) and reload.?brand=non‑existent‑brandand reload. Verify that if a primary brand is set the primary brand is used. Otherwise, the post should be neutral.Author Archives
/author/author‑name) and verify that the author's primary brand is used.?brand=brand‑aor any other brand slug that is not the primary for the author and reload.?brand=brand‑aor any other valid brand slug.brand‑a) is used.Term Archives (Categories/Tags)
/category/my‑cat) and verify that the primary brand (or ancestor's primary brand) is used.?brand=brand‑aor any other brand slug that is not the primary for the category and reload.?brand=brand‑aor any other valid brand slug.brand‑a) is used.Brand Archives
/brand‑a) and verify that the brand (brand‑a) is used.?brand=brand‑b(or any other brand slug) and reload.brand‑a) is still used (the override is ignored).Homepage
/) and verify that the page is neutral (no brand is used).?brand=brand‑a(or any other brand slug) and reload.Custom Override (Filter)
newspack_brand_overrideand verify that the filter's logic (for example, overriding with a different brand or returning null) is applied as expected.Other information: