本文整理汇总了PHP中acf_get_field_group_visibility函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_get_field_group_visibility函数的具体用法?PHP acf_get_field_group_visibility怎么用?PHP acf_get_field_group_visibility使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_get_field_group_visibility函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acf_filter_field_groups
function acf_filter_field_groups($field_groups, $args = false)
{
// bail early if no options
if (empty($args)) {
return $field_groups;
}
if (!empty($field_groups)) {
$keys = array_keys($field_groups);
foreach ($keys as $key) {
$visibility = acf_get_field_group_visibility($field_groups[$key], $args);
if (!$visibility) {
unset($field_groups[$key]);
}
}
$field_groups = array_values($field_groups);
}
return $field_groups;
}
示例2: acf_filter_field_groups
function acf_filter_field_groups($field_groups, $args = false)
{
// bail early if empty sargs
if (empty($args) || empty($field_groups)) {
return $field_groups;
}
// vars
$keys = array_keys($field_groups);
// loop through keys
foreach ($keys as $key) {
// get visibility
$visibility = acf_get_field_group_visibility($field_groups[$key], $args);
// unset
if (!$visibility) {
unset($field_groups[$key]);
}
}
// re assign index
$field_groups = array_values($field_groups);
// return
return $field_groups;
}
示例3: render_field
function render_field($field)
{
global $post, $self;
if (is_object($post)) {
$current_id = $post->ID;
} elseif ($self === "profile.php") {
$current_id = "user_" . $_GET["user_id"];
} elseif ($self === "comment.php") {
$current_id = "comment_" . $_GET["c"];
} else {
$current_id = "options";
}
$name_prefix = '';
// Geniem addition: get field group to get the visibility settings
$field_groups = acf_get_field_groups();
foreach ($field_groups as $group) {
if ($group["key"] == $field["group_key"]) {
$contents = $group;
break;
}
}
$contents["active"] = true;
// Geniem addition: set a variable that we are including the field group
// this variable will be checked in the visibility condition check
$this->included = "true";
// Geniem addition: check the visibility rules and return false if not visible
if (!acf_get_field_group_visibility($contents)) {
return false;
}
if (isset($field['parent'])) {
preg_match_all('/\\[(field_\\w+)\\](\\[(\\d+)\\])?/', $field['prefix'], $parent_fields);
if (isset($parent_fields[0])) {
foreach ($parent_fields[0] as $parent_field_index => $parent_field) {
$field_name = $parent_fields[1][$parent_field_index];
$index = $parent_fields[3][$parent_field_index];
$parent_field_object = acf_get_field($field_name);
$parent_prefix = $parent_field_object['name'];
if ($index !== '') {
$parent_prefix .= '_' . $index;
}
$name_prefix .= $parent_prefix . '_';
}
}
$name_prefix .= $field['_name'] . '_';
}
foreach ($field['sub_fields'] as $sub_field) {
$sub_name_prefix = $name_prefix;
$sub_field_name = $sub_field['name'];
// update prefix to allow for nested values
$sub_field['prefix'] = $field["name"];
$sub_field['name'] = "{$name_prefix}{$sub_field_name}";
// load value
if ($sub_field['value'] === null) {
$sub_field['value'] = acf_get_value($current_id, $sub_field);
}
// render input
acf_render_field_wrap($sub_field);
}
}
示例4: admin_head
function admin_head()
{
// vars
$style_found = false;
// get field groups
$field_groups = acf_get_field_groups();
// add meta boxes
if (!empty($field_groups)) {
foreach ($field_groups as $i => $field_group) {
// vars
$id = "acf-{$field_group['key']}";
$title = $field_group['title'];
$context = $field_group['position'];
$priority = 'high';
$args = array('field_group' => $field_group, 'visibility' => false);
// tweaks to vars
if ($context == 'side') {
$priority = 'core';
}
// filter for 3rd party customization
$priority = apply_filters('acf/input/meta_box_priority', $priority, $field_group);
// visibility
$args['visibility'] = acf_get_field_group_visibility($field_group, array('post_id' => $this->post_id, 'post_type' => $this->typenow));
// add meta box
add_meta_box($id, $title, array($this, 'render_meta_box'), $this->typenow, $context, $priority, $args);
// update style
if (!$style_found && $args['visibility']) {
$style_found = true;
$this->style = acf_get_field_group_style($field_group);
}
}
// foreach($acfs as $acf)
}
// if($acfs)
// Allow 'acf_after_title' metabox position
add_action('edit_form_after_title', array($this, 'edit_form_after_title'));
// remove ACF from meta postbox
add_filter('is_protected_meta', array($this, 'is_protected_meta'), 10, 3);
}
示例5: is_field_group_visible
/**
* Check if a given field group matches a given set of location rules
*
* @param array $field_group ACF field group (array format varies between the free and Pro versions of ACF)
* @param array $filters ACF location rules
* @return bool
*/
public static function is_field_group_visible($field_group, $filters)
{
if (self::is_pro_installed()) {
return acf_get_field_group_visibility($field_group, $filters);
} else {
$filtered_field_group_ids = apply_filters('acf/location/match_field_groups', array(), $filters);
return in_array($field_group['id'], $filtered_field_group_ids);
}
}