Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Check if value is string before applying filter, fixes #564 by seripap · Pull Request #565 · AdvancedCustomFields/acf · GitHub
Skip to content

Check if value is string before applying filter, fixes #564 - #565

Open
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1
Open

Check if value is string before applying filter, fixes #564#565
seripap wants to merge 1 commit into
AdvancedCustomFields:masterfrom
seripap:patch-1

Conversation

@seripap

Copy link
Copy Markdown

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 from wysiwyg 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.

@mattgrshaw

Copy link
Copy Markdown
Member

@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?

@seripap

Copy link
Copy Markdown
Author

Sure here's a full export which may be easier to reference

group_6183fcd1dabcb is using group_6183f883d77da as a clone.

group_6183f883d77da is the reference to 3 flexible content types. Within the first one is a layout called 'Components', which is a clone of group_6168389fcfc91.

Once a component is added that has a WYSIWYG field on it, the function referenced in the PR shows $value as [0] => component instead of a string

<?phpif( 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; 

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@mattgrshaw

Copy link
Copy Markdown
Member

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.

@seripap

Copy link
Copy Markdown
Author

No worries, thanks for the update

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seripap@mattgrshaw