Last active
December 10, 2019 11:59
-
-
Save hwkdev/90abdb62fa27a25190d050098c4cb1db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('acf/render_field_group_settings', 'hwk_acf_field_groups_add_settings', 10); | |
function hwk_acf_field_groups_add_settings($group){ | |
/**************** | |
* Basic | |
****************/ | |
// Text | |
// Return: "hwk_text": "foo bar" | |
acf_render_field_wrap(array( | |
'label' => __('Texte','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'text', | |
'name' => 'hwk_text', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_text'])) ? $group['hwk_text'] : '', | |
'placeholder' => 'placeholder', | |
'prepend' => 'prefixe', | |
'append' => 'suffixe', | |
'maxlength' => 2 | |
)); | |
// Textarea | |
// Return: "hwk_textarea": "foo bar" | |
acf_render_field_wrap(array( | |
'label' => __('Textarea','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'textarea', | |
'name' => 'hwk_textarea', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_textarea'])) ? $group['hwk_textarea'] : '', | |
'placeholder' => 'placeholder', | |
'maxlength' => 2, | |
'rows' => 8, | |
'new_lines' => 'wpautop' // wpautop | br | (empty) | |
)); | |
// Number | |
// Return: "hwk_number": 1 | |
acf_render_field_wrap(array( | |
'label' => __('Number','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'number', | |
'name' => 'hwk_number', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_number'])) ? $group['hwk_number'] : '', | |
'placeholder' => 'placeholder', | |
'prepend' => 'prefixe', | |
'append' => 'suffixe', | |
'min' => 0, | |
'max' => 100, | |
'step' => 1 | |
)); | |
// Range | |
// Return: "hwk_range": 1 | |
acf_render_field_wrap(array( | |
'label' => __('Range','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'range', | |
'name' => 'hwk_range', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_range'])) ? $group['hwk_range'] : 0, | |
'prepend' => 'prefixe', | |
'append' => 'suffixe', | |
'min' => 0, | |
'max' => 100, | |
'step' => 1 | |
)); | |
// Return: "hwk_email": "[email protected]" | |
acf_render_field_wrap(array( | |
'label' => __('Email','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'email', | |
'name' => 'hwk_email', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_email'])) ? $group['hwk_email'] : '', | |
'placeholder' => 'placeholder', | |
'prepend' => 'prefixe', | |
'append' => 'suffixe' | |
)); | |
// URL | |
// Return: "hwk_url": "http://www.google.com" | |
acf_render_field_wrap(array( | |
'label' => __('URL','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'url', | |
'name' => 'hwk_url', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_url'])) ? $group['hwk_url'] : '', | |
'placeholder' => 'placeholder' | |
)); | |
// Password | |
// Return: "hwk_password": "foobar" | |
acf_render_field_wrap(array( | |
'label' => __('Password','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'password', | |
'name' => 'hwk_password', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_password'])) ? $group['hwk_password'] : '', | |
'placeholder' => 'placeholder', | |
'prepend' => 'prefixe', | |
'append' => 'suffixe' | |
)); | |
/**************** | |
* Content | |
****************/ | |
// Image | |
// Return: "hwk_image": 431 | |
acf_render_field_wrap(array( | |
'label' => __('Image','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'image', | |
'name' => 'hwk_image', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_image'])) ? $group['hwk_image'] : '', | |
'preview_size' => 'thumbnail', | |
//'min_width' => 10, | |
//'min_height' => 20, | |
//'max_width' => 100, | |
//'max_height' => 200, | |
//'min_size' => 5, | |
//'max_size' => 50, | |
//'mime_types' => 'jpg,pdf' | |
//'return_format' => 'url' | |
)); | |
// File | |
// Return: "hwk_file": 432 | |
acf_render_field_wrap(array( | |
'label' => __('File','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'file', | |
'name' => 'hwk_file', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_file'])) ? $group['hwk_file'] : '', | |
'min_size' => 5, | |
'max_size' => 50 | |
)); | |
// WYSIWYG | |
// Return: "hwk_wysiwyg": "<strong>Lorem ipsum</strong>" | |
acf_render_field_wrap(array( | |
'label' => __('WYSIWYG','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'wysiwyg', | |
'name' => 'hwk_wysiwyg', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_wysiwyg'])) ? $group['hwk_wysiwyg'] : '', | |
'tabs' => 'all', // all | visual | text | |
'toolbar' => 'full', // full | basic | |
'media_upload' => true // true | false | |
)); | |
// oEmbed | |
// Return: "hwk_oembed": "https://www.youtube.com/watch?v=s09Ldx2HdaA" | |
acf_render_field_wrap(array( | |
'label' => __('oEmbed','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'oembed', | |
'name' => 'hwk_oembed', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_oembed'])) ? $group['hwk_oembed'] : '', | |
'width' => 640, | |
'height' => 390 | |
)); | |
// Gallery | |
// Return: "hwk_gallery": ["431","433"] | |
acf_render_field_wrap(array( | |
'label' => __('Gallery','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'gallery', | |
'name' => 'hwk_gallery', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_gallery'])) ? $group['hwk_gallery'] : '', | |
'min' => 1, | |
'max' => 5, | |
'insert' => 'prepend' // prepend |append | |
)); | |
/**************** | |
* Choices | |
****************/ | |
// Select | |
// Return: "hwk_select": ["zero"] | |
acf_render_field_wrap(array( | |
'label' => __('Select','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'select', | |
'name' => 'hwk_select', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_select'])) ? $group['hwk_select'] : '', | |
'toggle' => false, | |
'choices' => array( | |
'zero' =>__('Zero', 'acf'), | |
'un' =>__('Un', 'acf'), | |
), | |
'allow_null' => true, // true | false | |
'multiple' => true, // true | false | |
'ui' => true, // true | false | |
'ajax' => false // true | false | |
)); | |
// Checkbox | |
// Return: "hwk_checkbox": ["FooBar"] | |
acf_render_field_wrap(array( | |
'label' => __('Checkbox','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'checkbox', | |
'name' => 'hwk_checkbox', | |
'key' => 'hwk_checkbox', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_checkbox'])) ? $group['hwk_checkbox'] : '', | |
'choices' => array( | |
'zero' =>__('Zero', 'acf'), | |
'un' =>__('Un', 'acf') | |
), | |
'allow_custom' => true, // true | false | |
'save_custom' => true, // true | false | |
'toggle' => true, // true | false | |
'layout' => 'vertical' // vertical | horizontal | |
)); | |
// Radio | |
// Return: "hwk_radio": "un" | |
acf_render_field_wrap(array( | |
'label' => __('Radio','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'radio', | |
'name' => 'hwk_radio', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_radio'])) ? $group['hwk_radio'] : '', | |
'choices' => array( | |
'zero' =>__('Zero', 'acf'), | |
'un' =>__('Un', 'acf'), | |
), | |
'allow_null' => true, // true | false | |
'other_choice' => true, // true | false | |
'save_other_choice' => true, // true | false | |
'layout' => 'vertical' // vertical | horizontal | |
)); | |
// Bouton Group | |
// Return: "hwk_button_group": "zero" | |
acf_render_field_wrap(array( | |
'label' => __('Button Group','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'button_group', | |
'name' => 'hwk_button_group', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_button_group'])) ? $group['hwk_button_group'] : '', | |
'choices' => array( | |
'zero' =>__('Zero', 'acf'), | |
'un' =>__('Un', 'acf'), | |
), | |
'allow_null' => true, // true | false | |
'layout' => 'horizontal' // vertical | horizontal | |
)); | |
// True False | |
// Return: "hwk_true_false": 1 | |
acf_render_field_wrap(array( | |
'label' => __('True / False','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'true_false', | |
'name' => 'hwk_true_false', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_true_false'])) ? $group['hwk_true_false'] : '', | |
'message' => 'Message', | |
'default_value' => true, // true | false | |
'ui' => true, // true | false | |
'ui_on_text' => 'Actif', | |
'ui_off_text' => 'Inactif' | |
)); | |
/**************** | |
* Relationnel | |
****************/ | |
// Link | |
// Return: "hwk_link": {"title": "Google","url": "http://www.google.com","target": "_blank"} | |
acf_render_field_wrap(array( | |
'label' => __('Link','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'link', | |
'name' => 'hwk_link', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_link'])) ? $group['hwk_link'] : '' | |
)); | |
// Post Object | |
// Return: "hwk_post_object": ["4"] | |
acf_render_field_wrap(array( | |
'label' => __('Post Object','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'post_object', | |
'name' => 'hwk_post_object', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_post_object'])) ? $group['hwk_post_object'] : '', | |
//'post_type' => array('post'), // Bugged | |
//'taxonomy' => array('category:non-classe'), // Bugged | |
'allow_null' => true, // true | false | |
'multiple' => true, // true | false | |
'ui' => true // true | false | |
)); | |
// Page Link | |
// Return: "hwk_page_link": ["5"] | |
acf_render_field_wrap(array( | |
'label' => __('Page Link','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'page_link', | |
'name' => 'hwk_page_link', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_page_link'])) ? $group['hwk_page_link'] : '', | |
//'post_type' => array('post'), // Bugged | |
//'taxonomy' => array('category:non-classe'), // Bugged | |
'allow_null' => true, // true | false | |
'allow_archives' => true, // true | false | |
'multiple' => true // true | false | |
)); | |
// Relationship | |
// Return: "hwk_relationship": ["4","5"] | |
acf_render_field_wrap(array( | |
'label' => __('Relationship','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'relationship', | |
'name' => 'hwk_relationship', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_relationship'])) ? $group['hwk_relationship'] : '', | |
//'post_type' => array('page'), // Bugged | |
//'taxonomy' => array('category:non-classe'), // Bugged | |
'filters' => array( | |
'search', | |
'post_type', | |
'taxonomy' | |
), | |
'elements' => array( | |
'featured_image' | |
), | |
'min'=> 1, | |
'max'=> 2 | |
)); | |
// Taxonomy | |
// Return multiple=true: "hwk_taxonomy": ["1","3"] | |
// Return multiple=false: "hwk_taxonomy": "1" | |
acf_render_field_wrap(array( | |
'label' => __('Taxonomy','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'taxonomy', | |
'name' => 'hwk_taxonomy', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_taxonomy'])) ? $group['hwk_taxonomy'] : '', | |
'taxonomy' => 'category', | |
'field_type' => 'checkbox', // checkbox | radio | multi_select (bugged) | select (bugged) | |
'allow_null' => true, // true | false | |
'add_term' => true, // true (bugged) | false | |
'save_terms' => true, // true | false | |
'load_terms' => true, // true | false | |
'multiple' => true // true | false | |
)); | |
// User | |
// Return multiple=true: "hwk_user": ["1","2"] | |
// Return multiple=false: "hwk_user": "1" | |
acf_render_field_wrap(array( | |
'label' => __('User','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'user', | |
'name' => 'hwk_user', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_user'])) ? $group['hwk_user'] : '', | |
//'role' => array('editor'), | |
'allow_null' => true, // true | false | |
'multiple' => true // true | false | |
)); | |
/**************** | |
* jQuery | |
****************/ | |
// Google Map | |
// Return: "hwk_google_map": {"address": "X621, Hangjin Qi, Eerduosi Shi, Neimenggu Zizhiqu, Chine","lat": "40.18782406112183","lng": "107.29687929153442"} | |
acf_render_field_wrap(array( | |
'label' => __('Google Map','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'google_map', | |
'name' => 'hwk_google_map', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_google_map'])) ? $group['hwk_google_map'] : '', | |
'center_lat' => '', | |
'center_lng' => '', | |
'zoom' => 1, | |
'height' => 200 | |
)); | |
// Date Picker | |
// Return: "hwk_date_picker": 20171219 | |
acf_render_field_wrap(array( | |
'label' => __('Date Picker','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'date_picker', | |
'name' => 'hwk_date_picker', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_date_picker'])) ? $group['hwk_date_picker'] : '', | |
'display_format' => 'd/m/Y', | |
'first_day' => 1 // 0 | 1 (Lundi) | 2 | 3 | 4 | 5 | 6 | |
)); | |
// Date Time Picker | |
// Return: "hwk_date_time_picker": "2017-12-19 15:00:00" | |
acf_render_field_wrap(array( | |
'label' => __('Date Time Picker','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'date_time_picker', | |
'name' => 'hwk_date_time_picker', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_date_time_picker'])) ? $group['hwk_date_time_picker'] : '', | |
'display_format' => 'd/m/Y g:i a', | |
'first_day' => 1 // 0 | 1 (Lundi) | 2 | 3 | 4 | 5 | 6 | |
)); | |
// Time Picker | |
// Return: "hwk_time_picker": "17:29:49" | |
acf_render_field_wrap(array( | |
'label' => __('Time Picker','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'time_picker', | |
'name' => 'hwk_time_picker', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_time_picker'])) ? $group['hwk_time_picker'] : '', | |
'display_format' => 'g:i a' | |
)); | |
// Color Picker | |
// Return: "hwk_color_picker": "#81d742" | |
acf_render_field_wrap(array( | |
'label' => __('Color Picker','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'color_picker', | |
'name' => 'hwk_color_picker', | |
'prefix' => 'acf_field_group', | |
'value' => (isset($group['hwk_color_picker'])) ? $group['hwk_color_picker'] : '' | |
)); | |
/**************** | |
* Disposition | |
****************/ | |
// Message | |
acf_render_field_wrap(array( | |
'label' => __('Message','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'message', | |
'name' => 'hwk_message', | |
'prefix' => 'acf_field_group', | |
'message' => 'Message', | |
'new_lines' => 'wpautop', // wpautop | br | (empty) | |
'esc_html' => true // true | false | |
)); | |
// Accordion | |
acf_render_field_wrap(array( | |
'label' => __('Accordion','acf'), | |
'instructions' => __('Instructions','acf'), | |
'type' => 'accordion', | |
'name' => 'hwk_accordion', | |
'key' => 'hwk_accordion', | |
'prefix' => 'acf_field_group', | |
'open' => false, // true | false | |
'multi_expand' => false, // true | false | |
'endpoint' => 0 | |
)); | |
// Tab | |
acf_render_field_wrap(array( | |
'label' => __('Tab','acf'), | |
'type' => 'tab', | |
'name' => 'hwk_tab_tab', | |
'key' => 'hwk_tab_tab', | |
'prefix' => 'acf_field_group', | |
'placement' => 'left', // top | left | |
'endpoint' => 0 | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment