Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/4195347c8d07cf1a048814c80f3b486f to your computer and use it in GitHub Desktop.
Save hawkidoki/4195347c8d07cf1a048814c80f3b486f to your computer and use it in GitHub Desktop.
<?php
add_action('acf/field_group/admin_head', 'hwk_acf_flexible_layout_metabox');
function hwk_acf_flexible_layout_metabox(){
global $field_group;
$match = false;
foreach($field_group['location'] as $location){
foreach($location as $rule){
if($rule['param'] == 'hwk_flexible_content_rule'){
$match = true;
break;
}
}
}
if(!$match)
return;
add_meta_box('acf-field-group-options-flexible-group', __('Options Flexible', 'acf'), function(){
global $field_group;
if(!acf_is_field_group_key( $field_group['key']))
$field_group['key'] = uniqid('group_');
$group = $field_group;
acf_render_field_wrap(array(
'label' => __('Titre','acf'),
'type' => 'text',
'name' => 'hwk_flexible_group_title',
'prefix' => 'acf_field_group',
'value' => (isset($group['hwk_flexible_group_title'])) ? $group['hwk_flexible_group_title'] : $field_group['title'],
));
acf_render_field_wrap(array(
'label' => __('Image','acf'),
'type' => 'image',
'name' => 'hwk_flexible_group_image',
'prefix' => 'acf_field_group',
'value' => (isset($group['hwk_flexible_group_image'])) ? $group['hwk_flexible_group_image'] : '',
'preview_size' => "thumbnail",
));
?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
acf.postbox.render({
'id': 'acf-field-group-options-flexible-group',
'label': 'left'
});
}
</script>
<?php
}, 'acf-field-group', 'normal', 'high');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment