This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
inc-admin-options-manage.php
744 lines (608 loc) · 24.2 KB
/
inc-admin-options-manage.php
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<?php
/**
* edit post type defaults
*/
if ("edit-post-type-defaults" == $action) {
global $wp_post_types;
$post_type = $_GET["post-type"];
if ( isset($wp_post_types[$post_type]) ) {
$selected_post_type = $wp_post_types[$post_type];
?>
<form action="<?php echo SIMPLE_FIELDS_FILE ?>&action=edit-post-type-defaults-save" method="post">
<?php do_action("simple_fields_options_print_nav_tabs", $subpage); ?>
<h3><?php echo __( 'Post type defaults', "simple-fields" ) ?></h3>
<table class="form-table">
<tr>
<th>
<p><?php _e('Post type', "simple-fields" ) ?></p>
</th>
<td>
<p><?php echo esc_html( $selected_post_type->labels->name . " (" . $selected_post_type->name . ")" ) ?></p>
</td>
</tr>
<tr>
<th><?php _e('Default post connector', 'simple-fields') ?></th>
<td>
<?php
$arr_post_connectors = $this->get_post_connectors_for_post_type($post_type);
if ($arr_post_connectors) {
$selected_post_type_default = $this->get_default_connector_for_post_type($post_type);
?>
<select name="simple_fields_save-post_type_connector">
<option <?php echo ($selected_post_type_default==="__none__") ? " selected='selected' " : "" ?> value="__none__"><?php _e('No post connector', 'simple-fields') ?></option>
<option <?php echo ($selected_post_type_default==="__inherit__") ? " selected='selected' " : "" ?> value="__inherit__"><?php _e('Inherit from parent post', 'simple-fields') ?></option>
<?php
foreach ($arr_post_connectors as $one_post_connector) {
$is_the_selected_post_connector = ( intval($selected_post_type_default) == intval($one_post_connector["id"]) );
// Don't show post connector if it's deleted and not the one selected = we show it even if it's deleted, if it's the selected one
if ( $one_post_connector["deleted"] && ! $is_the_selected_post_connector ) continue;
echo "<option " . ( $is_the_selected_post_connector ? " selected='selected' " : "" ) . "value='{$one_post_connector["id"]}'>" . $one_post_connector["name"] . "</option>";
}
?>
</select>
<?php
} else {
?><p><?php _e('There are no post connectors for this post type.', 'simple-fields') ?></p><?php
}
?>
</td>
</tr>
</table>
<p class="submit">
<input class="button-primary" type="submit" value="<?php _e("Save changes", "simple-fields") ?>" />
<input type="hidden" name="simple_fields_save-post_type" value="<?php echo $post_type ?>" />
<?php wp_nonce_field( "save-default-post-connector", "simple-fields" ) ?>
<?php _e('or', 'simple_fields'); ?>
<a href="<?php echo SIMPLE_FIELDS_FILE ?>"><?php _e('cancel', 'simple-fields') ?></a>
</p>
</form>
<?php
}
}
/**
* edit new or existing post connector
* If new then connector-id = 0
*/
if ("edit-post-connector" == $action) {
$connector_id = (isset($_GET["connector-id"])) ? intval($_GET["connector-id"]) : false;
$highest_connector_id = 0;
$is_new_post_connector = false;
// if new, save it as unnamed, and then set to edit that
if ($connector_id === 0) {
// is new connector
$is_new_post_connector = true;
$post_connector_in_edit = simple_fields_register_post_connector(null, array("deleted" => true, "added_with_code" => false));
$post_connector_in_edit["name"] = "";
$post_connector_in_edit["slug"] = "";
} else {
// existing post connector
// set a default value for hide_editor if it does not exist. did not exist until 0.5
$post_connectors[$connector_id]["hide_editor"] = (bool) @$post_connectors[$connector_id]["hide_editor"];
$post_connector_in_edit = $post_connectors[$connector_id];
}
?>
<form method="post" action="<?php echo SIMPLE_FIELDS_FILE ?>&action=edit-post-connector-save">
<?php do_action("simple_fields_options_print_nav_tabs", $subpage); ?>
<h3><?php _e('Post Connector details', 'simple-fields') ?></h3>
<?php
if ( ! empty( $post_connector_in_edit["added_with_code"] ) ) {
echo "<div class='simple-fields-message'><p>";
_e("This post connector was added with PHP code, so the changes made here may not be permanent.", "simple-fields");
echo "</p></div>";
}
?>
<table class="form-table">
<tr>
<th><label><?php _e('Name', 'simple-fields') ?></label></th>
<td><input
type="text"
id="post_connector_name"
name="post_connector_name"
class="regular-text"
value="<?php echo esc_html($post_connector_in_edit["name"]) ?>"
placeholder="<?php _e("Enter a name for this post connector", "simple-fields"); ?>"
<?php if ($is_new_post_connector) { ?>
autofocus
<?php } ?>
/></td>
</tr>
<tr>
<th>
<label for="post_connector_slug"><?php _e('Slug', 'simple-fields') ?></label>
</th>
<td>
<input type="text" name="post_connector_slug" id="post_connector_slug" class="regular-text"
value="<?php echo esc_html(@$post_connector_in_edit["slug"]) ?>"
pattern='<?php echo $this->get_slug_pattern() ?>'
title='<?php echo $this->get_slug_title() ?>'
required
/>
<br>
<span class="description"><?php echo __("A unique identifier for this connector", 'simple-fields') ?></span>
<?php
// sf_d($post_connector_in_edit);
?>
</td>
</tr>
<tr>
<th><?php _e('Field Groups', 'simple-fields') ?></th>
<td>
<p>
<select id="simple-fields-post-connector-add-fields">
<option value=""><?php _e('Add field group...', 'simple-fields') ?></option>
<?php
foreach ($field_groups as $one_field_group) {
if ($one_field_group["deleted"]) { continue; }
?><option value='<?php echo $one_field_group["id"] ?>'><?php echo esc_html($one_field_group["name"]) ?></option><?php
}
?>
</select>
</p>
<ul id="simple-fields-post-connector-added-fields">
<?php
foreach ($post_connector_in_edit["field_groups"] as $one_post_connector_added_field) {
if ($one_post_connector_added_field["deleted"]) { continue; }
#d($one_post_connector_added_field);
?>
<li>
<div class='simple-fields-post-connector-addded-fields-handle'></div>
<div class='simple-fields-post-connector-addded-fields-field-name'><?php echo $one_post_connector_added_field["name"] ?></div>
<input type='hidden' name='added_fields[<?php echo $one_post_connector_added_field["id"] ?>][id]' value='<?php echo $one_post_connector_added_field["id"] ?>' />
<input type='hidden' name='added_fields[<?php echo $one_post_connector_added_field["id"] ?>][name]' value='<?php echo $one_post_connector_added_field["name"] ?>' />
<input type='hidden' name='added_fields[<?php echo $one_post_connector_added_field["id"] ?>][deleted]' value='0' class="simple-fields-post-connector-added-field-deleted" />
<div class="simple-fields-post-connector-addded-fields-options">
<?php _e('Context', 'simple-fields') ?>
<select name='added_fields[<?php echo $one_post_connector_added_field["id"] ?>][context]' class="simple-fields-post-connector-addded-fields-option-context">
<option <?php echo ("normal" == $one_post_connector_added_field["context"]) ? " selected='selected' " : "" ?> value="normal"><?php _e('normal') ?></option>
<option <?php echo ("advanced" == $one_post_connector_added_field["context"]) ? " selected='selected' " : "" ?> value="advanced"><?php _e('advanced') ?></option>
<option <?php echo ("side" == $one_post_connector_added_field["context"]) ? " selected='selected' " : "" ?> value="side"><?php _e('side') ?></option>
</select>
<?php _e('Priority', 'simple-fields') ?>
<select name='added_fields[<?php echo $one_post_connector_added_field["id"] ?>][priority]' class="simple-fields-post-connector-addded-fields-option-priority">
<option <?php echo ("low" == $one_post_connector_added_field["priority"]) ? " selected='selected' " : "" ?> value="low"><?php _e('low') ?></option>
<option <?php echo ("high" == $one_post_connector_added_field["priority"]) ? " selected='selected' " : "" ?> value="high"><?php _e('high') ?></option>
</select>
</div>
<a href='#' class='simple-fields-post-connector-addded-fields-delete'><?php _e('Delete', 'simple-fields') ?></a>
</li>
<?php
}
?>
</ul>
</td>
</tr>
<tr>
<th><?php _e('Options', 'simple-fields') ?></th>
<td><input
type="checkbox"
<?php echo $post_connector_in_edit["hide_editor"] == TRUE ? " checked='checked' " : "" ?>
name="hide_editor"
class=""
value="1" />
<?php _e('Hide the built in editor', 'simple-fields') ?>
</td>
</tr>
<tr>
<th>
<?php _e('Available for post types', 'simple-fields') ?>
</th>
<td>
<?php
global $wp_post_types;
$arr_post_types_to_ignore = array("revision", "nav_menu_item");
foreach ($wp_post_types as $one_post_type) {
if (!in_array($one_post_type->name, $arr_post_types_to_ignore)) {
$input_id = "post_types_" . $one_post_type->name;
?>
<p>
<input
<?php echo (in_array($one_post_type->name, $post_connector_in_edit["post_types"]) ? " checked='checked' " : ""); ?>
type="checkbox"
name="post_types[]"
value="<?php echo $one_post_type->name ?>"
id="<?php echo $input_id ?>"
/>
<?php
printf( '<label for="%3$s">%1$s (%2$s)</label>', $one_post_type->labels->name, $one_post_type->name, $input_id);
?>
<?php /* <input <?php echo (in_array($one_post_type->name, $post_connector_in_edit["post_types_type_default"]) ? " checked='checked' " : "") ?> type="checkbox" name="post_types_type_default[]" value="<?php echo $one_post_type->name ?>" />
Default connector for post type <?php echo $one_post_type->name ?>
*/
?>
</p>
<?php
}
}
?>
</td>
</tr>
</table>
<p class="submit">
<input class="button-primary" type="submit" value="<?php _e('Save Changes', 'simple-fields') ?>" />
<input type="hidden" name="action" value="update" />
<input type="hidden" name="post_connector_id" value="<?php echo $post_connector_in_edit["id"] ?>" />
<?php wp_nonce_field( "save-post-connector", "simple-fields" ) ?>
or
<a href="<?php echo SIMPLE_FIELDS_FILE ?>"><?php _e('cancel', 'simple-fields') ?></a>
</p>
<p class="simple-fields-post-connector-delete">
<?php
$action_url = add_query_arg(array("action" => "delete-post-connector", "connector-id" => $post_connector_in_edit["id"]), SIMPLE_FIELDS_FILE);
$action_url = wp_nonce_url( $action_url, "delete-post-connector");
?>
<a href="<?php echo $action_url ?>"><?php _e('Delete') ?></a>
</p>
</form>
<?php
}
/**
* Edit new or existing Field Group
*/
if ("edit-field-group" == $action) {
$field_group_id = (isset($_GET["group-id"])) ? intval($_GET["group-id"]) : false;
$highest_field_id = 0;
$is_new_field_group = false;
// check if field group is new or existing
if ($field_group_id === 0) {
// new: save it as unnamed, and then set to edit that
$is_new_field_group = true;
$field_group_in_edit = simple_fields_register_field_group("", array("deleted" => true, "added_with_code" => false));
$field_group_in_edit["name"] = "";
$field_group_in_edit["slug"] = "";
simple_fields::debug("Added new field group", $field_group_in_edit);
} else {
// check that field group exists
if ( ! isset($field_groups[$field_group_id]) ) {
wp_die( __("Could not find field group. Perhaps it has been deleted?", "simple-fields") );
}
$field_group_in_edit = $field_groups[$field_group_id];
// existing: get highest field id
foreach ($field_groups[$field_group_id]["fields"] as $one_field) {
if ($one_field["id"] > $highest_field_id) {
$highest_field_id = $one_field["id"];
}
}
}
?>
<form method="post" action="<?php echo SIMPLE_FIELDS_FILE ?>&action=edit-field-group-save">
<?php do_action("simple_fields_options_print_nav_tabs", $subpage); ?>
<h3><?php _e('Field group details', 'simple-fields') ?></h3>
<?php
if ( ! empty( $field_group_in_edit["added_with_code"] ) ) {
echo "<div class='simple-fields-message'><p>";
_e("This field group was added with PHP code, so the changes made here may not be permanent.", "simple-fields");
echo "</p></div>";
}
?>
<table class="form-table">
<tr>
<th>
<label for="field_group_name"><?php _e('Name', 'simple-fields') ?></label>
</th>
<td>
<input
type="text"
name="field_group_name"
id="field_group_name"
class="regular-text"
value="<?php echo esc_html($field_group_in_edit["name"]) ?>" required
placeholder="<?php _e("Enter a name for this field group", "simple-fields"); ?>"
<?php if ($is_new_field_group) { ?>
autofocus
<?php } ?>
/>
</td>
</tr>
<tr>
<th>
<label for="field_group_slug"><?php _e('Slug', 'simple-fields') ?></label>
</th>
<td>
<input type="text" name="field_group_slug" id="field_group_slug" class="regular-text"
value="<?php echo esc_html(@$field_group_in_edit["slug"]) ?>"
pattern='<?php echo $this->get_slug_pattern() ?>'
title='<?php echo $this->get_slug_title() ?>'
required
title="<?php _e("Allowed chars: a-z and underscore.", 'simple-fields') ?>"
/>
<br>
<span class="description"><?php echo __("A unique identifier for this field group.", 'simple-fields') ?></span>
</td>
</tr>
<tr>
<th>
<label for="field_group_description"><?php _e('Description', 'simple-fields') ?></label>
</th>
<td>
<input type="text" name="field_group_description" id="field_group_description" class="regular-text"
value="<?php echo esc_html(@$field_group_in_edit["description"]) ?>"
/>
</td>
</th>
<tr>
<th>
<?php echo __("Options", 'simple-fields') ?>
</th>
<td>
<p>
<label for="field_group_repeatable">
<input type="checkbox" <?php echo ($field_group_in_edit["repeatable"] == true) ? "checked='checked'" : ""; ?> value="1" id="field_group_repeatable" name="field_group_repeatable" />
<?php _e('Repeatable', 'simple-fields') ?>
<br>
<span class="description"><?php echo __("With repeatable checked you can add the fields below to a post multiple times. Great for image slideshow, attachments, and similar.", 'simple-fields') ?></span>
</label>
</p>
<p>
<label for="field_group_gui_view">
<input type="checkbox" <?php echo ( isset( $field_group_in_edit["gui_view"] ) && $field_group_in_edit["gui_view"] === "table") ? "checked='checked'" : ""; ?> value="1" id="field_group_gui_view" name="field_group_gui_view" />
<?php _e('Use table view', 'simple-fields') ?>
<br>
<span class="description"><?php echo __("List fields in a more compact and overviewable table view. Works best when you use just a few fields.", 'simple-fields') ?></span>
</label>
</p>
</td>
</tr>
<tr>
<th><h3><?php _e('Fields', 'simple-fields') ?></h3></th>
<td>
<div id="simple-fields-field-group-existing-fields">
<ul class='simple-fields-edit-field-groups-added-fields'>
<?php
foreach ($field_group_in_edit["fields"] as $oneField) {
if (!$oneField["deleted"]) {
echo $this->field_group_add_field_template($oneField["id"], $field_group_in_edit);
}
}
?>
</ul>
</div>
<p><a href="#" id="simple-fields-field-group-add-field">+ <?php _e('Add field', 'simple-fields') ?></a></p>
</td>
</tr>
</table>
<p class="submit">
<input class="button-primary" type="submit" value="<?php _e('Save Changes', 'simple-fields') ?>" />
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="field_group_name" />
<input type="hidden" name="field_group_id" value="<?php echo $field_group_in_edit["id"] ?>" />
<?php wp_nonce_field( "save-field-group", "simple-fields" ) ?>
<?php _e('or', 'simple-fields') ?>
<a href="<?php echo SIMPLE_FIELDS_FILE ?>"><?php _e('cancel', 'simple-fields') ?></a>
</p>
<p class="simple-fields-field-group-delete">
<?php
$action_url = add_query_arg(array("action" => "delete-field-group", "group-id" => $field_group_in_edit["id"]), SIMPLE_FIELDS_FILE);
$action_url = wp_nonce_url( $action_url, "delete-field-group");
?>
<a href="<?php echo $action_url ?>"><?php _e('Delete', 'simple-fields') ?></a>
</p>
</form>
<script type="text/javascript">
var simple_fields_highest_field_id = <?php echo (int) $highest_field_id ?>;
</script>
<?php
}
// overview, if no action
if ( ! $action ) {
do_action("simple_fields_options_print_nav_tabs", $subpage);
/**
* view post connectors
*/
$post_connector_count = 0;
foreach ($post_connectors as $onePostConnector) {
if (!$onePostConnector["deleted"]) {
$post_connector_count++;
}
}
/**
* view list of existing field groups
*/
?>
<div class="simple-fields-edit-field-groups">
<?php
printf('
<h3>
%1$s
<a href="%2$s" class="add-new-h2">%3$s</a>
</h3>
',
__('Field Groups', 'simple-fields'),
SIMPLE_FIELDS_FILE . "&action=edit-field-group&group-id=0",
__('Add new')
);
// Count num of non deleted field groups
$field_group_count = 0;
foreach ($field_groups as $oneFieldGroup) {
if (!$oneFieldGroup["deleted"]) {
$field_group_count++;
}
}
if ($field_groups == $field_group_count) {
echo "<p>".__('No field groups yet.', 'simple-fields')."</p>";
} else {
?>
<table class="wp-list-table widefat fixed">
<thead>
<tr>
<th><?php _e("Name", "simple-fields") ?></th>
<th><?php _e("Slug", "simple-fields") ?></th>
<th><?php _e("Fields", "simple-fields") ?></th>
<th><?php _e("Added fields", "simple-fields") ?></th>
</tr>
</thead>
<tbody>
<?php
$loopnum = 0;
foreach ($field_groups as $oneFieldGroup) {
if ($oneFieldGroup["id"] && !$oneFieldGroup["deleted"]) {
$row_class = $loopnum % 2 == 0 ? "alternate" : "";
$editlink = SIMPLE_FIELDS_FILE . "&action=edit-field-group&group-id=$oneFieldGroup[id]";
$remove_url = add_query_arg(array("action" => "delete-field-group", "group-id" => $oneFieldGroup["id"]), SIMPLE_FIELDS_FILE);
$remove_url = wp_nonce_url( $remove_url, "delete-field-group");
echo "<tr class='$row_class'>";
echo "<td>";
echo "<a href='$editlink'><strong>" . esc_html( $this->get_string( "Field group name, " . $oneFieldGroup["slug"], $oneFieldGroup["name"] ) ) . "</strong></a>";
?><div class="row-actions">
<span class="edit"><a href="<?php echo $editlink ?>" title="<?php _e("Edit this item") ?>"><?php _e("Edit") ?></a></span>
<!-- <span class="trash"><a class="submitdelete" href="<?php echo $remove_url ?>"><?php _e("Trash") ?></a></span> -->
</div><?php
echo "</td>";
printf('<td>%1$s</td>', $oneFieldGroup["slug"]);
echo "<td>";
if ($oneFieldGroup["fields_count"]) {
$format = $oneFieldGroup["repeatable"] ? _n('1 repeatable', '%d repeatable', $oneFieldGroup["fields_count"]) : _n('1', '%d', $oneFieldGroup["fields_count"]);
echo __( sprintf($format, $oneFieldGroup["fields_count"]) );
}
echo "</td>";
// Fields in this field group
echo "<td>";
$fields_out = "";
foreach ( $oneFieldGroup["fields"] as $one_field ) {
if ($one_field["deleted"]) continue;
$fields_out .= sprintf(
'%1$s (%2$s), ',
esc_html($one_field["name"]),
esc_html($one_field["type"])
);
}
$fields_out = preg_replace('/, $/', '', $fields_out);
echo $fields_out;
echo "</td>";
echo "</tr>";
$loopnum++;
}
}
?>
</tbody>
</table>
<?php
}
?>
</div>
<div class="simple-fields-edit-post-connectors">
<h3>
<?php _e('Post Connectors', 'simple-fields') ?>
<a class="add-new-h2" href="<?php echo SIMPLE_FIELDS_FILE ?>&action=edit-post-connector&connector-id=0"><?php _e('Add new') ?></a>
</h3>
<?php
if ($post_connector_count) {
?>
<table class="wp-list-table widefat fixed">
<thead>
<tr>
<th><?php _e("Name", "simple-fields") ?></th>
<th><?php _e("Slug", "simple-fields") ?></th>
<th><?php _e("Field groups", "simple-fields") ?></th>
<th><?php _e("Added field groups", "simple-fields") ?></th>
</tr>
</thead>
<tbody>
<?php
$loopnum = 0;
foreach ($post_connectors as $one_post_connector) {
if ($one_post_connector["deleted"] || !$one_post_connector["id"]) {
continue;
}
$row_class = $loopnum % 2 == 0 ? "alternate" : "";
$edit_url = SIMPLE_FIELDS_FILE . "&action=edit-post-connector&connector-id=" . $one_post_connector["id"];
?>
<tr class='<?php echo $row_class ?>'>
<td>
<a href="<?php echo $edit_url ?>"><strong><?php echo esc_html( $this->get_string( "Post connector name, " . $one_post_connector["slug"], $one_post_connector["name"]) ) ?></strong></a>
<div class="row-actions">
<span class="edit"><a href="<?php echo $edit_url ?>" title="<?php _e("Edit this item") ?>"><?php _e("Edit") ?></a></span>
<!-- <span class="trash"><a class="submitdelete" href="<?php echo $remove_url ?>"><?php _e("Trash") ?></a></span> -->
</div>
</td>
<td>
<?php echo $one_post_connector["slug"] ?>
</td>
<td>
<?php
if ($one_post_connector["field_groups_count"]) {
printf( _n('1', '%d', $one_post_connector["field_groups_count"]), $one_post_connector["field_groups_count"] );
}
?>
</td>
<td>
<?php
$field_groups_output = "";
foreach ( $one_post_connector["field_groups"] as $one_field_group ) {
if ( $one_field_group["deleted"] ) continue;
$field_groups_output .= sprintf( '%1$s, ', esc_attr( $one_field_group["name"] ) );
}
$field_groups_output = preg_replace('/, $/', '', $field_groups_output);
echo $field_groups_output;
?>
</td>
</tr>
<?php
$loopnum++;
}
?>
</tbody>
</table>
<?php
} else {
?>
<!-- <p>No post connectors</p> -->
<?php
}
?>
</div>
<div class="simple-fields-post-type-defaults">
<h3><?php _e('Post Type Defaults', 'simple-fields') ?></h3>
<table class="wp-list-table widefat fixed">
<thead>
<tr>
<th><?php _e("Post type", "simple-fields") ?></th>
<th><?php _e("Default Post Connector", "simple-fields") ?></th>
<th></th><!-- two empty to make table widths same as the other tables -->
<th></th>
</tr>
</thead>
<tbody>
<?php
$post_types = get_post_types();
$arr_post_types_to_ignore = array("revision", "nav_menu_item");
foreach ($post_types as $one_post_type) {
$one_post_type_info = get_post_type_object($one_post_type);
if (!in_array($one_post_type, $arr_post_types_to_ignore)) {
$default_connector = $this->get_default_connector_for_post_type($one_post_type);
switch ($default_connector) {
case "__none__":
$default_connector_str = __('No connector', 'simple-fields');
break;
case "__inherit__":
$default_connector_str = __('Inherit parent connector', 'simple-fields');
break;
default:
if (is_numeric($default_connector)) {
$connector = $this->get_connector_by_id($default_connector);
if ($connector !== FALSE) {
$default_connector_str = $connector["name"];
}
}
}
?>
<tr>
<td>
<a href="<?php echo SIMPLE_FIELDS_FILE ?>&action=edit-post-type-defaults&post-type=<?php echo $one_post_type ?>">
<?php echo $one_post_type_info->label ?>
</a>
</td>
<td>
<span><?php echo $default_connector_str ?></span>
</td>
<td></td>
<td></td>
</tr>
<?php
} // if in array ignore types
} // foreach post type
?>
</tbody>
</table>
</div>
<?php
} // end simple_fields_options