options.php
12.7 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<?php
// vars
$key = $field['name'];
// validate
if( !$field['row_min'] )
{
$field['row_min'] = '';
}
if( !$field['row_limit'] )
{
$field['row_limit'] = '';
}
// add clone
$field['sub_fields'][] = apply_filters('acf/load_field_defaults', array(
'key' => 'field_clone',
'label' => __("New Field",'acf'),
'name' => __("new_field",'acf'),
'type' => 'text',
));
// get name of all fields for use in field type drop down
$fields_names = apply_filters('acf/registered_fields', array());
unset( $fields_names[ __("Layout",'acf') ]['tab'] );
// conditional logic dummy data
$conditional_logic_rule = array(
'field' => '',
'operator' => '==',
'value' => ''
);
?>
<tr class="field_option field_option_<?php echo $this->name; ?> field_option_<?php echo $this->name; ?>_fields">
<td class="label">
<label><?php _e("Repeater Fields",'acf'); ?></label>
</td>
<td>
<div class="repeater">
<div class="fields_header">
<table class="acf widefat">
<thead>
<tr>
<th class="field_order"><?php _e('Field Order','acf'); ?></th>
<th class="field_label"><?php _e('Field Label','acf'); ?></th>
<th class="field_name"><?php _e('Field Name','acf'); ?></th>
<th class="field_type"><?php _e('Field Type','acf'); ?></th>
</tr>
</thead>
</table>
</div>
<div class="fields">
<div class="no_fields_message" <?php if(count($field['sub_fields']) > 1){ echo 'style="display:none;"'; } ?>>
<?php _e("No fields. Click the \"+ Add Sub Field button\" to create your first field.",'acf'); ?>
</div>
<?php foreach($field['sub_fields'] as $sub_field):
$fake_name = $key . '][sub_fields][' . $sub_field['key'];
?>
<div class="field field_type-<?php echo $sub_field['type']; ?> field_key-<?php echo $sub_field['key']; ?> sub_field" data-type="<?php echo $sub_field['type']; ?>" data-id="<?php echo $sub_field['key']; ?>">
<input type="hidden" class="input-field_key" name="fields[<?php echo $fake_name; ?>][key]" value="<?php echo $sub_field['key']; ?>" />
<div class="field_meta">
<table class="acf widefat">
<tr>
<td class="field_order"><span class="circle"><?php echo (int)$sub_field['order_no'] + 1; ?></span></td>
<td class="field_label">
<strong>
<a class="acf_edit_field" title="<?php _e("Edit this Field",'acf'); ?>" href="javascript:;"><?php echo $sub_field['label']; ?></a>
</strong>
<div class="row_options">
<span><a class="acf_edit_field" title="<?php _e("Edit this Field",'acf'); ?>" href="javascript:;"><?php _e("Edit",'acf'); ?></a> | </span>
<span><a title="<?php _e("Read documentation for this field",'acf'); ?>" href="http://www.advancedcustomfields.com/docs/field-types/" target="_blank"><?php _e("Docs",'acf'); ?></a> | </span>
<span><a class="acf_duplicate_field" title="<?php _e("Duplicate this Field",'acf'); ?>" href="javascript:;"><?php _e("Duplicate",'acf'); ?></a> | </span>
<span><a class="acf_delete_field" title="<?php _e("Delete this Field",'acf'); ?>" href="javascript:;"><?php _e("Delete",'acf'); ?></a>
</div>
</td>
<td class="field_name"><?php echo $sub_field['name']; ?></td>
<td class="field_type"><?php echo $sub_field['type']; ?></td>
</tr>
</table>
</div>
<div class="field_form_mask">
<div class="field_form">
<table class="acf_input widefat">
<tbody>
<tr class="field_label">
<td class="label">
<label><?php _e("Field Label",'acf'); ?> <span class="required">*</span></label>
<p class="description"><?php _e("This is the name which will appear on the edit page",'acf'); ?></p>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields[' . $fake_name . '][label]',
'value' => $sub_field['label'],
'class' => 'label',
));
?>
</td>
</tr>
<tr class="field_name">
<td class="label">
<label><?php _e("Field Name",'acf'); ?> <span class="required">*</span></label>
<p class="description"><?php _e("Single word, no spaces. Underscores and dashes allowed",'acf'); ?></p>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields[' . $fake_name . '][name]',
'value' => $sub_field['name'],
'class' => 'name',
));
?>
</td>
</tr>
<tr class="field_type">
<td class="label"><label><?php _e("Field Type",'acf'); ?> <span class="required">*</span></label></td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'select',
'name' => 'fields[' . $fake_name . '][type]',
'value' => $sub_field['type'],
'class' => 'type',
'choices' => $fields_names,
'optgroup' => true
));
?>
</td>
</tr>
<tr class="field_instructions">
<td class="label"><label><?php _e("Field Instructions",'acf'); ?></label></td>
<td>
<?php
if( !isset($sub_field['instructions']) )
{
$sub_field['instructions'] = "";
}
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields[' . $fake_name . '][instructions]',
'value' => $sub_field['instructions'],
'class' => 'instructions',
));
?>
</td>
</tr>
<tr class="required">
<td class="label"><label><?php _e("Required?",'acf'); ?></label></td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'radio',
'name' => 'fields[' .$fake_name . '][required]',
'value' => $sub_field['required'],
'choices' => array(
1 => __("Yes",'acf'),
0 => __("No",'acf'),
),
'layout' => 'horizontal',
));
?>
</td>
</tr>
<tr class="field_column_width">
<td class="label">
<label><?php _e("Column Width",'acf'); ?></label>
</td>
<td>
<?php
if( !isset($sub_field['column_width']) )
{
$sub_field['column_width'] = "";
}
do_action('acf/create_field', array(
'type' => 'number',
'name' => 'fields[' . $fake_name . '][column_width]',
'value' => $sub_field['column_width'],
'class' => 'column_width',
'append' => '%'
));
?>
</td>
</tr>
<?php
$sub_field['name'] = $fake_name;
do_action('acf/create_field_options', $sub_field );
?>
<tr class="conditional-logic" data-field_name="<?php echo $field['key']; ?>">
<td class="label"><label><?php _e("Conditional Logic",'acf'); ?></label></td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'radio',
'name' => 'fields[' . $fake_name . '][conditional_logic][status]',
'value' => $sub_field['conditional_logic']['status'],
'choices' => array(
1 => __("Yes",'acf'),
0 => __("No",'acf'),
),
'layout' => 'horizontal',
));
// no rules?
if( ! $sub_field['conditional_logic']['rules'] )
{
$sub_field['conditional_logic']['rules'] = array(
array() // this will get merged with $conditional_logic_rule
);
}
?>
<div class="contional-logic-rules-wrapper" <?php if( ! $sub_field['conditional_logic']['status'] ) echo 'style="display:none"'; ?>>
<table class="conditional-logic-rules widefat acf-rules <?php if( count($sub_field['conditional_logic']['rules']) == 1) echo 'remove-disabled'; ?>">
<tbody>
<?php foreach( $sub_field['conditional_logic']['rules'] as $rule_i => $rule ):
// validate
$rule = array_merge($conditional_logic_rule, $rule);
// fix PHP error in 3.5.4.1
if( strpos($rule['value'],'Undefined index: value in') !== false )
{
$rule['value'] = '';
}
?>
<tr data-i="<?php echo $rule_i; ?>">
<td>
<input class="conditional-logic-field" type="hidden" name="fields[<?php echo $fake_name; ?>][conditional_logic][rules][<?php echo $rule_i; ?>][field]" value="<?php echo $rule['field']; ?>" />
</td>
<td width="25%">
<?php
do_action('acf/create_field', array(
'type' => 'select',
'name' => 'fields[' . $fake_name . '][conditional_logic][rules][' . $rule_i . '][operator]',
'value' => $rule['operator'],
'choices' => array(
'==' => __("is equal to",'acf'),
'!=' => __("is not equal to",'acf'),
),
));
?>
</td>
<td><input class="conditional-logic-value" type="hidden" name="fields[<?php echo $fake_name; ?>][conditional_logic][rules][<?php echo $rule_i; ?>][value]" value="<?php echo $rule['value']; ?>" /></td>
<td class="buttons">
<ul class="hl clearfix">
<li><a class="acf-button-remove" href="javascript:;"></a></li>
<li><a class="acf-button-add" href="javascript:;"></a></li>
</ul>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<ul class="hl clearfix">
<li style="padding:4px 4px 0 0;"><?php _e("Show this field when",'acf'); ?></li>
<li><?php do_action('acf/create_field', array(
'type' => 'select',
'name' => 'fields[' . $fake_name . '][conditional_logic][allorany]',
'value' => $sub_field['conditional_logic']['allorany'],
'choices' => array(
'all' => __("all",'acf'),
'any' => __("any",'acf'),
),
)); ?></li>
<li style="padding:4px 0 0 4px;"><?php _e("these rules are met",'acf'); ?></li>
</ul>
</div>
</td>
</tr>
<tr class="field_save">
<td class="label">
<!-- <label><?php _e("Save Field",'acf'); ?></label> -->
</td>
<td>
<ul class="hl clearfix">
<li>
<a class="acf_edit_field acf-button grey" title="<?php _e("Close Field",'acf'); ?>" href="javascript:;"><?php _e("Close Sub Field",'acf'); ?></a>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div><!-- End Form -->
</div><!-- End Form Mask -->
</div>
<?php endforeach; ?>
</div>
<div class="table_footer">
<div class="order_message"><?php _e('Drag and drop to reorder','acf'); ?></div>
<a href="javascript:;" id="add_field" class="acf-button"><?php _e('+ Add Sub Field','acf'); ?></a>
</div>
</div>
</td>
</tr>
<tr class="field_option field_option_<?php echo $this->name; ?>">
<td class="label">
<label><?php _e("Minimum Rows",'acf'); ?></label>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields['.$key.'][row_min]',
'value' => $field['row_min'],
));
?>
</td>
</tr>
<tr class="field_option field_option_<?php echo $this->name; ?>">
<td class="label">
<label><?php _e("Maximum Rows",'acf'); ?></label>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields['.$key.'][row_limit]',
'value' => $field['row_limit'],
));
?>
</td>
</tr>
<tr class="field_option field_option_<?php echo $this->name; ?> field_option_<?php echo $this->name; ?>_layout">
<td class="label">
<label><?php _e("Layout",'acf'); ?></label>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'radio',
'name' => 'fields['.$key.'][layout]',
'value' => $field['layout'],
'layout' => 'horizontal',
'choices' => array(
'table' => __("Table",'acf'),
'row' => __("Row",'acf')
)
));
?>
</td>
</tr>
<tr class="field_option field_option_<?php echo $this->name; ?>">
<td class="label">
<label><?php _e("Button Label",'acf'); ?></label>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'text',
'name' => 'fields['.$key.'][button_label]',
'value' => $field['button_label'],
));
?>
</td>
</tr>