Skip to content

Add Locale from Tags snippet#2923

Merged
pfefferle merged 4 commits intotrunkfrom
add/locale-from-tags-snippet
Feb 16, 2026
Merged

Add Locale from Tags snippet#2923
pfefferle merged 4 commits intotrunkfrom
add/locale-from-tags-snippet

Conversation

@jeherve
Copy link
Member

@jeherve jeherve commented Feb 16, 2026

Proposed changes:

Other information:

  • Have you written new tests for your changes, if applicable?

This is a community snippet (a standalone micro-plugin in snippets/), not a change to the core plugin. No new tests are needed.

Testing instructions:

  1. Copy the snippets/locale-from-tags/ folder into wp-content/plugins/ and activate it.
  2. Create or edit a post and add a tag matching one of the default language codes (e.g. en, fr, de).
  3. Publish the post and check its ActivityPub JSON representation (append ?activitypub or check the outbox) — the contentMap key should reflect the tag's language code instead of the site's default locale.
  4. To test customization, add this to your theme's functions.php:
    add_filter(
        'activitypub_snippet_locale_from_tags_codes',
        function () {
            return array( 'en', 'fr', 'hu' );
        }
    );
    Verify that only tags matching the custom list are recognized.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Added - for new features

Message

Add Locale from Tags community snippet.

Adds a community snippet that sets a post's ActivityPub language
based on post tags matching language codes. Useful for multilingual
blogs that tag posts with language identifiers like 'en', 'fr', 'de'.
Guards against WP_Error, which is a possible return type.
Matches defensive patterns used elsewhere in the codebase.
Copilot AI review requested due to automatic review settings February 16, 2026 09:45
@jeherve jeherve added Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. Enhancement labels Feb 16, 2026
@jeherve jeherve self-assigned this Feb 16, 2026
@jeherve jeherve requested a review from a team February 16, 2026 09:45
@github-actions github-actions bot added the Docs label Feb 16, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new community snippet that automatically sets a post's ActivityPub language based on tags matching language codes (e.g., en, fr, de), enabling proper language metadata for multilingual WordPress sites in the Fediverse.

Changes:

  • New locale-from-tags snippet with filter hook to detect language code tags and override the default locale
  • Documentation explaining installation, configuration, and usage
  • Entry in the main snippets README listing the new snippet

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
snippets/locale-from-tags/locale-from-tags.php Core snippet implementation with set_locale_from_tags() function and filter hook
snippets/locale-from-tags/README.md Documentation covering installation, requirements, configuration, and origin
snippets/README.md Added entry for the new snippet in the snippets directory table
.github/changelog/2923-from-description Changelog entry for this patch addition

@jeherve jeherve removed the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Feb 16, 2026
Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! ♥️

@pfefferle pfefferle merged commit 4d78947 into trunk Feb 16, 2026
10 checks passed
@pfefferle pfefferle deleted the add/locale-from-tags-snippet branch February 16, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants