1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Leonidas\Library\Admin\Fields\Managers\PostMetaFieldManager; |
|
|
|
|
4
|
|
|
use Leonidas\Library\Admin\Forms\Controllers\PostMetaboxFormSubmissionManager; |
|
|
|
|
5
|
|
|
use Leonidas\Library\Admin\Metabox\AutoLoadingMetabox; |
|
|
|
|
6
|
|
|
use Leonidas\Library\Admin\Metabox\Components\FieldGrid; |
|
|
|
|
7
|
|
|
use Leonidas\Library\Admin\Metabox\Components\Section; |
|
|
|
|
8
|
|
|
use Leonidas\Library\Core\Auth\Nonce; |
9
|
|
|
use WebTheory\Saveyour\Controllers\FormFieldController; |
|
|
|
|
10
|
|
|
use WebTheory\Saveyour\Fields\Time; |
|
|
|
|
11
|
|
|
|
12
|
|
|
################################################################################ |
13
|
|
|
|
14
|
|
|
$postType = 'wts_test_cpt_2'; |
15
|
|
|
$nonce = new Nonce('wts-metabox', 'edit_' . $postType); |
16
|
|
|
|
17
|
|
|
$metabox = (new AutoLoadingMetabox('wts_hours', 'Hours', $postType)) |
18
|
|
|
->setNonce($nonce) |
19
|
|
|
->hook(); |
20
|
|
|
|
21
|
|
|
$formController = (new PostMetaboxFormSubmissionManager($postType)) |
22
|
|
|
->setTokenManager($nonce) |
23
|
|
|
->hook(); |
24
|
|
|
|
25
|
|
|
// rows |
26
|
|
|
$days = [ |
27
|
|
|
'Sunday', |
28
|
|
|
'Monday', |
29
|
|
|
'Tuesday', |
30
|
|
|
'Wednesday', |
31
|
|
|
'Thursday', |
32
|
|
|
'Friday', |
33
|
|
|
'Saturday', |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
// columns |
37
|
|
|
$times = ['Open', 'Close']; |
38
|
|
|
|
39
|
|
|
$fieldGrid = (new FieldGrid())->setColumnWidth(2); |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* populate $fieldGrid and |
43
|
|
|
*/ |
44
|
|
|
foreach ($times as $time) { |
45
|
|
|
$fieldGrid->addColumn(strtolower($time), $time); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
foreach ($days as $day) { |
49
|
|
|
$daySlug = strtolower($day); |
50
|
|
|
$fieldGrid->addRow($daySlug, $day); |
51
|
|
|
|
52
|
|
|
foreach ($times as $time) { |
53
|
|
|
$timeSlug = strtolower($time); |
54
|
|
|
$slug = "{$daySlug}_{$timeSlug}"; |
55
|
|
|
|
56
|
|
|
$element = (new Time()) |
57
|
|
|
->setId("ba--{$daySlug}--{$timeSlug}") |
58
|
|
|
->setName($slug); |
59
|
|
|
|
60
|
|
|
$data = (new PostMetaFieldManager("ba_location_hours__{$slug}")); |
61
|
|
|
|
62
|
|
|
$field = (new FormFieldController($slug, $element, $data)); |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* populate form submission manager with each field |
66
|
|
|
* |
67
|
|
|
* @var PostMetaboxFormSubmissionManager $formController |
68
|
|
|
*/ |
69
|
|
|
$formController->addField($field); |
70
|
|
|
|
71
|
|
|
$fieldGrid->addField($daySlug, $timeSlug, $field); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// create section and add fieldgrid as content |
76
|
|
|
$section = (new Section('Hours'))->addContent('hours', $fieldGrid); |
77
|
|
|
|
78
|
|
|
// |
79
|
|
|
$metabox->addContent('hours', $section); |
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths