fix(acf): bootstrap Advanced Custom Fields integration - #16
Merged
nlemoine merged 6 commits intoJun 3, 2026
Merged
Conversation
nlemoine
self-requested a review
May 21, 2026 19:14
nlemoine
requested changes
May 21, 2026
Owner
There was a problem hiding this comment.
Good catch! thanks for that PR @huubl.
One thing I'd change, maybe use ACF direct API for this: acf_register_location_type, it includes some checks and also fires a acf/registered_location_type we're skipping when using the underlying logic.
nlemoine
force-pushed
the
copilot/add-advanced-custom-fields-integration
branch
from
May 21, 2026 19:37
dca4d74 to
c6b9451
Compare
AdvancedCustomFields.php was procedural top-level add_action code; the
file was never loaded because Composer PSR-4 only autoloads class files
and it is not listed in autoload.files. As a result the ACF location
type was never registered and `page_type == <cpt>_page` rules always
evaluated to false on ACF Pro 6.x.
Refactor the file into a class-based integration consistent with the
existing Polylang/WordPressSeo/Wpml/Autodescription composites:
- Implement IntegrationInterface with isSupported() + registerHooks().
- Guard isSupported() on class_exists('ACF_Location_Page_Type') so the
hook is only registered when ACF Pro's parent class is loaded.
- Register the integration in Container as a service factory.
- Add it to Plugin::getIntegrations() so plugin.php bootstraps it.
- Extend PluginTest and ContainerTest to cover the new integration.
ACF_Location_Page_Type class is loaded later during ACF’s init flow. Since this plugin checks integrations on plugins_loaded, the ACF integration will never register its acf/include_location_rules hook
huubl
force-pushed
the
copilot/add-advanced-custom-fields-integration
branch
from
May 22, 2026 09:47
ca54380 to
8691c2b
Compare
nlemoine
reviewed
May 22, 2026
Extend ACF's built-in page_type location rule with <cpt>_page values using the documented acf/location/rule_values/type=page_type and acf/location/match_rule/type=page_type filters, instead of removing and re-registering ACF's native location type. This augments core behavior without mutating ACF's location store or subclassing internal ACF classes, so it stays compatible across ACF updates. Api is injected via the container and the integration is wired into Plugin::getIntegrations() so it bootstraps with the others. Removes the LocationPageType subclass. Adds integration tests for both filters plus PluginTest/ContainerTest coverage, registers ACF in the test bootstrap, and adds a test:advanced-custom-fields composer script.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16 +/- ##
============================================
+ Coverage 76.47% 79.86% +3.39%
+ Complexity 500 494 -6
============================================
Files 32 31 -1
Lines 1356 1336 -20
============================================
+ Hits 1037 1067 +30
+ Misses 319 269 -50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
isSupported(), registerHooks() and the constructor otherwise run during the test bootstrap, before coverage collection starts, so they never register as covered. Instantiate the integration directly to exercise them, mirroring PolylangTest and WpmlTest. Also cover the two remaining match_rule branches: a screen pointing at a non-existent post, and a rule value that matches no bound post type. This brings AdvancedCustomFields to full line coverage.
The coverage job ran a per-plugin step for Polylang, WPML, WordPress SEO and AutoDescription but not Advanced Custom Fields, so the ACF integration never appeared in coverage reports. The integration-tests matrix also omitted ACF and WPML, so neither suite gated pull requests. Add the ACF coverage step and add test:advanced-custom-fields and test:wpml to the integration-tests matrix.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AdvancedCustomFields.php was procedural top-level add_action code; the file was never loaded because Composer PSR-4 only autoloads class files and it is not listed in autoload.files. As a result the ACF location type was never registered.