Skip to content

Refactor Friend Tag#583

Merged
akirk merged 1 commit intomainfrom
refactor-friend-tag
Feb 6, 2026
Merged

Refactor Friend Tag#583
akirk merged 1 commit intomainfrom
refactor-friend-tag

Conversation

@akirk
Copy link
Copy Markdown
Owner

@akirk akirk commented Jan 2, 2026

Summary

Extracts the friend_tag taxonomy logic into a dedicated Friend_Tag class (includes/class-friend-tag.php), replacing scattered inline usage of the taxonomy throughout the codebase.

Changes

  • New Friend_Tag class with static methods for all tag operations: register(), has_tag(), has_mention(), add_tag(), add_tags(), mention_tag(), remove_tag(), cleanup_orphaned(), etc.
  • Friends class now delegates to Friend_Tag::register() and Friend_Tag::cleanup_orphaned() instead of inlining the taxonomy registration and cleanup logic. Friends::TAG_TAXONOMY references Friend_Tag::TAXONOMY.
  • Feed class uses Friend_Tag::add_tags() instead of calling wp_set_post_terms() directly for both friend_tags and friend_mention_tags.
  • ActivityPub parser uses Friend_Tag::mention_tag() to build mention slugs and Friend_Tag::has_mention() to check for mentions before queuing reply-to-comment conversion.
  • Migration class replaces inline wp_get_post_terms() + prefix-matching loops with Friend_Tag::has_mention() and uses Friend_Tag::mention_tag() for building mention slugs.
  • Enable Mastodon Apps integration uses Friend_Tag::mention_tag() instead of hardcoding the mention- prefix.

Motivation

The mention- prefix and friend_tag taxonomy name were hardcoded in many places. This consolidates them behind constants (Friend_Tag::TAXONOMY, Friend_Tag::MENTION_PREFIX) and a single class, making the tag system easier to maintain and less error-prone.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 2, 2026

Test this PR in WordPress Playground

You can test this pull request directly in WordPress Playground:

Launch WordPress Playground

This will install and activate the plugin with the changes from this PR.

@akirk akirk force-pushed the refactor-friend-tag branch from 64cbc44 to 40d42b4 Compare February 6, 2026 07:10
@akirk akirk merged commit 583cd25 into main Feb 6, 2026
25 checks passed
@akirk akirk deleted the refactor-friend-tag branch February 6, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant