initial commit
This commit is contained in:
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$disabled = false;
|
||||
|
||||
|
||||
// empty
|
||||
if ( empty( $field['conditional_logic'] ) ) {
|
||||
|
||||
$disabled = true;
|
||||
$field['conditional_logic'] = array(
|
||||
|
||||
// group 0
|
||||
array(
|
||||
|
||||
// rule 0
|
||||
array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="acf-field acf-field-true-false acf-field-setting-conditional_logic" data-type="true_false" data-name="conditional_logic">
|
||||
<td class="acf-label">
|
||||
<label><?php _e( 'Conditional Logic', 'acf' ); ?></label>
|
||||
</td>
|
||||
<td 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 class="rule-groups"
|
||||
<?php
|
||||
if ( $disabled ) :
|
||||
?>
|
||||
style="display:none;"<?php endif; ?>>
|
||||
|
||||
<?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 acf_esc_attr_e( $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>
|
||||
|
||||
</td>
|
||||
</tr>
|
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
// 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'],
|
||||
);
|
||||
|
||||
// Misc template vars.
|
||||
$field_label = acf_get_field_label( $field, 'admin' );
|
||||
$field_type_label = acf_get_field_type_label( $field['type'] );
|
||||
|
||||
?>
|
||||
<div <?php echo acf_esc_attr( $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>
|
||||
<a class="move-field" title="<?php _e( 'Move field to another group', 'acf' ); ?>" href="#"><?php _e( 'Move', 'acf' ); ?></a>
|
||||
<a class="delete-field" title="<?php _e( 'Delete field', 'acf' ); ?>" href="#"><?php _e( 'Delete', 'acf' ); ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php // whitespace before field name looks odd but fixes chrome bug selecting all text in row ?>
|
||||
<li class="li-field-name"> <?php echo esc_html( $field['name'] ); ?></li>
|
||||
<li class="li-field-key"> <?php echo esc_html( $field['key'] ); ?></li>
|
||||
<li class="li-field-type"> <?php echo esc_html( $field_type_label ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="settings">
|
||||
<table class="acf-table">
|
||||
<tbody class="acf-field-settings">
|
||||
<?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
|
||||
);
|
||||
|
||||
|
||||
// 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',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// instructions
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
// required
|
||||
acf_render_field_setting(
|
||||
$field,
|
||||
array(
|
||||
'label' => __( 'Required?', 'acf' ),
|
||||
'instructions' => '',
|
||||
'type' => 'true_false',
|
||||
'name' => 'required',
|
||||
'ui' => 1,
|
||||
'class' => 'field-required',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// 3rd party settings
|
||||
do_action( 'acf/render_field_settings', $field );
|
||||
|
||||
|
||||
// type specific settings
|
||||
do_action( "acf/render_field_settings/type={$field['type']}", $field );
|
||||
|
||||
|
||||
// conditional logic
|
||||
acf_get_view( 'field-group-field-conditional-logic', array( 'field' => $field ) );
|
||||
|
||||
|
||||
// wrapper
|
||||
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',
|
||||
),
|
||||
),
|
||||
'tr'
|
||||
);
|
||||
|
||||
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',
|
||||
),
|
||||
),
|
||||
'tr'
|
||||
);
|
||||
|
||||
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',
|
||||
),
|
||||
),
|
||||
'tr'
|
||||
);
|
||||
|
||||
?>
|
||||
<tr class="acf-field acf-field-save">
|
||||
<td class="acf-label"></td>
|
||||
<td class="acf-input">
|
||||
<ul class="acf-hl">
|
||||
<li>
|
||||
<a class="button edit-field" title="<?php _e( 'Close Field', 'acf' ); ?>" href="#"><?php _e( 'Close Field', 'acf' ); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,76 @@
|
||||
<div class="acf-field-list-wrap">
|
||||
|
||||
<ul class="acf-hl acf-thead">
|
||||
<li class="li-field-order"><?php _e( 'Order', 'acf' ); ?></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>
|
||||
|
||||
<div class="acf-field-list
|
||||
<?php
|
||||
if ( ! $fields ) {
|
||||
echo ' -empty'; }
|
||||
?>
|
||||
">
|
||||
|
||||
<div class="no-fields-message">
|
||||
<?php _e( 'No fields. Click the <strong>+ Add Field</strong> button to create your first field.', 'acf' ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $fields ) :
|
||||
|
||||
foreach ( $fields as $i => $field ) :
|
||||
|
||||
acf_get_view(
|
||||
'field-group-field',
|
||||
array(
|
||||
'field' => $field,
|
||||
'i' => $i,
|
||||
)
|
||||
);
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<ul class="acf-hl acf-tfoot">
|
||||
<li class="acf-fr">
|
||||
<a href="#" class="button button-primary button-large add-field"><?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(
|
||||
'field-group-field',
|
||||
array(
|
||||
'field' => $clone,
|
||||
'i' => 0,
|
||||
)
|
||||
);
|
||||
?>
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
?>
|
||||
<div class="acf-field">
|
||||
<div class="acf-label">
|
||||
<label><?php _e( 'Rules', 'acf' ); ?></label>
|
||||
<p class="description"><?php _e( 'Create a set of rules to determine which edit screens will use these advanced custom fields', 'acf' ); ?></p>
|
||||
</div>
|
||||
<div class="acf-input">
|
||||
<div class="rule-groups">
|
||||
|
||||
<?php
|
||||
foreach ( $field_group['location'] as $i => $group ) :
|
||||
|
||||
// bail ealry if no group
|
||||
if ( empty( $group ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view(
|
||||
'html-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>
|
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// 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'),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// style
|
||||
acf_render_field_wrap(
|
||||
array(
|
||||
'label' => __( 'Style', 'acf' ),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'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' => '',
|
||||
'type' => 'select',
|
||||
'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',
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// label_placement
|
||||
acf_render_field_wrap(
|
||||
array(
|
||||
'label' => __( 'Label placement', 'acf' ),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'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' => 'select',
|
||||
'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'],
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// 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'],
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// 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,
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// 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': 'left'
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying admin navigation.
|
||||
*
|
||||
* @date 27/3/20
|
||||
* @since 5.9.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $submenu, $parent_file, $submenu_file, $plugin_page, $pagenow;
|
||||
|
||||
// Vars.
|
||||
$parent_slug = 'edit.php?post_type=acf-field-group';
|
||||
|
||||
// Generate array of navigation items.
|
||||
$tabs = array();
|
||||
if ( isset( $submenu[ $parent_slug ] ) ) {
|
||||
foreach ( $submenu[ $parent_slug ] as $i => $sub_item ) {
|
||||
|
||||
// Check user can access page.
|
||||
if ( ! current_user_can( $sub_item[1] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore "Add New".
|
||||
if ( $i === 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Define tab.
|
||||
$tab = array(
|
||||
'text' => $sub_item[0],
|
||||
'url' => $sub_item[2],
|
||||
);
|
||||
|
||||
// Convert submenu slug "test" to "$parent_slug&page=test".
|
||||
if ( ! strpos( $sub_item[2], '.php' ) ) {
|
||||
$tab['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug );
|
||||
}
|
||||
|
||||
// Detect active state.
|
||||
if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) {
|
||||
$tab['is_active'] = true;
|
||||
}
|
||||
|
||||
// Special case for "Add New" page.
|
||||
if ( $i === 0 && $submenu_file === 'post-new.php?post_type=acf-field-group' ) {
|
||||
$tab['is_active'] = true;
|
||||
}
|
||||
$tabs[] = $tab;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the admin navigation tabs.
|
||||
*
|
||||
* @date 27/3/20
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $tabs The array of navigation tabs.
|
||||
*/
|
||||
$tabs = apply_filters( 'acf/admin/toolbar', $tabs );
|
||||
|
||||
// Bail early if set to false.
|
||||
if ( $tabs === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="acf-admin-toolbar">
|
||||
<h2><i class="acf-tab-icon dashicons dashicons-welcome-widgets-menus"></i> <?php echo acf_get_setting( 'name' ); ?></h2>
|
||||
<?php
|
||||
foreach ( $tabs as $tab ) {
|
||||
printf(
|
||||
'<a class="acf-tab%s" href="%s">%s</a>',
|
||||
! empty( $tab['is_active'] ) ? ' is-active' : '',
|
||||
esc_url( $tab['url'] ),
|
||||
acf_esc_html( $tab['text'] )
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( ! defined( 'ACF_PRO' ) || ! ACF_PRO ) : ?>
|
||||
<a target="_blank" href="https://www.advancedcustomfields.com/pro/?utm_source=ACF%2BFree&utm_medium=insideplugin&utm_campaign=ACF%2Bupgrade" class="btn-upgrade">
|
||||
<img src="<?php echo acf_get_url( 'assets/images/icon-upgrade-pro.svg' ); ?>" />
|
||||
<p><?php _e( 'Upgrade to Pro', 'acf' ); ?></p>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Network Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.show-on-complete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e( 'Upgrade Database', 'acf' ); ?></h1>
|
||||
|
||||
<p><?php echo sprintf( __( 'The following sites require a DB upgrade. Check the ones you want to update and then click %s.', 'acf' ), '"' . __( 'Upgrade Sites', 'acf' ) . '"' ); ?></p>
|
||||
<p><input type="submit" name="upgrade" value="<?php _e( 'Upgrade Sites', 'acf' ); ?>" class="button" id="upgrade-sites"></p>
|
||||
|
||||
<table class="wp-list-table widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all">
|
||||
</td>
|
||||
<th class="manage-column" scope="col" style="width:33%;">
|
||||
<label for="sites-select-all"><?php _e( 'Site', 'acf' ); ?></label>
|
||||
</th>
|
||||
<th><?php _e( 'Description', 'acf' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all-2">
|
||||
</td>
|
||||
<th class="manage-column" scope="col">
|
||||
<label for="sites-select-all-2"><?php _e( 'Site', 'acf' ); ?></label>
|
||||
</th>
|
||||
<th><?php _e( 'Description', 'acf' ); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="the-list">
|
||||
<?php
|
||||
|
||||
$sites = acf_get_sites();
|
||||
if ( $sites ) :
|
||||
foreach ( $sites as $i => $site ) :
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
?>
|
||||
<tr
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) :
|
||||
?>
|
||||
class="alternate"<?php endif; ?>>
|
||||
<th class="check-column" scope="row">
|
||||
<?php if ( acf_has_upgrade() ) : ?>
|
||||
<input type="checkbox" value="<?php echo $site['blog_id']; ?>" name="checked[]">
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<strong><?php echo get_bloginfo( 'name' ); ?></strong><br /><?php echo home_url(); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ( acf_has_upgrade() ) : ?>
|
||||
<span class="response"><?php printf( __( 'Site requires database upgrade from %1$s to %2$s', 'acf' ), acf_get_db_version(), ACF_VERSION ); ?></span>
|
||||
<?php else : ?>
|
||||
<?php _e( 'Site is up to date', 'acf' ); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// restore
|
||||
restore_current_blog();
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><input type="submit" name="upgrade" value="<?php _e( 'Upgrade Sites', 'acf' ); ?>" class="button" id="upgrade-sites-2"></p>
|
||||
<p class="show-on-complete"><?php echo sprintf( __( 'Database Upgrade complete. <a href="%s">Return to network dashboard</a>', 'acf' ), network_admin_url() ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
events: {
|
||||
'click #upgrade-sites': 'onClick',
|
||||
'click #upgrade-sites-2': 'onClick'
|
||||
},
|
||||
$inputs: function(){
|
||||
return $('#the-list input:checked');
|
||||
},
|
||||
onClick: function( e, $el ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
// bail early if no selection
|
||||
if( !this.$inputs().length ) {
|
||||
return alert('<?php _e( 'Please select at least one site to upgrade.', 'acf' ); ?>');
|
||||
}
|
||||
|
||||
// confirm action
|
||||
if( !confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// upgrade
|
||||
this.upgrade();
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// vars
|
||||
var $inputs = this.$inputs();
|
||||
|
||||
// bail early if no sites selected
|
||||
if( !$inputs.length ) {
|
||||
return this.complete();
|
||||
}
|
||||
|
||||
// disable buttons
|
||||
$('.button').prop('disabled', true);
|
||||
|
||||
// vars
|
||||
var $input = $inputs.first();
|
||||
var $row = $input.closest('tr');
|
||||
var text = '';
|
||||
var success = false;
|
||||
|
||||
// show loading
|
||||
$row.find('.response').html('<i class="acf-loading"></i></span> <?php printf( __( 'Upgrading data to version %s', 'acf' ), ACF_VERSION ); ?>');
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade',
|
||||
blog_id: $input.val()
|
||||
}),
|
||||
success: function( json ){
|
||||
success = true;
|
||||
$input.remove();
|
||||
text = '<?php _e( 'Upgrade complete.', 'acf' ); ?>';
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
text = '<?php _e( 'Upgrade failed.', 'acf' ); ?>';
|
||||
if( error = acf.getXhrError(jqXHR) ) {
|
||||
text += ' <code>' + error + '</code>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// display text
|
||||
$row.find('.response').html( text );
|
||||
|
||||
// if successful upgrade, proceed to next site. Otherwise, skip to complete.
|
||||
if( success ) {
|
||||
this.upgrade();
|
||||
} else {
|
||||
this.complete();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
complete: function(){
|
||||
|
||||
// enable buttons
|
||||
$('.button').prop('disabled', false);
|
||||
|
||||
// show message
|
||||
$('.show-on-complete').show();
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
</div>
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.step-1,
|
||||
.step-2,
|
||||
.step-3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e( 'Upgrade Database', 'acf' ); ?></h1>
|
||||
|
||||
<?php if ( acf_has_upgrade() ) : ?>
|
||||
|
||||
<p><?php _e( 'Reading upgrade tasks...', 'acf' ); ?></p>
|
||||
<p class="step-1"><i class="acf-loading"></i> <?php printf( __( 'Upgrading data to version %s', 'acf' ), ACF_VERSION ); ?></p>
|
||||
<p class="step-2"></p>
|
||||
<p class="step-3"><?php echo sprintf( __( 'Database upgrade complete. <a href="%s">See what\'s new</a>', 'acf' ), admin_url( 'edit.php?post_type=acf-field-group' ) ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
initialize: function(){
|
||||
|
||||
// allow user to read message for 1 second
|
||||
this.setTimeout( this.upgrade, 1000 );
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// show step 1
|
||||
$('.step-1').show();
|
||||
|
||||
// vars
|
||||
var response = '';
|
||||
var success = false;
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade'
|
||||
}),
|
||||
success: function( json ){
|
||||
success = true;
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
response = '<?php _e( 'Upgrade failed.', 'acf' ); ?>';
|
||||
if( error = acf.getXhrError(jqXHR) ) {
|
||||
response += ' <code>' + error + '</code>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// remove spinner
|
||||
$('.acf-loading').hide();
|
||||
|
||||
// display response
|
||||
if( response ) {
|
||||
$('.step-2').show().html( response );
|
||||
}
|
||||
|
||||
// display success
|
||||
if( success ) {
|
||||
$('.step-3').show();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<p><?php _e( 'No updates available.', 'acf' ); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* html-admin-tools
|
||||
*
|
||||
* View to output admin tools for both archive and single
|
||||
*
|
||||
* @date 20/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param string $screen_id The screen ID used to display metaboxes
|
||||
* @param string $active The active Tool
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
$class = $active ? 'single' : 'grid';
|
||||
|
||||
?>
|
||||
<div class="wrap" id="acf-admin-tools">
|
||||
|
||||
<h1><?php _e( 'Tools', 'acf' ); ?> <?php
|
||||
if ( $active ) :
|
||||
?>
|
||||
<a class="page-title-action" href="<?php echo acf_get_admin_tools_url(); ?>"><?php _e( 'Back to all tools', 'acf' ); ?></a><?php endif; ?></h1>
|
||||
|
||||
<div class="acf-meta-box-wrap -<?php echo $class; ?>">
|
||||
<?php do_meta_boxes( $screen_id, 'normal', '' ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,30 @@
|
||||
<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(
|
||||
'html-location-rule',
|
||||
array(
|
||||
'rule' => $rule,
|
||||
)
|
||||
);
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
@ -0,0 +1,97 @@
|
||||
<?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',
|
||||
'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>
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// calculate add-ons (non pro only)
|
||||
$plugins = array();
|
||||
|
||||
if ( ! acf_get_setting( 'pro' ) ) {
|
||||
|
||||
if ( is_plugin_active( 'acf-repeater/acf-repeater.php' ) ) {
|
||||
$plugins[] = __( 'Repeater', 'acf' );
|
||||
}
|
||||
if ( is_plugin_active( 'acf-flexible-content/acf-flexible-content.php' ) ) {
|
||||
$plugins[] = __( 'Flexible Content', 'acf' );
|
||||
}
|
||||
if ( is_plugin_active( 'acf-gallery/acf-gallery.php' ) ) {
|
||||
$plugins[] = __( 'Gallery', 'acf' );
|
||||
}
|
||||
if ( is_plugin_active( 'acf-options-page/acf-options-page.php' ) ) {
|
||||
$plugins[] = __( 'Options Page', 'acf' );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-notice" class="notice">
|
||||
|
||||
<div class="col-content">
|
||||
|
||||
<img src="<?php echo acf_get_url( 'assets/images/acf-logo.png' ); ?>" />
|
||||
<h2><?php _e( 'Database Upgrade Required', 'acf' ); ?></h2>
|
||||
<p><?php printf( __( 'Thank you for updating to %1$s v%2$s!', 'acf' ), acf_get_setting( 'name' ), acf_get_setting( 'version' ) ); ?><br /><?php _e( 'This version contains improvements to your database and requires an upgrade.', 'acf' ); ?></p>
|
||||
<?php if ( ! empty( $plugins ) ) : ?>
|
||||
<p><?php printf( __( 'Please also check all premium add-ons (%s) are updated to the latest version.', 'acf' ), implode( ', ', $plugins ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-actions">
|
||||
<a id="acf-upgrade-button" href="<?php echo $button_url; ?>" class="button button-primary button-hero"><?php echo $button_text; ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php if ( $confirm ) : ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
$("#acf-upgrade-button").on("click", function(){
|
||||
return confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>");
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif; ?>
|
Reference in New Issue
Block a user