in web/wp-content/plugins/acf-extended/includes/acfe-field-group-functions.php [264:428]
function acfe_get_locations_array($locations){
$return = array();
$types = acf_get_location_rule_types();
if(!$locations || !$types){
return $return;
}
$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',
),
'admin-appearance' => array(
'acfe_template'
)
);
$rules = array();
foreach($types as $key => $type){
foreach($type as $slug => $name){
$icon = $icon_default;
foreach($icons as $_icon => $icon_slugs){
if(!in_array($slug, $icon_slugs)){
continue;
}
$icon = $_icon;
break;
}
$rules[ $slug ] = array(
'name' => $slug,
'label' => $name,
'icon' => $icon
);
}
}
foreach($locations as $group){
if(!acf_maybe_get($rules, $group['param']) || !acf_maybe_get($group, 'value')){
continue;
}
// init
$rule = $rules[ $group['param'] ];
// vars
$icon = $rule['icon'];
$name = $rule['name'];
$label = $rule['label'];
$operator = $group['operator'] === '==' ? '=' : $group['operator'];
$value = $group['value'];
// Exception for Post/Page/page Parent ID
if(in_array($group['param'], array('post', 'page', 'page_parent'))){
$value = get_the_title((int) $value);
}else{
// Validate value
$values = acf_get_location_rule_values($group);
if(!empty($values) && is_array($values)){
foreach($values as $value_slug => $value_name){
if($value != $value_slug){
continue;
}
$value = $value_name;
if(is_array($value_name) && isset($value_name[$value_slug])){
$value = $value_name[$value_slug];
}
break;
}
}
}
// html
$title = $label . ' ' . $operator . ' ' . $value;
$atts = array(
'class' => 'acf-js-tooltip dashicons dashicons-' . $icon,
'title' => $title
);
if($operator === '!='){
$atts['style'] = 'color: #ccc;';
}
$html = '<span ' . acf_esc_atts($atts) . '></span>';
$return[] = array(
'html' => $html,
'icon' => $icon,
'title' => $title,
'name' => $name,
'label' => $label,
'operator' => $operator,
'value' => $value,
);
}
return $return;
}