ID) != 'acf-field-group')
return $states;
$field_group = acf_get_field_group($post->ID);
if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
return $states;
$states[] = $field_group['acfe_display_title'];
return $states;
}
/**
* Table Columns
*/
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
function acfe_field_groups_column($columns){
// Fix 'Sync' screen columns
if(acf_maybe_get_GET('post_status') === 'sync'){
unset($columns['acf-field-group-category']);
return $columns;
}
// Locations
$columns['acfe-locations'] = __('Locations');
// Load
$columns['acfe-local'] = __('Load');
// PHP sync
if(acf_get_setting('acfe_php'))
$columns['acfe-autosync-php'] = __('PHP sync');
// Json sync
if(acf_get_setting('json'))
$columns['acfe-autosync-json'] = __('Json sync');
return $columns;
}
/**
* Table Columns HTML
*/
add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
function acfe_field_groups_column_html($column, $post_id){
/**
* Locations
*/
if($column == 'acfe-locations'){
$field_group = acf_get_field_group($post_id);
$choices = acf_get_location_rule_types();
if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
return;
$final = array();
$icon_default = 'admin-generic';
$icons = array(
'edit' => array(
'post_type',
'post_template',
'post_status',
'post_format',
'post',
),
'media-default' => array(
'page_template',
'page_type',
'page_parent',
'page',
),
'admin-users' => array(
'current_user',
'user_form',
),
'welcome-widgets-menus' => array(
'widget',
'nav_menu',
'nav_menu_item',
),
'category' => array(
'taxonomy',
'post_category',
'post_taxonomy',
),
'admin-comments' => array(
'comment',
),
'paperclip' => array(
'attachment',
),
'admin-settings' => array(
'options_page',
),
'businessman' => array(
'current_user_role',
'user_role',
),
);
foreach($choices as $key => $sub_choices){
foreach($sub_choices as $choice_slug => $choice_name){
$final_icon = $icon_default;
foreach($icons as $icon => $icon_slugs){
foreach($icon_slugs as $icon_slug){
if($choice_slug != $icon_slug)
continue;
$final_icon = $icon;
break(2);
}
}
$final[$choice_slug] = array(
'name' => $choice_name,
'icon' => $final_icon
);
}
}
$html = array();
foreach($field_group['location'] as $or){
foreach($or as $and){
if(!isset($final[$and['param']]))
continue;
$final_name = $and['value'];
$values = acf_get_location_rule_values($and);
if(!empty($values) && is_array($values)){
foreach($values as $value_slug => $value_name){
if($and['value'] != $value_slug)
continue;
$final_name = $value_name;
break;
}
}
$name = '';
if($and['operator'] == '!=')
$name = '';
$html[] = $name;
}
}
echo implode(' ', $html);
}
/**
* Load
*/
elseif($column == 'acfe-local'){
if(!$field_group = acf_get_field_group($post_id))
return;
$local_field_group = acf_get_local_field_group($field_group['key']);
$local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
if($local_field_group_type != 'php'){
echo __('DB');
return;
}
echo 'php';
}
/**
* PHP sync
*/
elseif($column == 'acfe-autosync-php'){
if(!$field_group = acf_get_field_group($post_id))
return;
if(!acfe_has_field_group_autosync($field_group, 'php')){
echo '';
if(acfe_has_field_group_autosync_file($field_group, 'php')){
echo '';
}
return;
}
if(!acf_get_setting('acfe_php_found')){
echo '';
echo '';
}
elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
echo '';
echo '';
}
else{
echo '';
}
}
/**
* Json sync
*/
elseif($column == 'acfe-autosync-json'){
if(!$field_group = acf_get_field_group($post_id))
return;
if(!acfe_has_field_group_autosync($field_group, 'json')){
echo '';
if(acfe_has_field_group_autosync_file($field_group, 'json'))
echo '';
return;
}
echo '';
if(!acfe_has_field_group_autosync_file($field_group, 'json'))
echo '';
}
}
/**
* Table Row Actions
*/
add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
function hwk_post_type_exemple_row_actions($actions, $post){
if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
return $actions;
$field_group = acf_get_field_group($post->ID);
$actions['acfe-export-php'] = 'PHP';
$actions['acfe-export-json'] = 'Json';
//$actions['acfe-id'] = 'ID: ' . $field_group['ID'] . '';
$actions['acfe-key'] = '' . $field_group['key'] . '';
return $actions;
}
/**
* Sidebar
*/
add_action('current_screen', function(){
if(!acf_is_screen('edit-acf-field-group'))
return;
add_action('admin_footer', function(){
?>