Repository navigation
fix(export): register post meta in PHP export - #544
faisalahammad wants to merge 2 commits into
Conversation
Exported field groups now include register_post_meta() calls for eligible fields, so exported fields work with block bindings in block themes without manual registration. Fixes WordPress#384
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Pass explicit flags to html_entity_decode() so single quote entities decode the same on PHP 7.4 and 8.x. Match the editor preview menu item with a tolerant pattern because WP trunk renamed it to Preview (opens in a new tab). Refs WordPress#544
|
CI fixes for the failing checks: f9fb7ce
The E2E change also fixes the editor preview fixture on trunk for other PRs, since trunk E2E started failing after the label rename. Refs #384 |
|
Thanks for the contribution and the effort here! 🙏 A heads-up on how this repo works: a large part of SCF's codebase (field types, Flexible Content, Blocks v3, local fields, forms, value formatting, and most of includes/ and assets/src/js/) is regularly synced from an upstream codebase. Any change we make there, whether a bug fix or a new feature, gets overwritten or causes hard merge conflicts on the next sync. That includes features behind a beta flag. Fixes for those areas arrive through the sync itself, so we can't accept PRs that touch that code, even good ones. |
Generated PHP now includes
register_post_meta()calls for fields that are eligible, so exported field groups work with block bindings in block themes without manual registration. Previously the export only emittedacf_add_local_field_group()andregister_post_type(), so block bindings reported the field as not registered and it did not show in the bindings picker.Closes #384
What gets registered
A field is exported as post meta only when all of these are true:
post_type == <slug>rule. Groups with mixed or broader rules are skipped rather than guessed.string,boolean,integer,number). Multi value fields such as checkbox, repeater, gallery, or relationship are skipped, since they cannot be registered as single native meta safely.The output is added to the existing export as a separate block:
The existing
acf_add_local_field_group()output is unchanged, so this is additive.Files changed
includes/acf-field-group-functions.php- helper functions to resolve concrete post types from location rules, decide which fields can be registered, and build the exported PHP.includes/admin/tools/class-acf-admin-tool-export.php- prints the post meta block alongside the field group export.tests/php/includes/test-acf-field-group-functions.php- tests for scalar export, multiple post types, skipped fields, and ambiguous locations.How to test
bookpost type.register_post_meta( 'book', ... )call for the field.Testing done
composer test:phppasses: 2947 tests, 22753 assertions.composer lint:phpand the phpcs changed lines check pass on the changed files.Use of AI Tools
This pull request was developed with assistance from GLM 5.3. The tool was used for repository investigation, implementation support, test planning, and review. The final code, tests, and submitted changes were reviewed and verified by the contributor.