AdvancedCustomFields / AdvancedCustomFields/acf
Custom attributes no longer work in ACF using pre_save_block
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
When using the latest version of WordPress and ACF you can no longer save custom attributes on a block using pre_save_block. In the documentation for the 6.0 release it gives some code examples such as:
add_filter(
'acf/pre_save_block',
function( $attributes ) {
if ( empty( $attributes['id'] ) ) {
$attributes['id'] = 'acf-block-' . uniqid();
}
return $attributes;
}
);
however this no longer works. It strips any attributes not defined in the function acf_get_block_type_default_attributes. If I add an attribute to that $attributes array in acf_get_block_type_default_attributes then it does not strip away my custom attributes. Please restore this functionality or add a filter to the $attributes in acf_get_block_type_default_attributes so we can have custom attributes. After removing the ID attribute and calling it not a breaking change and it breaking stuff now there are more breaking changes, very unfortunate.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the acf/pre_save_block filter into acf_get_block_type_default_attributes and compare how custom attributes are handled in the reported WordPress and ACF versions. The issue is done when custom block attributes can be saved again without manually adding them to the default attributes array, with the behavior covered by the relevant tests if present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend, content
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100