__('Stylised button'), 'name' => 'acfe_flexible_stylised_button', 'key' => 'acfe_flexible_stylised_button', 'instructions' => __('Better layouts button integration'), 'type' => 'true_false', 'message' => '', 'default_value' => false, 'ui' => true, 'ui_on_text' => '', 'ui_off_text' => '', ), true); // Hide Empty Message acf_render_field_setting($field, array( 'label' => __('Hide Empty Message'), 'name' => 'acfe_flexible_hide_empty_message', 'key' => 'acfe_flexible_hide_empty_message', 'instructions' => __('Hide the empty message box'), 'type' => 'true_false', 'message' => '', 'default_value' => false, 'ui' => true, 'ui_on_text' => '', 'ui_off_text' => '', 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_stylised_button', 'operator' => '!=', 'value' => '1', ), ) ) ), true); // Empty Message acf_render_field_setting($field, array( 'label' => __('Empty Message'), 'name' => 'acfe_flexible_empty_message', 'key' => 'acfe_flexible_empty_message', 'instructions' => __('Text displayed when the flexible field is empty'), 'type' => 'text', 'placeholder' => _('Click the "Add Row" button below to start creating your layout'), 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_stylised_button', 'operator' => '!=', 'value' => '1', ), array( 'field' => 'acfe_flexible_hide_empty_message', 'operator' => '!=', 'value' => '1', ) ) ) ), true); // Layouts thumbnails acf_render_field_setting($field, array( 'label' => __('Layouts Thumbnails'), 'name' => 'acfe_flexible_layouts_thumbnails', 'key' => 'acfe_flexible_layouts_thumbnails', 'instructions' => __('Display thumbnails for each layout. You need to save the field group to take effect'), 'type' => 'true_false', 'message' => '', 'default_value' => false, 'ui' => true, 'ui_on_text' => '', 'ui_off_text' => '', ), true); // Layouts render acf_render_field_setting($field, array( 'label' => __('Layouts Render'), 'name' => 'acfe_flexible_layouts_templates', 'key' => 'acfe_flexible_layouts_templates', 'instructions' => __('Display PHP template, style & javascript includes fields. You need to save the field group to take effect'), 'type' => 'true_false', 'message' => '', 'default_value' => false, 'ui' => true, 'ui_on_text' => '', 'ui_off_text' => '', ), true); // Modal acf_render_field_setting($field, array( 'label' => __('Modal'), 'name' => 'acfe_flexible_modal', 'key' => 'acfe_flexible_modal', 'instructions' => __('Use modal for layout selection'), 'type' => 'group', 'layout' => 'block', 'sub_fields' => array( array( 'label' => '', 'name' => 'acfe_flexible_modal_enabled', 'key' => 'acfe_flexible_modal_enabled', 'type' => 'true_false', 'instructions' => '', 'required' => false, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'message' => '', 'default_value' => false, 'ui' => true, 'ui_on_text' => '', 'ui_off_text' => '', 'conditional_logic' => false, ), array( 'label' => '', 'name' => 'acfe_flexible_modal_title', 'key' => 'acfe_flexible_modal_title', 'type' => 'text', 'prepend' => __('Title'), 'placeholder' => 'Add Row', 'instructions' => false, 'required' => false, 'wrapper' => array( 'width' => '35', 'class' => '', 'id' => '', ), 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_modal_enabled', 'operator' => '==', 'value' => '1', ) ) ) ), array( 'label' => '', 'name' => 'acfe_flexible_modal_col', 'key' => 'acfe_flexible_modal_col', 'type' => 'select', 'prepend' => '', 'instructions' => false, 'required' => false, 'choices' => array( '1' => '1 column', '2' => '2 columns', '3' => '3 columns', '4' => '4 columns', '5' => '5 columns', '6' => '6 columns', ), 'default_value' => '4', 'wrapper' => array( 'width' => '15', 'class' => '', 'id' => '', ), 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_modal_enabled', 'operator' => '==', 'value' => '1', ) ) ) ), array( 'label' => '', 'name' => 'acfe_flexible_modal_categories', 'key' => 'acfe_flexible_modal_categories', 'type' => 'true_false', 'message' => __('Categories'), 'instructions' => false, 'required' => false, 'wrapper' => array( 'width' => '15', 'class' => '', 'id' => '', ), 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_modal_enabled', 'operator' => '==', 'value' => '1', ) ) ) ), ) ), true); // Layouts State acf_render_field_setting($field, array( 'label' => __('Layouts State'), 'name' => 'acfe_flexible_layouts_state', 'key' => 'acfe_flexible_layouts_state', 'instructions' => __('Force layouts to be collapsed or opened'), 'type' => 'select', 'allow_null' => true, 'choices' => array( 'collapse' => 'Collapsed', 'open' => 'Opened', ) ), true); } add_action('acf/render_field', 'acfe_flexible_layouts_settings', 0); function acfe_flexible_layouts_settings($field){ if($field['_name'] != 'label' || stripos($field['name'], 'layout_') === false) return; $layout_prefix = $field['prefix']; preg_replace_callback('/\[(.*?)\]/', function($m) use (&$arr){ $arr[] = explode(',',preg_replace('/([\w]+)/', "$1", $m[1])); }, $layout_prefix); $layout_key = $arr[2][0]; $field_flexible_id = $arr[0][0]; $field_flexible = acf_get_field($field_flexible_id); $layout = $field_flexible['layouts'][$layout_key]; $echo = false; $is_flexible_layouts_thumbnails = isset($field_flexible['acfe_flexible_layouts_thumbnails']) && !empty($field_flexible['acfe_flexible_layouts_thumbnails']); $is_flexible_layouts_templates = isset($field_flexible['acfe_flexible_layouts_templates']) && !empty($field_flexible['acfe_flexible_layouts_templates']); $is_flexible_modal_enabled = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']); $is_flexible_modal_categories = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']); if($is_flexible_layouts_thumbnails || $is_flexible_layouts_templates || ($is_flexible_modal_enabled && $is_flexible_modal_categories)){ $echo = true; ?> '; echo '
'; acf_render_field_wrap(array( 'label' => false, 'name' => 'acfe_flexible_thumbnail', 'type' => 'image', 'class' => '', 'prefix' => $layout_prefix, 'value' => $acfe_flexible_thumbnail, 'return_format' => 'array', 'preview_size' => 'thumbnail', 'library' => 'all', )); echo ''; } // Template if($is_flexible_layouts_templates){ $acfe_flexible_render_template = isset($layout['acfe_flexible_render_template']) ? $layout['acfe_flexible_render_template'] : ''; echo '