fields.php
4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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 esc_html_e( 'Fields', 'acf' ); ?></h3>
<a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php esc_html_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. */
esc_html_e( '#', 'acf' );
?>
<span class="acf-hidden">
<?php
/* translators: Hidden accessibility text for the positional order number of the field. */
esc_html_e( 'Order', 'acf' );
?>
</span>
</li>
<li class="li-field-label"><?php esc_html_e( 'Label', 'acf' ); ?></li>
<li class="li-field-name"><?php esc_html_e( 'Name', 'acf' ); ?></li>
<li class="li-field-key"><?php esc_html_e( 'Key', 'acf' ); ?></li>
<li class="li-field-type"><?php esc_html_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 esc_url( acf_get_url( 'assets/images/empty-group.svg' ) ); ?>" />
<h2><?php esc_html_e( 'Add Your First Field', 'acf' ); ?></h2>
<p><?php esc_html_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 esc_html_e( 'Add Field', 'acf' ); ?></a>
<p class="acf-small">
<?php
echo acf_esc_html(
sprintf(
/* 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 esc_html_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>