-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if value is string before applying filter, fixes #564 #565
base: master
Are you sure you want to change the base?
Conversation
@seripap Thanks for the PR! To make sure we're on the same page, would you be able to share an export of a field group where you're seeing this issue? |
Sure here's a full export which may be easier to reference
Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows <?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_6183fcd1dabcb',
'title' => 'Homepage Template',
'fields' => array(
array(
'key' => 'field_6183fcd656f95',
'label' => 'Content',
'name' => 'pageContent',
'type' => 'clone',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'clone' => array(
0 => 'field_6183f888691b9',
),
'display' => 'seamless',
'layout' => 'block',
'prefix_label' => 0,
'prefix_name' => 0,
'acfe_field_group_condition' => 0,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
array(
array(
'param' => 'page_template',
'operator' => '==',
'value' => 'index.php',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'left',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'acfe_autosync' => array(
0 => 'json',
),
'acfe_form' => 0,
'acfe_display_title' => '',
'acfe_meta' => '',
'acfe_note' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'contents',
'map_graphql_types_from_location_rules' => 0,
'graphql_types' => '',
));
acf_add_local_field_group(array(
'key' => 'group_6183f883d77da',
'title' => 'Page Content',
'fields' => array(
array(
'key' => 'field_6183f888691b9',
'label' => 'Content',
'name' => 'content',
'type' => 'flexible_content',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'acfe_flexible_advanced' => 0,
'layouts' => array(
'layout_6183f8950d198' => array(
'key' => 'layout_6183f8950d198',
'name' => 'components',
'label' => 'Components',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_6183f89a691ba',
'label' => 'Component',
'name' => 'component',
'type' => 'clone',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'clone' => array(
0 => 'field_616838a5ba9e2',
),
'display' => 'seamless',
'layout' => 'block',
'prefix_label' => 0,
'prefix_name' => 0,
'acfe_field_group_condition' => 0,
),
),
'min' => '',
'max' => '',
'acfe_flexible_render_template' => false,
'acfe_flexible_render_style' => false,
'acfe_flexible_render_script' => false,
'acfe_flexible_thumbnail' => false,
'acfe_flexible_settings' => false,
'acfe_flexible_settings_size' => 'medium',
'acfe_layout_locations' => array(
),
'acfe_flexible_modal_edit_size' => false,
'acfe_flexible_category' => false,
'acfe_layout_col' => 'auto',
'acfe_layout_allowed_col' => false,
),
'layout_6183f8ba691bb' => array(
'key' => 'layout_6183f8ba691bb',
'name' => 'blocks',
'label' => 'Blocks',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_6183f8c2691bc',
'label' => 'Block',
'name' => 'block',
'type' => 'post_object',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'post_type' => array(
0 => 'block',
),
'taxonomy' => '',
'allow_null' => 0,
'multiple' => 0,
'max' => '',
'return_format' => 'object',
'acfe_add_post' => 0,
'acfe_edit_post' => 0,
'save_custom' => 0,
'save_post_status' => 'publish',
'acfe_bidirectional' => array(
'acfe_bidirectional_enabled' => '0',
),
'acfe_field_group_condition' => 0,
'ui' => 1,
),
),
'min' => '',
'max' => '',
'acfe_flexible_render_template' => false,
'acfe_flexible_render_style' => false,
'acfe_flexible_render_script' => false,
'acfe_flexible_thumbnail' => false,
'acfe_flexible_settings' => false,
'acfe_flexible_settings_size' => 'medium',
'acfe_layout_locations' => array(
),
'acfe_flexible_modal_edit_size' => false,
'acfe_flexible_category' => false,
'acfe_layout_col' => 'auto',
'acfe_layout_allowed_col' => false,
),
'layout_6183f8dd691bd' => array(
'key' => 'layout_6183f8dd691bd',
'name' => 'scenarios',
'label' => 'Scenarios',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_6183f8e1691be',
'label' => 'Scenario',
'name' => 'scenario',
'type' => 'post_object',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'post_type' => array(
0 => 'scenario',
),
'taxonomy' => '',
'allow_null' => 0,
'multiple' => 0,
'max' => '',
'return_format' => 'object',
'acfe_add_post' => 0,
'acfe_edit_post' => 0,
'save_custom' => 0,
'save_post_status' => 'publish',
'acfe_bidirectional' => array(
'acfe_bidirectional_enabled' => '0',
),
'acfe_field_group_condition' => 0,
'ui' => 1,
),
),
'min' => '',
'max' => '',
'acfe_flexible_render_template' => false,
'acfe_flexible_render_style' => false,
'acfe_flexible_render_script' => false,
'acfe_flexible_thumbnail' => false,
'acfe_flexible_settings' => false,
'acfe_flexible_settings_size' => 'medium',
'acfe_layout_locations' => array(
),
'acfe_flexible_modal_edit_size' => false,
'acfe_flexible_category' => false,
'acfe_layout_col' => 'auto',
'acfe_layout_allowed_col' => false,
),
),
'button_label' => 'Add Content',
'min' => '',
'max' => '',
'acfe_field_group_condition' => 0,
'acfe_flexible_stylised_button' => false,
'acfe_flexible_hide_empty_message' => false,
'acfe_flexible_empty_message' => '',
'acfe_flexible_layouts_templates' => false,
'acfe_flexible_layouts_previews' => false,
'acfe_flexible_layouts_placeholder' => false,
'acfe_flexible_layouts_thumbnails' => false,
'acfe_flexible_layouts_settings' => false,
'acfe_flexible_layouts_locations' => false,
'acfe_flexible_async' => array(
),
'acfe_flexible_add_actions' => array(
),
'acfe_flexible_remove_button' => array(
),
'acfe_flexible_layouts_state' => false,
'acfe_flexible_modal_edit' => array(
'acfe_flexible_modal_edit_enabled' => false,
'acfe_flexible_modal_edit_size' => 'large',
),
'acfe_flexible_modal' => array(
'acfe_flexible_modal_enabled' => false,
'acfe_flexible_modal_title' => false,
'acfe_flexible_modal_size' => 'full',
'acfe_flexible_modal_col' => '4',
'acfe_flexible_modal_categories' => false,
),
'acfe_flexible_grid' => array(
'acfe_flexible_grid_enabled' => false,
'acfe_flexible_grid_align' => 'center',
'acfe_flexible_grid_valign' => 'stretch',
'acfe_flexible_grid_wrap' => false,
),
'acfe_flexible_grid_container' => false,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => false,
'description' => '',
'acfe_autosync' => array(
0 => 'json',
),
'acfe_form' => 0,
'acfe_display_title' => '',
'acfe_meta' => '',
'acfe_note' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'homepage',
'map_graphql_types_from_location_rules' => 0,
'graphql_types' => '',
));
acf_add_local_field_group(array(
'key' => 'group_616835be9ab8d',
'title' => 'Page Metadata',
'fields' => array(
array(
'key' => 'field_616835c51a987',
'label' => 'Title',
'name' => 'title',
'type' => 'text',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_616835cd1a988',
'label' => 'Description',
'name' => 'description',
'type' => 'textarea',
'instructions' => 'SEO Description.',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'maxlength' => 155,
'rows' => '',
'new_lines' => '',
),
array(
'key' => 'field_616835e41a989',
'label' => 'Image',
'name' => 'image',
'type' => 'image',
'instructions' => 'Optional image to render for SEO.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'return_format' => 'url',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => array(
0 => 'the_content',
1 => 'excerpt',
),
'active' => true,
'description' => 'Basic metadata for a page.',
'acfe_autosync' => array(
0 => 'json',
),
'acfe_form' => 1,
'acfe_display_title' => 'Page Metadata',
'acfe_permissions' => '',
'acfe_meta' => '',
'acfe_note' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'pageMetadata',
'map_graphql_types_from_location_rules' => 0,
'graphql_types' => '',
));
acf_add_local_field_group(array(
'key' => 'group_6168389fcfc91',
'title' => 'Global Components',
'fields' => array(
array(
'key' => 'field_616838a5ba9e2',
'label' => 'Component',
'name' => 'components',
'type' => 'flexible_content',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'hide_field' => '',
'hide_label' => '',
'hide_instructions' => '',
'hide_required' => '',
'instruction_placement' => '',
'acfe_permissions' => '',
'show_in_graphql' => 1,
'acfe_flexible_advanced' => 1,
'acfe_flexible_stylised_button' => 1,
'acfe_flexible_layouts_templates' => 0,
'acfe_flexible_layouts_placeholder' => 0,
'acfe_flexible_layouts_thumbnails' => 0,
'acfe_flexible_layouts_settings' => 0,
'acfe_flexible_layouts_locations' => 0,
'acfe_flexible_async' => array(
),
'acfe_flexible_add_actions' => array(
),
'acfe_flexible_remove_button' => array(
),
'acfe_flexible_layouts_state' => 'user',
'acfe_flexible_modal_edit' => array(
'acfe_flexible_modal_edit_enabled' => '0',
'acfe_flexible_modal_edit_size' => 'large',
),
'acfe_flexible_modal' => array(
'acfe_flexible_modal_enabled' => '1',
'acfe_flexible_modal_title' => 'Components',
'acfe_flexible_modal_size' => 'full',
'acfe_flexible_modal_col' => '4',
'acfe_flexible_modal_categories' => '1',
),
'acfe_flexible_grid' => array(
'acfe_flexible_grid_enabled' => '0',
'acfe_flexible_grid_align' => 'center',
'acfe_flexible_grid_valign' => 'stretch',
'acfe_flexible_grid_wrap' => false,
),
'layouts' => array(
'layout_61698847abf16' => array(
'key' => 'layout_61698847abf16',
'name' => 'content_block',
'label' => 'Content Block',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_6169886fabf19',
'label' => 'Content',
'name' => 'content',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
'acfe_wysiwyg_height' => 300,
'acfe_wysiwyg_max_height' => '',
'acfe_wysiwyg_valid_elements' => '',
'acfe_wysiwyg_custom_style' => '',
'acfe_wysiwyg_disable_wp_style' => 0,
'acfe_wysiwyg_autoresize' => 0,
'acfe_wysiwyg_disable_resize' => 0,
'acfe_wysiwyg_remove_path' => 0,
'acfe_wysiwyg_menubar' => 0,
'acfe_wysiwyg_transparent' => 0,
'acfe_wysiwyg_merge_toolbar' => 0,
'acfe_wysiwyg_custom_toolbar' => 0,
'acfe_field_group_condition' => 0,
),
),
'min' => '',
'max' => '',
'acfe_flexible_category' => array(
0 => 'Generic',
),
'acfe_flexible_render_template' => false,
'acfe_flexible_render_style' => false,
'acfe_flexible_render_script' => false,
'acfe_flexible_thumbnail' => false,
'acfe_flexible_settings' => false,
'acfe_flexible_settings_size' => 'medium',
'acfe_layout_locations' => array(
),
'acfe_flexible_modal_edit_size' => false,
'acfe_layout_col' => 'auto',
'acfe_layout_allowed_col' => false,
),
'layout_617c55d30aab4' => array(
'key' => 'layout_617c55d30aab4',
'name' => 'hero',
'label' => 'Hero',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'field_617c55eb0aab5',
'label' => 'Title',
'name' => 'title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'hide_field' => '',
'hide_label' => '',
'hide_instructions' => '',
'hide_required' => '',
'instruction_placement' => '',
'acfe_permissions' => '',
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
),
array(
'key' => 'field_617c55f60aab6',
'label' => 'Description',
'name' => 'description',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'hide_field' => '',
'hide_label' => '',
'hide_instructions' => '',
'hide_required' => '',
'instruction_placement' => '',
'acfe_permissions' => '',
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
'acfe_textarea_code' => 0,
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
),
array(
'key' => 'field_617c56210aab7',
'label' => 'Buttons',
'name' => 'buttons',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'hide_field' => '',
'hide_label' => '',
'hide_instructions' => '',
'hide_required' => '',
'instruction_placement' => '',
'acfe_permissions' => '',
'show_in_graphql' => 1,
'acfe_repeater_stylised_button' => 0,
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => 'Add Button',
'acfe_settings' => '',
'acfe_field_group_condition' => 0,
'sub_fields' => array(
array(
'key' => 'field_617c56a80aab8',
'label' => 'Label',
'name' => 'label',
'type' => 'text',
'instructions' => 'The label for the button',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
),
array(
'key' => 'field_617c56f90aab9',
'label' => 'Color',
'name' => 'color',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'choices' => array(
'primary' => 'Primary',
'secondary' => 'Secondary',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'max' => '',
'ui' => 0,
'return_format' => 'value',
'prepend' => '',
'append' => '',
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_617c57700aaba',
'label' => 'Link',
'name' => 'link',
'type' => 'url',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
),
array(
'key' => 'field_617c58770aabb',
'label' => 'Open in New Page?',
'name' => 'new_page',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'message' => '',
'default_value' => 0,
'ui' => 0,
'acfe_settings' => '',
'acfe_validate' => '',
'acfe_field_group_condition' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
),
),
),
'min' => '',
'max' => '',
'acfe_flexible_category' => array(
0 => 'Generic',
),
'acfe_flexible_render_template' => false,
'acfe_flexible_render_style' => false,
'acfe_flexible_render_script' => false,
'acfe_flexible_thumbnail' => false,
'acfe_flexible_settings' => false,
'acfe_flexible_settings_size' => 'medium',
'acfe_layout_locations' => array(
),
'acfe_flexible_modal_edit_size' => false,
'acfe_layout_col' => 'auto',
'acfe_layout_allowed_col' => false,
),
),
'button_label' => 'Add Component',
'min' => '',
'max' => '',
'acfe_settings' => '',
'acfe_field_group_condition' => 0,
'acfe_flexible_hide_empty_message' => false,
'acfe_flexible_empty_message' => '',
'acfe_flexible_layouts_previews' => false,
'acfe_flexible_grid_container' => false,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 2,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => false,
'description' => 'Reusable components- Use as a `clone` within ACF fields.',
'acfe_autosync' => array(
0 => 'json',
),
'acfe_form' => 1,
'acfe_display_title' => 'Components',
'acfe_permissions' => '',
'acfe_meta' => '',
'acfe_note' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'components',
'map_graphql_types_from_location_rules' => 0,
'graphql_types' => '',
));
endif; |
Thanks! Unfortunately I wasn't able to replicate the problem with that field group, but I don't see the harm in adding some type checking here, especially since we already do this with similar fields. I've raised an issue on our internal repo and will look at getting this into a future release. Thanks again for flagging and raising a PR. |
Hi @seripap, just a heads up that we've released 5.11 today, but unfortunately weren't able to get this into that release (we were late in the release cycle when you submitted this PR). I've triaged that to our 5.11.1 bugfix release so it will be included then, but if you update to 5.11 in the meantime, you'll need to apply this fix again manually. |
No worries, thanks for the update |
In my setup, I have a
clone
field that is represented as flexible content. Within this flexible content, 3 different high level fields exist: clone (flexible content), or post objects.When nested Flexible Content > Flexible Content > Content (WYSIWYG in this case), ACF triggers
apply_filters
fromwysiwyg
field. The input$value
is an array in my scenario, which causes the admin panel to throw an error. This just adds a string check before applying the filter.