AdvancedCustomFields / AdvancedCustomFields/acf
Icon picker fatal error
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When using the icon picker field type in a custom ACF block with a custom icon set I am getting the following error when trying to edit a page where that block is used:
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-icon_picker.php:132 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(324): acf_field_icon_picker->render_field(Array) #1 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #2 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #3 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-hook-functions.php(113): do_action_ref_array('acf/render_fiel...', Array) #4 /var/www/html/wp-includes/class-wp-hook.php(324): _acf_apply_hook_variations(Array) #5 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #6 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(807): do_action('acf/render_fiel...', Array) #8 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(763): acf_render_field(Array) #9 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(614): acf_render_field_wrap(Array, 'div', 'field') #10 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(613): acf_render_fields(Array, 'block_32caf81ff...', 'div', 'field') #11 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(543): acf_rendered_block(Array, '', true, 1307, Object(WP_Block)) #12 /var/www/html/wp-includes/class-wp-block.php(586): acf_render_block_callback(Array, '', Object(WP_Block)) #13 /var/www/html/wp-includes/blocks.php(2358): WP_Block->render() #14 /var/www/html/wp-includes/blocks.php(2410): render_block(Array) #15 /var/www/html/wp-includes/class-wp-hook.php(324): do_blocks('<!-- wp:acf/her...') #16 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters('<!-- wp:acf/her...', Array) #17 /var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1961): apply_filters('the_content', '<!-- wp:acf/her...') #18 /var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(655): WP_REST_Posts_Controller->prepare_item_for_response(Object(WP_Post), Object(WP_REST_Request)) #19 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1292): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request)) #20 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/pages/(?...', Array, NULL) #21 /var/www/html/wp-includes/rest-api.php(586): WP_REST_Server->dispatch(Object(WP_REST_Request)) #22 /var/www/html/wp-includes/rest-api.php(2973): rest_do_request(Object(WP_REST_Request)) #23 [internal function]: rest_preload_api_request(Array, '/wp/v2/pages/13...') #24 /var/www/html/wp-includes/block-editor.php(754): array_reduce(Array, 'rest_preload_ap...', Array) #25 /var/www/html/wp-admin/edit-form-blocks.php(114): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context)) #26 /var/www/html/wp-admin/post.php(187): require('/var/www/html/w...') #27 {main} thrown in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-icon_picker.php on line 132
To Reproduce
Steps to reproduce the behavior:
- Create an ACF block with an icon picker field with a custom icon set.
- Use the following code (or similar) in functions.php to manage the custom icon set
add_filter('acf/fields/icon_picker/tabs', function(array $tabs): array {
$tabs['nwlp'] = 'NWLP';
return $tabs;
});
add_filter('acf/fields/icon_picker/nwlp/icons', function(array $icons): array {
$base_url = get_template_directory_uri() . '/assets/images/icons/';
return [
[
'url' => $base_url . 'accreditations.svg',
'key' => 'accreditations',
'label' => 'Accreditations',
],
[
'url' => $base_url . 'audio-podcast.svg',
'key' => 'audio-podcast',
'label' => 'Audio podcast',
]
];
});
- Try to insert/edit a page where this block is embedded and the error should show.
Expected behavior
No error to show
Code
{
"key": "group_687639d742f8f",
"title": "Block: Icon",
"fields": [
{
"key": "field_687639d70f893",
"label": "Icon",
"name": "icon",
"aria-label": "",
"type": "icon_picker",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"tabs": [
"nwlp"
],
"return_format": "array",
"allow_in_bindings": 0,
"library": "all",
"default_value": {
"type": null,
"value": null
}
},
{
"key": "field_68763a145e4e2",
"label": "Icon Colour",
"name": "icon_colour",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"blue": "Blue",
"green": "Green",
"pink": "Pink"
},
"default_value": false,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 0,
"ui": 0,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
}
],
"location": [
[
{
"param": "block",
"operator": "==",
"value": "acf\/icon"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1752583984
}
Version Information:
- WordPress Version 6.8.2
- PHP Version 8.2.28
- ACF Version ACF Pro 6.4.3
- Browser Chrome 138
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 at includes/fields/class-acf-field-icon_picker.php line 132 and reproduce the failure with the custom tab and icon filters shown in the issue. Use the supplied ACF block configuration and WordPress/PHP versions to confirm the failing render path. Done means the page editor loads the block with the custom icon set without a fatal error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100