Repository navigation
Update/removing tags #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amerk-sitecrafting
wants to merge
8
commits into
main
Choose a base branch
from
update/removing-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update/removing tags #175
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
17713de
adding functionality to Conifer to support removing tags
amerk-sitecrafting bd50a82
adding integration tests for tag removal
amerk-sitecrafting d334d5f
updating Site docs for tag removal
amerk-sitecrafting f1dc04d
fixing integration tests
amerk-sitecrafting e49e397
removing dead code, but I'm not 100% sure it is dead code
amerk-sitecrafting dd98091
Merge branch 'main' into update/removing-tags
amerk-sitecrafting 501320e
adding code review feedback and updating docs
amerk-sitecrafting 60ef334
maybe fixing tag disabled when declaring specific post types
amerk-sitecrafting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Test tag removal helpers on the Conifer\Site class. | ||
| * | ||
| * @copyright 2026 SiteCrafting, Inc. | ||
| * @package Conifer | ||
| */ | ||
|
|
||
| namespace Conifer\Integration; | ||
|
|
||
| class SiteTagRemovalTest extends Base | ||
| { | ||
| private const POST_TYPE_ONE = 'conifer_tag_test_one'; | ||
| private const POST_TYPE_TWO = 'conifer_tag_test_two'; | ||
| private const EXCLUDED_POST_TYPE = 'tribe_events'; | ||
|
|
||
| /** | ||
| * Post types associated with post_tag before each test. | ||
| * | ||
| * @var string[] | ||
| */ | ||
| private array $postTypesWithTags = []; | ||
|
|
||
| public function setUp(): void | ||
| { | ||
| parent::setUp(); | ||
|
|
||
| $this->postTypesWithTags = array_filter( | ||
| get_post_types([], 'names'), | ||
| function (string $postType): bool { | ||
| return is_object_in_taxonomy($postType, 'post_tag'); | ||
| } | ||
| ); | ||
|
|
||
| register_post_type(self::POST_TYPE_ONE, [ | ||
| 'public' => true, | ||
| 'taxonomies' => ['post_tag'], | ||
| ]); | ||
| register_post_type(self::POST_TYPE_TWO, [ | ||
| 'public' => true, | ||
| 'taxonomies' => ['post_tag'], | ||
| ]); | ||
| register_post_type(self::EXCLUDED_POST_TYPE, [ | ||
| 'public' => true, | ||
| 'taxonomies' => ['post_tag'], | ||
| ]); | ||
| } | ||
|
|
||
| public function tearDown(): void | ||
| { | ||
| foreach ([self::POST_TYPE_ONE, self::POST_TYPE_TWO, self::EXCLUDED_POST_TYPE] as $postType) { | ||
| unregister_post_type($postType); | ||
| } | ||
|
|
||
| foreach ($this->postTypesWithTags as $postType) { | ||
| register_taxonomy_for_object_type('post_tag', $postType); | ||
| } | ||
|
|
||
| parent::tearDown(); | ||
| } | ||
|
|
||
| public function test_disable_tags_for_post_types_removes_tags_only_from_specified_post_types() | ||
| { | ||
| $this->site->disable_tags_for_post_types([self::POST_TYPE_ONE]); | ||
|
|
||
| $this->assertFalse(is_object_in_taxonomy(self::POST_TYPE_ONE, 'post_tag')); | ||
| $this->assertTrue(is_object_in_taxonomy(self::POST_TYPE_TWO, 'post_tag')); | ||
| } | ||
|
|
||
| public function test_disable_tags_excludes_tribe_events_by_default() | ||
| { | ||
| $this->site->configure(function () { | ||
| $this->disable_tags(); | ||
| }, false); | ||
|
|
||
| $this->assertFalse(is_object_in_taxonomy(self::POST_TYPE_ONE, 'post_tag')); | ||
| $this->assertTrue(is_object_in_taxonomy(self::EXCLUDED_POST_TYPE, 'post_tag')); | ||
| } | ||
|
|
||
| public function test_disable_tags_honors_custom_excluded_post_types() | ||
| { | ||
| $excludedPostTypes = [self::POST_TYPE_ONE]; | ||
| $this->site->configure(function () use ($excludedPostTypes) { | ||
| $this->disable_tags($excludedPostTypes); | ||
| }, false); | ||
|
|
||
| $this->assertTrue(is_object_in_taxonomy(self::POST_TYPE_ONE, 'post_tag')); | ||
| $this->assertFalse(is_object_in_taxonomy(self::POST_TYPE_TWO, 'post_tag')); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably mention the
$this->disable_tags();function as well?