'Hide "Collapse"', 'add' => 'Hide "Add"', 'delete' => 'Hide "Delete"', 'duplicate' => 'Hide "Duplicate"', ); if(acf_version_compare(acf_get_setting('version'), '<', '5.9')){ acfe_unset($hide_choices, 'duplicate'); } // Hide Buttons acf_render_field_setting($field, array( 'label' => __('Hide Buttons'), 'name' => 'acfe_flexible_remove_button', 'key' => 'acfe_flexible_remove_button', 'instructions' => __('Hide buttons'), 'type' => 'checkbox', 'default_value' => '', 'layout' => 'horizontal', 'choices' => $hide_choices, 'conditional_logic' => array( array( array( 'field' => 'acfe_flexible_advanced', 'operator' => '==', 'value' => '1', ), ) ) )); } function validate_hide($field){ /* * Old settings: * * acfe_flexible_remove_add_button * acfe_flexible_remove_duplicate_button * acfe_flexible_remove_delete_button */ $hide = acf_get_array($field['acfe_flexible_remove_button']); // acfe_flexible_remove_add_button if(acf_maybe_get($field, 'acfe_flexible_remove_add_button')){ if(!in_array('add', $hide)) $hide[] = 'add'; acfe_unset($field, 'acfe_flexible_remove_add_button'); } // acfe_flexible_remove_duplicate_button if(acf_maybe_get($field, 'acfe_flexible_remove_duplicate_button')){ if(!in_array('duplicate', $hide)) $hide[] = 'duplicate'; acfe_unset($field, 'acfe_flexible_remove_duplicate_button'); } // acfe_flexible_remove_delete_button if(acf_maybe_get($field, 'acfe_flexible_remove_delete_button')){ if(!in_array('delete', $hide)) $hide[] = 'delete'; acfe_unset($field, 'acfe_flexible_remove_delete_button'); } $field['acfe_flexible_remove_button'] = $hide; return $field; } function remove_actions($return, $field){ if(!in_array('add', $field['acfe_flexible_remove_button'])) return $return; return true; } function layout_icons($icons, $layout, $field){ if(in_array('add', $field['acfe_flexible_remove_button'])) acfe_unset($icons, 'add'); if(in_array('duplicate', $field['acfe_flexible_remove_button'])) acfe_unset($icons, 'duplicate'); if(in_array('delete', $field['acfe_flexible_remove_button'])) acfe_unset($icons, 'delete'); return $icons; } } acf_new_instance('acfe_field_flexible_content_hide'); endif;