edit pages

This commit is contained in:
razusrest
2024-04-18 17:45:44 +05:45
parent f4e3b7c750
commit 46f1b89d3d
3923 changed files with 1838473 additions and 156 deletions

View File

@ -0,0 +1,178 @@
<?php
// vars
$disabled = false;
// empty
if ( empty( $field['conditional_logic'] ) ) {
$disabled = true;
$field['conditional_logic'] = array(
// group 0
array(
// rule 0
array(),
),
);
}
?>
<div class="acf-field acf-field-true-false acf-field-setting-conditional_logic" data-type="true_false" data-name="conditional_logic">
<div class="acf-conditional-toggle">
<div class="acf-label">
<?php $acf_label_for = acf_idify( $field['prefix'] . '[conditional_logic]' ); ?>
<label for="<?php echo esc_attr( $acf_label_for ); ?>"><?php _e( 'Conditional Logic', 'acf' ); ?></label>
</div>
<div class="acf-input">
<?php
acf_render_field(
array(
'type' => 'true_false',
'name' => 'conditional_logic',
'prefix' => $field['prefix'],
'value' => $disabled ? 0 : 1,
'ui' => 1,
'class' => 'conditions-toggle',
)
);
?>
</div>
</div>
<div class="rule-groups"
<?php
if ( $disabled ) {
echo ' style="display:none"';
}
?>
>
<?php
foreach ( $field['conditional_logic'] as $group_id => $group ) :
// validate
if ( empty( $group ) ) {
continue;
}
// vars
// $group_id must be completely different to $rule_id to avoid JS issues
$group_id = "group_{$group_id}";
$h4 = ( $group_id == 'group_0' ) ? __( 'Show this field if', 'acf' ) : __( 'or', 'acf' );
?>
<div class="rule-group" data-id="<?php echo $group_id; ?>">
<h4><?php echo $h4; ?></h4>
<table class="acf-table -clear">
<tbody>
<?php
foreach ( $group as $rule_id => $rule ) :
// valid rule
$rule = wp_parse_args(
$rule,
array(
'field' => '',
'operator' => '',
'value' => '',
)
);
// vars
// $group_id must be completely different to $rule_id to avoid JS issues
$rule_id = "rule_{$rule_id}";
$prefix = "{$field['prefix']}[conditional_logic][{$group_id}][{$rule_id}]";
// data attributes
$attributes = array(
'data-id' => $rule_id,
'data-field' => $rule['field'],
'data-operator' => $rule['operator'],
'data-value' => $rule['value'],
);
?>
<tr class="rule" <?php echo acf_esc_attrs( $attributes ); ?>>
<td class="param">
<?php
acf_render_field(
array(
'type' => 'select',
'prefix' => $prefix,
'name' => 'field',
'class' => 'condition-rule-field',
'disabled' => $disabled,
'value' => $rule['field'],
'choices' => array(
$rule['field'] => $rule['field'],
),
)
);
?>
</td>
<td class="operator">
<?php
acf_render_field(
array(
'type' => 'select',
'prefix' => $prefix,
'name' => 'operator',
'class' => 'condition-rule-operator',
'disabled' => $disabled,
'value' => $rule['operator'],
'choices' => array(
$rule['operator'] => $rule['operator'],
),
)
);
?>
</td>
<td class="value">
<?php
// create field
acf_render_field(
array(
'type' => 'select',
'prefix' => $prefix,
'name' => 'value',
'class' => 'condition-rule-value',
'disabled' => $disabled,
'value' => $rule['value'],
'choices' => array(
$rule['value'] => $rule['value'],
),
)
);
?>
</td>
<td class="add">
<a href="#" class="button add-conditional-rule"><?php _e( 'and', 'acf' ); ?></a>
</td>
<td class="remove">
<a href="#" class="acf-icon -minus remove-conditional-rule"></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endforeach; ?>
<h4><?php _e( 'or', 'acf' ); ?></h4>
<a href="#" class="button add-conditional-group"><?php _e( 'Add rule group', 'acf' ); ?></a>
</div>
</div>

View File

@ -0,0 +1,328 @@
<?php
//phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file.
// Define input name prefix using unique identifier.
$input_prefix = 'acf_fields[' . $field['ID'] . ']';
$input_id = acf_idify( $input_prefix );
// Update field props.
$field['prefix'] = $input_prefix;
// Elements.
$div_attrs = array(
'class' => 'acf-field-object acf-field-object-' . acf_slugify( $field['type'] ),
'data-id' => $field['ID'],
'data-key' => $field['key'],
'data-type' => $field['type'],
);
// Add additional class if the field is an endpoint.
if ( isset( $field['endpoint'] ) && $field['endpoint'] ) {
$div_attrs['class'] .= ' acf-field-is-endpoint';
}
// Misc template vars.
$field_label = acf_get_field_label( $field, 'admin' );
$field_type_label = acf_get_field_type_label( $field['type'] );
if ( acf_is_pro() && acf_get_field_type_prop( $field['type'], 'pro' ) && ! acf_pro_is_license_active() ) {
$field_type_label .= '<span class="acf-pro-label acf-pro-label-field-type">PRO</span>';
}
if ( ! isset( $num_field_groups ) ) {
$num_field_groups = 0;
}
$conditional_logic_class = $conditional_logic_text = '';
if ( isset( $field['conditional_logic'] ) && is_array( $field['conditional_logic'] ) && count( $field['conditional_logic'] ) > 0 ) {
$conditional_logic_class = ' is-enabled';
$conditional_logic_text = __( 'Active', 'acf' );
}
?>
<div <?php echo acf_esc_attrs( $div_attrs ); ?>>
<div class="meta">
<?php
$meta_inputs = array(
'ID' => $field['ID'],
'key' => $field['key'],
'parent' => $field['parent'],
'menu_order' => $i,
'save' => '',
);
foreach ( $meta_inputs as $k => $v ) :
acf_hidden_input(
array(
'name' => $input_prefix . '[' . $k . ']',
'value' => $v,
'id' => $input_id . '-' . $k,
)
);
endforeach;
?>
</div>
<div class="handle">
<ul class="acf-hl acf-tbody">
<li class="li-field-order">
<span class="acf-icon acf-sortable-handle" title="<?php _e( 'Drag to reorder', 'acf' ); ?>"><?php echo ( $i + 1 ); ?></span>
</li>
<li class="li-field-label">
<strong>
<a class="edit-field" title="<?php _e( 'Edit field', 'acf' ); ?>" href="#"><?php echo acf_esc_html( $field_label ); ?></a>
</strong>
<div class="row-options">
<a class="edit-field" title="<?php _e( 'Edit field', 'acf' ); ?>" href="#"><?php _e( 'Edit', 'acf' ); ?></a>
<a class="duplicate-field" title="<?php _e( 'Duplicate field', 'acf' ); ?>" href="#"><?php _e( 'Duplicate', 'acf' ); ?></a>
<?php if ( $num_field_groups > 1 ) : ?>
<a class="move-field" title="<?php _e( 'Move field to another group', 'acf' ); ?>" href="#"><?php _e( 'Move', 'acf' ); ?></a>
<?php endif; ?>
<a class="delete-field" title="<?php _e( 'Delete field', 'acf' ); ?>" href="#"><?php _e( 'Delete', 'acf' ); ?></a>
</div>
</li>
<li class="li-field-name"><span class="copyable"><?php echo esc_html( $field['name'] ); ?></span></li>
<li class="li-field-key"><span class="copyable"><?php echo esc_html( $field['key'] ); ?></span></li>
<li class="li-field-type">
<i class="field-type-icon field-type-icon-<?php echo acf_slugify( $field['type'] ); ?>"></i>
<span class="field-type-label">
<?php echo acf_esc_html( $field_type_label ); ?>
</span>
</li>
</ul>
</div>
<div class="settings">
<div class="acf-field-editor">
<div class="acf-field-settings acf-fields">
<?php
foreach ( acf_get_combined_field_type_settings_tabs() as $tab_key => $tab_label ) {
$field_to_render = array(
'type' => 'tab',
'label' => $tab_label,
'key' => 'acf_field_settings_tabs',
'settings-type' => $tab_key,
);
if ( $tab_key === 'conditional_logic' ) {
$field_to_render['label'] = __( 'Conditional Logic', 'acf' ) . '<i class="conditional-logic-badge' . $conditional_logic_class . '">' . $conditional_logic_text . '</i>';
}
acf_render_field_wrap( $field_to_render );
?>
<?php
$wrapper_class = str_replace( '_', '-', $tab_key );
?>
<div class="acf-field-settings-main acf-field-settings-main-<?php echo esc_attr( $wrapper_class ); ?>">
<?php
switch ( $tab_key ) {
case 'general':
$field_type_select_class = 'field-type';
if ( ! apply_filters( 'acf/field_group/enable_field_type_select2', true ) ) {
$field_type_select_class .= ' disable-select2';
}
// type
acf_render_field_setting(
$field,
array(
'label' => __( 'Field Type', 'acf' ),
'instructions' => '',
'type' => 'select',
'name' => 'type',
'choices' => acf_get_grouped_field_types(),
'class' => $field_type_select_class,
),
true
);
if ( apply_filters( 'acf/field_group/enable_field_browser', true ) ) {
?>
<div class="acf-field acf-field-setting-browse-fields" data-append="type">
<div class="acf-input">
<button class="acf-btn browse-fields">
<i class="acf-icon acf-icon-dots-grid"></i>
<?php _e( 'Browse Fields', 'acf' ); ?>
</button>
</div>
</div>
<?php
}
// label
acf_render_field_setting(
$field,
array(
'label' => __( 'Field Label', 'acf' ),
'instructions' => __( 'This is the name which will appear on the EDIT page', 'acf' ),
'name' => 'label',
'type' => 'text',
'class' => 'field-label',
),
true
);
// name
acf_render_field_setting(
$field,
array(
'label' => __( 'Field Name', 'acf' ),
'instructions' => __( 'Single word, no spaces. Underscores and dashes allowed', 'acf' ),
'name' => 'name',
'type' => 'text',
'class' => 'field-name',
),
true
);
// 3rd party settings
do_action( 'acf/render_field_settings', $field );
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}", $field );
?>
<div class="acf-field-type-settings" data-parent-tab="<?php echo esc_attr( $tab_key ); ?>">
<?php
do_action( "acf/render_field_settings/type={$field['type']}", $field );
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}/type={$field['type']}", $field );
do_action( "acf/render_field_{$tab_key}_settings/type={$field['type']}", $field );
?>
</div>
<?php
break;
case 'validation':
// required
acf_render_field_setting(
$field,
array(
'label' => __( 'Required', 'acf' ),
'instructions' => '',
'type' => 'true_false',
'name' => 'required',
'ui' => 1,
'class' => 'field-required',
),
true
);
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}", $field );
?>
<div class="acf-field-type-settings" data-parent-tab="<?php echo esc_attr( $tab_key ); ?>">
<?php
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}/type={$field['type']}", $field );
do_action( "acf/render_field_{$tab_key}_settings/type={$field['type']}", $field );
?>
</div>
<?php
break;
case 'presentation':
acf_render_field_setting(
$field,
array(
'label' => __( 'Instructions', 'acf' ),
'instructions' => __( 'Instructions for authors. Shown when submitting data', 'acf' ),
'type' => 'textarea',
'name' => 'instructions',
'rows' => 5,
),
true
);
acf_render_field_wrap(
array(
'label' => '',
'instructions' => '',
'type' => 'text',
'name' => 'class',
'prefix' => $field['prefix'] . '[wrapper]',
'value' => $field['wrapper']['class'],
'prepend' => __( 'class', 'acf' ),
'wrapper' => array(
'data-append' => 'wrapper',
),
),
'div'
);
acf_render_field_wrap(
array(
'label' => '',
'instructions' => '',
'type' => 'text',
'name' => 'id',
'prefix' => $field['prefix'] . '[wrapper]',
'value' => $field['wrapper']['id'],
'prepend' => __( 'id', 'acf' ),
'wrapper' => array(
'data-append' => 'wrapper',
),
),
'div'
);
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}", $field );
?>
<div class="acf-field-type-settings" data-parent-tab="<?php echo esc_attr( $tab_key ); ?>">
<?php
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}/type={$field['type']}", $field );
do_action( "acf/render_field_{$tab_key}_settings/type={$field['type']}", $field );
?>
</div>
<?php
acf_render_field_wrap(
array(
'label' => __( 'Wrapper Attributes', 'acf' ),
'instructions' => '',
'type' => 'number',
'name' => 'width',
'prefix' => $field['prefix'] . '[wrapper]',
'value' => $field['wrapper']['width'],
'prepend' => __( 'width', 'acf' ),
'append' => '%',
'wrapper' => array(
'data-name' => 'wrapper',
'class' => 'acf-field-setting-wrapper',
),
),
'div'
);
break;
case 'conditional_logic':
acf_get_view( 'acf-field-group/conditional-logic', array( 'field' => $field ) );
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}", $field );
?>
<div class="acf-field-type-settings" data-parent-tab="<?php echo esc_attr( $tab_key ); ?>">
<?php
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}/type={$field['type']}", $field );
do_action( "acf/render_field_{$tab_key}_settings/type={$field['type']}", $field );
?>
</div>
<?php
break;
default:
// Global action hook for custom tabs.
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}", $field );
?>
<div class="acf-field-type-settings" data-parent-tab="<?php echo esc_attr( $tab_key ); ?>">
<?php
// Type-specific action hook for custom tabs.
do_action( "acf/field_group/render_field_settings_tab/{$tab_key}/type={$field['type']}", $field );
do_action( "acf/render_field_{$tab_key}_settings/type={$field['type']}", $field );
?>
</div>
<?php
}
?>
</div>
<?php
}
?>
<div class="acf-field-settings-footer">
<a class="button close-field edit-field" title="<?php _e( 'Close Field', 'acf' ); ?>" href="#"><?php _e( 'Close Field', 'acf' ); ?></a>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,135 @@
<?php
//phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- template include file
$field_groups = acf_get_field_groups();
$num_field_groups = 0;
if ( is_array( $field_groups ) ) {
$num_field_groups = count( $field_groups );
}
$is_subfield = ! empty( $is_subfield );
$wrapper_class = '';
if ( $is_subfield ) {
$wrapper_class = ' acf-is-subfields';
if ( ! $fields ) {
$wrapper_class .= ' -empty';
}
} elseif ( ! $fields && ! $parent ) {
/**
* Filter for determining if a new field group should render with a text field automatically
*
* @since 6.2
*
* @param bool $bool If an empty field group should render with a new field auto appended.
*/
if ( apply_filters( 'acf/field_group/auto_add_first_field', true ) ) {
$wrapper_class = ' acf-auto-add-field';
} else {
$wrapper_class = ' -empty';
}
}
?>
<?php if ( $parent || $is_subfield ) { ?>
<div class="acf-sub-field-list-header">
<h3 class="acf-sub-field-list-title"><?php _e( 'Fields', 'acf' ); ?></h3>
<a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php _e( 'Add Field', 'acf' ); ?></a>
</div>
<?php } ?>
<?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed string output ?>
<div class="acf-field-list-wrap<?php echo $wrapper_class; ?>">
<ul class="acf-hl acf-thead">
<li class="li-field-order">
<?php
/* translators: A symbol (or text, if not available in your locale) meaning "Order Number", in terms of positional placement. */
_e( '#', 'acf' );
?>
<span class="acf-hidden">
<?php
/* translators: Hidden accessibility text for the positional order number of the field. */
_e( 'Order', 'acf' );
?>
</span>
</li>
<li class="li-field-label"><?php _e( 'Label', 'acf' ); ?></li>
<li class="li-field-name"><?php _e( 'Name', 'acf' ); ?></li>
<li class="li-field-key"><?php _e( 'Key', 'acf' ); ?></li>
<li class="li-field-type"><?php _e( 'Type', 'acf' ); ?></li>
</ul>
<?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed string output ?>
<div class="acf-field-list<?php echo $wrapper_class; ?>">
<div class="no-fields-message">
<div class="no-fields-message-inner">
<img src="<?php echo acf_get_url( 'assets/images/empty-group.svg' ); ?>" />
<h2><?php _e( 'Add Your First Field', 'acf' ); ?></h2>
<p><?php _e( 'Get started creating new custom fields for your posts, pages, custom post types and other WordPress content.', 'acf' ); ?></p>
<a href="#" class="acf-btn acf-btn-primary add-field add-first-field
"><i class="acf-icon acf-icon-plus"></i> <?php _e( 'Add Field', 'acf' ); ?></a>
<p class="acf-small">
<?php
printf(
/* translators: %s url to field types list */
__( 'Choose from over 30 field types. <a href="%s" target="_blank">Learn more</a>.', 'acf' ),
acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/', 'docs', 'empty-field-group', 'field-types' )
);
?>
</p>
</div>
</div>
<?php
if ( $fields ) :
foreach ( $fields as $i => $field ) :
acf_get_view(
'acf-field-group/field',
array(
'field' => $field,
'i' => $i,
'num_field_groups' => $num_field_groups,
)
);
endforeach;
endif;
?>
</div>
<ul class="acf-hl acf-tfoot">
<li class="acf-fr">
<a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php _e( 'Add Field', 'acf' ); ?></a>
</li>
</ul>
<?php
if ( ! $parent ) :
// get clone
$clone = acf_get_valid_field(
array(
'ID' => 'acfcloneindex',
'key' => 'acfcloneindex',
'label' => __( 'New Field', 'acf' ),
'name' => 'new_field',
'type' => 'text',
)
);
?>
<script type="text/html" id="tmpl-acf-field">
<?php
acf_get_view(
'acf-field-group/field',
array(
'field' => $clone,
'i' => 0,
'num_field_groups' => $num_field_groups,
)
);
?>
</script>
<script type="text/html" id="tmpl-acf-browse-fields-modal">
<?php acf_get_view( 'browse-fields-modal' ); ?>
</script>
<?php endif; ?>
</div>

View File

@ -0,0 +1,26 @@
<script>document.body.classList.add('acf-no-field-groups');</script>
<div class="acf-no-field-groups-wrapper">
<div class="acf-no-field-groups-inner">
<img src="<?php echo acf_get_url( 'assets/images/empty-group.svg' ); ?>" />
<h2><?php _e( 'Add Your First Field Group', 'acf' ); ?></h2>
<p>
<?php
printf(
/* translators: %s url to creating a field group page */
__( 'ACF uses <a href="%s" target="_blank">field groups</a> to group custom fields together, and then attach those fields to edit screens.', 'acf' ),
acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/creating-a-field-group/', 'docs', 'no-field-groups' )
);
?>
</p>
<a href="<?php echo admin_url( 'post-new.php?post_type=acf-field-group' ); ?>" class="acf-btn"><i class="acf-icon acf-icon-plus"></i> <?php _e( 'Add Field Group', 'acf' ); ?></a>
<p class="acf-small">
<?php
printf(
/* translators: %s url to getting started guide */
__( 'New to ACF? Take a look at our <a href="%s" target="_blank">getting started guide</a>.', 'acf' ),
acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/getting-started-with-acf/', 'docs', 'no-field-groups' )
);
?>
</p>
</div>
</div>

View File

@ -0,0 +1,29 @@
<div class="rule-group" data-id="<?php echo $group_id; ?>">
<h4><?php echo ( $group_id == 'group_0' ) ? __( 'Show this field group if', 'acf' ) : __( 'or', 'acf' ); ?></h4>
<table class="acf-table -clear">
<tbody>
<?php
foreach ( $group as $i => $rule ) :
// validate rule
$rule = acf_validate_location_rule( $rule );
// append id and group
$rule['id'] = "rule_{$i}";
$rule['group'] = $group_id;
// view
acf_get_view(
'acf-field-group/location-rule',
array(
'rule' => $rule,
)
);
endforeach;
?>
</tbody>
</table>
</div>

View File

@ -0,0 +1,89 @@
<?php
// vars
$prefix = 'acf_field_group[location][' . $rule['group'] . '][' . $rule['id'] . ']';
?>
<tr data-id="<?php echo $rule['id']; ?>">
<td class="param">
<?php
// vars
$choices = acf_get_location_rule_types();
// array
if ( is_array( $choices ) ) {
acf_render_field(
array(
'type' => 'select',
'name' => 'param',
'prefix' => $prefix,
'value' => $rule['param'],
'choices' => $choices,
'class' => 'refresh-location-rule',
)
);
}
?>
</td>
<td class="operator">
<?php
// vars
$choices = acf_get_location_rule_operators( $rule );
// array
if ( is_array( $choices ) ) {
acf_render_field(
array(
'type' => 'select',
'name' => 'operator',
'prefix' => $prefix,
'value' => $rule['operator'],
'choices' => $choices,
)
);
// custom
} else {
echo $choices;
}
?>
</td>
<td class="value">
<?php
// vars
$choices = acf_get_location_rule_values( $rule );
// array
if ( is_array( $choices ) ) {
acf_render_field(
array(
'type' => 'select',
'name' => 'value',
'class' => 'location-rule-value',
'prefix' => $prefix,
'value' => $rule['value'],
'choices' => $choices,
)
);
// custom
} else {
echo $choices;
}
?>
</td>
<td class="add">
<a href="#" class="button add-location-rule"><?php _e( 'and', 'acf' ); ?></a>
</td>
<td class="remove">
<a href="#" class="acf-icon -minus remove-location-rule"></a>
</td>
</tr>

View File

@ -0,0 +1,51 @@
<?php
// global
global $field_group;
?>
<div class="acf-field">
<div class="acf-label">
<label><?php _e( 'Rules', 'acf' ); ?></label>
<i tabindex="0" class="acf-icon acf-icon-help acf-js-tooltip" title="<?php esc_attr_e( 'Create a set of rules to determine which edit screens will use these advanced custom fields', 'acf' ); ?>">?</i>
</div>
<div class="acf-input">
<div class="rule-groups">
<?php
foreach ( $field_group['location'] as $i => $group ) :
// bail early if no group
if ( empty( $group ) ) {
return;
}
// view
acf_get_view(
'acf-field-group/location-group',
array(
'group' => $group,
'group_id' => "group_{$i}",
)
);
endforeach;
?>
<h4><?php _e( 'or', 'acf' ); ?></h4>
<a href="#" class="button add-location-group"><?php _e( 'Add rule group', 'acf' ); ?></a>
</div>
</div>
</div>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
acf.newPostbox({
'id': 'acf-field-group-locations',
'label': 'left'
});
}
</script>

View File

@ -0,0 +1,297 @@
<?php
// global
global $field_group;
// UI needs at lease 1 location rule
if ( empty( $field_group['location'] ) ) {
$field_group['location'] = array(
// Group 0.
array(
// Rule 0.
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
);
$acf_use_post_type = acf_get_post_type_from_request_args( 'add-fields' );
$acf_use_taxonomy = acf_get_taxonomy_from_request_args( 'add-fields' );
$acf_use_options_page = acf_get_ui_options_page_from_request_args( 'add-fields' );
if ( $acf_use_post_type && ! empty( $acf_use_post_type['post_type'] ) ) {
$field_group['location'] = array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => $acf_use_post_type['post_type'],
),
),
);
}
if ( $acf_use_taxonomy && ! empty( $acf_use_taxonomy['taxonomy'] ) ) {
$field_group['location'] = array(
array(
array(
'param' => 'taxonomy',
'operator' => '==',
'value' => $acf_use_taxonomy['taxonomy'],
),
),
);
}
if ( $acf_use_options_page && ! empty( $acf_use_options_page['menu_slug'] ) ) {
$field_group['location'] = array(
array(
array(
'param' => 'options_page',
'operator' => '==',
'value' => $acf_use_options_page['menu_slug'],
),
),
);
}
}
foreach ( acf_get_combined_field_group_settings_tabs() as $tab_key => $tab_label ) {
acf_render_field_wrap(
array(
'type' => 'tab',
'label' => $tab_label,
'key' => 'acf_field_group_settings_tabs',
'settings-type' => $tab_key,
)
);
switch ( $tab_key ) {
case 'location_rules':
echo '<div class="field-group-locations field-group-settings-tab">';
acf_get_view( 'acf-field-group/locations' );
echo '</div>';
break;
case 'presentation':
echo '<div class="field-group-setting-split-container field-group-settings-tab">';
echo '<div class="field-group-setting-split">';
// style
acf_render_field_wrap(
array(
'label' => __( 'Style', 'acf' ),
'instructions' => '',
'type' => 'button_group',
'name' => 'style',
'prefix' => 'acf_field_group',
'value' => $field_group['style'],
'choices' => array(
'default' => __( 'Standard (WP metabox)', 'acf' ),
'seamless' => __( 'Seamless (no metabox)', 'acf' ),
),
)
);
// position
acf_render_field_wrap(
array(
'label' => __( 'Position', 'acf' ),
'instructions' => __( "'High' position not supported in the Block Editor", 'acf' ),
'type' => 'button_group',
'name' => 'position',
'prefix' => 'acf_field_group',
'value' => $field_group['position'],
'choices' => array(
'acf_after_title' => __( 'High (after title)', 'acf' ),
'normal' => __( 'Normal (after content)', 'acf' ),
'side' => __( 'Side', 'acf' ),
),
'default_value' => 'normal',
),
'div',
'field'
);
// label_placement
acf_render_field_wrap(
array(
'label' => __( 'Label Placement', 'acf' ),
'instructions' => '',
'type' => 'button_group',
'name' => 'label_placement',
'prefix' => 'acf_field_group',
'value' => $field_group['label_placement'],
'choices' => array(
'top' => __( 'Top aligned', 'acf' ),
'left' => __( 'Left aligned', 'acf' ),
),
)
);
// instruction_placement
acf_render_field_wrap(
array(
'label' => __( 'Instruction Placement', 'acf' ),
'instructions' => '',
'type' => 'button_group',
'name' => 'instruction_placement',
'prefix' => 'acf_field_group',
'value' => $field_group['instruction_placement'],
'choices' => array(
'label' => __( 'Below labels', 'acf' ),
'field' => __( 'Below fields', 'acf' ),
),
)
);
// menu_order
acf_render_field_wrap(
array(
'label' => __( 'Order No.', 'acf' ),
'instructions' => __( 'Field groups with a lower order will appear first', 'acf' ),
'type' => 'number',
'name' => 'menu_order',
'prefix' => 'acf_field_group',
'value' => $field_group['menu_order'],
),
'div',
'field'
);
echo '</div>';
echo '<div class="field-group-setting-split">';
// hide on screen
$choices = array(
'permalink' => __( 'Permalink', 'acf' ),
'the_content' => __( 'Content Editor', 'acf' ),
'excerpt' => __( 'Excerpt', 'acf' ),
'custom_fields' => __( 'Custom Fields', 'acf' ),
'discussion' => __( 'Discussion', 'acf' ),
'comments' => __( 'Comments', 'acf' ),
'revisions' => __( 'Revisions', 'acf' ),
'slug' => __( 'Slug', 'acf' ),
'author' => __( 'Author', 'acf' ),
'format' => __( 'Format', 'acf' ),
'page_attributes' => __( 'Page Attributes', 'acf' ),
'featured_image' => __( 'Featured Image', 'acf' ),
'categories' => __( 'Categories', 'acf' ),
'tags' => __( 'Tags', 'acf' ),
'send-trackbacks' => __( 'Send Trackbacks', 'acf' ),
);
if ( acf_get_setting( 'remove_wp_meta_box' ) ) {
unset( $choices['custom_fields'] );
}
acf_render_field_wrap(
array(
'label' => __( 'Hide on screen', 'acf' ),
'instructions' => __( '<b>Select</b> items to <b>hide</b> them from the edit screen.', 'acf' ) . '<br /><br />' . __( "If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)", 'acf' ),
'type' => 'checkbox',
'name' => 'hide_on_screen',
'prefix' => 'acf_field_group',
'value' => $field_group['hide_on_screen'],
'toggle' => true,
'choices' => $choices,
),
'div',
'label',
true
);
echo '</div>';
echo '</div>';
break;
case 'group_settings':
echo '<div class="field-group-settings field-group-settings-tab">';
// active
acf_render_field_wrap(
array(
'label' => __( 'Active', 'acf' ),
'instructions' => '',
'type' => 'true_false',
'name' => 'active',
'prefix' => 'acf_field_group',
'value' => $field_group['active'],
'ui' => 1,
// 'ui_on_text' => __('Active', 'acf'),
// 'ui_off_text' => __('Inactive', 'acf'),
)
);
// Show fields in REST API.
if ( acf_get_setting( 'rest_api_enabled' ) ) {
acf_render_field_wrap(
array(
'label' => __( 'Show in REST API', 'acf' ),
'instructions' => '',
'type' => 'true_false',
'name' => 'show_in_rest',
'prefix' => 'acf_field_group',
'value' => $field_group['show_in_rest'],
'ui' => 1,
// 'ui_on_text' => __('Active', 'acf'),
// 'ui_off_text' => __('Inactive', 'acf'),
)
);
}
// description
acf_render_field_wrap(
array(
'label' => __( 'Description', 'acf' ),
'instructions' => __( 'Shown in field group list', 'acf' ),
'type' => 'text',
'name' => 'description',
'prefix' => 'acf_field_group',
'value' => $field_group['description'],
),
'div',
'field'
);
/* translators: 1: Post creation date 2: Post creation time */
$acf_created_on = sprintf( __( 'Created on %1$s at %2$s', 'acf' ), get_the_date(), get_the_time() );
?>
<div class="acf-field-group-settings-footer">
<span class="acf-created-on"><?php echo esc_html( $acf_created_on ); ?></span>
<a href="<?php echo get_delete_post_link(); ?>" class="acf-btn acf-btn-tertiary acf-delete-field-group">
<i class="acf-icon acf-icon-trash"></i>
<?php esc_html_e( 'Delete Field Group', 'acf' ); ?>
</a>
</div>
<?php
echo '</div>';
break;
default:
echo '<div class="field-group-' . esc_attr( $tab_key ) . ' field-group-settings-tab">';
do_action( 'acf/field_group/render_group_settings_tab/' . $tab_key, $field_group );
echo '</div>';
break;
}
}
// 3rd party settings
do_action( 'acf/render_field_group_settings', $field_group );
?>
<div class="acf-hidden">
<input type="hidden" name="acf_field_group[key]" value="<?php echo $field_group['key']; ?>" />
</div>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
acf.newPostbox({
'id': 'acf-field-group-options',
'label': 'top'
});
}
</script>

View File

@ -0,0 +1,90 @@
<?php
$acf_field_group_pro_features_title = __( 'Unlock Advanced Features and Build Even More with ACF PRO', 'acf' );
$acf_learn_more_text = __( 'Learn More', 'acf' );
$acf_learn_more_link = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/pro/', 'ACF upgrade', 'metabox' );
$acf_learn_more_target = '_blank';
$acf_pricing_text = __( 'View Pricing & Upgrade', 'acf' );
$acf_pricing_link = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/pro/', 'ACF upgrade', 'metabox_pricing', 'pricing-table' );
$acf_more_tools_link = acf_add_url_utm_tags( 'https://wpengine.com/developer/', 'bx_prod_referral', 'acf_free_plugin_cta_panel_logo', false, 'acf_plugin', 'referral' );
$acf_wpengine_logo_link = acf_add_url_utm_tags( 'https://wpengine.com/', 'bx_prod_referral', 'acf_free_plugin_cta_panel_logo', false, 'acf_plugin', 'referral' );
if ( acf_is_pro() ) {
if ( ! acf_pro_get_license_key() && acf_is_updates_page_visible() ) {
$acf_learn_more_target = '';
$acf_learn_more_text = __( 'Manage License', 'acf' );
$acf_learn_more_link = esc_url( admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates#acf_pro_license' ) );
} elseif ( acf_pro_is_license_expired() ) {
$acf_pricing_text = __( 'Renew License', 'acf' );
$acf_pricing_link = acf_add_url_utm_tags( acf_pro_get_manage_license_url(), 'ACF renewal', 'metabox' );
}
}
?>
<div id="tmpl-acf-field-group-pro-features">
<div class="acf-field-group-pro-features-wrapper">
<h1 class="acf-field-group-pro-features-title-sm"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label">PRO</div></h1>
<div class="acf-field-group-pro-features-content">
<h1 class="acf-field-group-pro-features-title"><?php echo esc_html( $acf_field_group_pro_features_title ); ?> <div class="acf-pro-label">PRO</div></h1>
<p class="acf-field-group-pro-features-desc"><?php esc_html_e( 'Speed up your workflow and develop better websites with features like ACF Blocks and Options Pages, and sophisticated field types like Repeater, Flexible Content, Clone, and Gallery.', 'acf' ); ?></p>
<div class="acf-field-group-pro-features-actions">
<a target="<?php echo $acf_learn_more_target; ?>" href="<?php echo $acf_learn_more_link; ?>" class="acf-btn acf-btn-muted acf-pro-features-learn-more"><?php echo esc_html( $acf_learn_more_text ); ?> <i class="acf-icon acf-icon-arrow-up-right"></i></a>
<a target="_blank" href="<?php echo $acf_pricing_link; ?>" class="acf-btn acf-pro-features-upgrade"><?php echo esc_html( $acf_pricing_text ); ?> <i class="acf-icon acf-icon-arrow-up-right"></i></a>
</div>
</div>
<div class="acf-field-group-pro-features-grid">
<div class="acf-field-group-pro-feature">
<i class="field-type-icon field-type-icon-flexible-content"></i>
<span class="field-type-label"><?php esc_html_e( 'Flexible Content Field', 'acf' ); ?></span>
</div>
<div class="acf-field-group-pro-feature">
<i class="field-type-icon field-type-icon-repeater"></i>
<span class="field-type-label"><?php esc_html_e( 'Repeater Field', 'acf' ); ?></span>
</div>
<div class="acf-field-group-pro-feature">
<i class="field-type-icon field-type-icon-clone"></i>
<span class="field-type-label"><?php esc_html_e( 'Clone Field', 'acf' ); ?></span>
</div>
<div class="acf-field-group-pro-feature">
<i class="field-type-icon pro-feature-blocks"></i>
<span class="field-type-label"><?php esc_html_e( 'ACF Blocks', 'acf' ); ?></span>
</div>
<div class="acf-field-group-pro-feature">
<i class="field-type-icon pro-feature-options-pages"></i>
<span class="field-type-label"><?php esc_html_e( 'Options Pages', 'acf' ); ?></span>
</div>
<div class="acf-field-group-pro-feature">
<i class="field-type-icon field-type-icon-gallery"></i>
<span class="field-type-label"><?php esc_html_e( 'Gallery Field', 'acf' ); ?></span>
</div>
</div>
</div>
<div class="acf-field-group-pro-features-footer-wrap">
<div class="acf-field-group-pro-features-footer">
<div class="acf-for-the-builders">
<?php
$acf_wpengine_logo = acf_get_url( 'assets/images/wp-engine-horizontal-white.svg' );
$acf_wpengine_logo = sprintf( '<a href="%s" target="_blank"><img class="acf-field-group-pro-features-wpengine-logo" src="%s" alt="WP Engine" /></a>', $acf_wpengine_logo_link, $acf_wpengine_logo );
/* translators: %s - WP Engine logo */
$acf_made_for_text = sprintf( __( 'Built for those that build with WordPress, by the team at %s', 'acf' ), $acf_wpengine_logo );
echo acf_esc_html( $acf_made_for_text );
?>
</div>
<div class="acf-more-tools-from-wpengine">
<a href="<?php echo $acf_more_tools_link; ?>" target="_blank"><?php esc_html_e( 'More Tools from WP Engine', 'acf' ); ?> <i class="acf-icon acf-icon-arrow-up-right"></i></a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
( function ( $, undefined ) {
$( document ).ready( function() {
if ( 'field_group' === acf.get( 'screen' ) ) {
$( '#acf-field-group-options' ).after( $( '#tmpl-acf-field-group-pro-features' ).css( 'display', 'block' ) );
} else {
$( '#tmpl-acf-field-group-pro-features' ).appendTo( '#wpbody-content .wrap' ).css( 'display', 'block' );
}
} );
} )( jQuery );
</script>