Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Icon picker fatal error

Đang mở
#967 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php, wordpress
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại includes/fields/class-acf-field-icon_picker.php dòng 132 và tái hiện lỗi với tab tùy chỉnh cùng các bộ lọc biểu tượng được hiển thị trong issue. Sử dụng cấu hình block ACF được cung cấp và các phiên bản WordPress/PHP để xác nhận đường dẫn render bị lỗi. Hoàn thành khi trình chỉnh sửa trang tải block với bộ biểu tượng tùy chỉnh mà không gặp lỗi nghiêm trọng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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:

  1. Create an ACF block with an icon picker field with a custom icon set.
  2. 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',
        ]
    ];
});
  1. 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
Ngôn ngữ chính
PHP
Star
946
Fork
197
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AdvancedCustomFields/acf

Tất cả issue của AdvancedCustomFields/acf

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.