|
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\Fieldset; |
|
|
|
|
|
|
7
|
|
|
use Leonidas\Library\Core\Auth\Nonce; |
|
8
|
|
|
use Respect\Validation\Validator; |
|
9
|
|
|
use WebTheory\Saveyour\Controllers\FormFieldController; |
|
|
|
|
|
|
10
|
|
|
use WebTheory\Saveyour\Fields\Email; |
|
|
|
|
|
|
11
|
|
|
use WebTheory\Saveyour\Fields\Input; |
|
|
|
|
|
|
12
|
|
|
use WebTheory\Saveyour\Request; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
######################################################################################################################## |
|
15
|
|
|
|
|
16
|
|
|
// exit(var_dump($_REQUEST)); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
$postType = 'wts_test_cpt'; |
|
22
|
|
|
$nonce = new Nonce('wts-metabox', 'save-post-fields'); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* create fields |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
// phone |
|
29
|
|
|
$field = (new Input()) |
|
30
|
|
|
->setPlaceholder('Phone') |
|
31
|
|
|
->setId('wts-phone'); |
|
32
|
|
|
$phoneData = (new PostMetaFieldManager('wts-phone')); |
|
33
|
|
|
$phone = (new FormFieldController('wts-phone', $field, $phoneData)); |
|
34
|
|
|
$phone->addRule('phone', Validator::optional(Validator::phone()), 'Enter Valid Phone Number'); |
|
35
|
|
|
|
|
36
|
|
|
// fax |
|
37
|
|
|
$field = (new Input()) |
|
38
|
|
|
->setPlaceholder('Fax') |
|
39
|
|
|
->setId('wts-fax'); |
|
40
|
|
|
$data = (new PostMetaFieldManager('wts-fax')); |
|
41
|
|
|
$fax = (new FormFieldController('wts-fax', $field, $data)); |
|
42
|
|
|
$fax->addRule('fax', Validator::optional(Validator::phone()), 'Enter Valid Fax Number'); |
|
43
|
|
|
|
|
44
|
|
|
// email |
|
45
|
|
|
$field = (new Input()) |
|
46
|
|
|
->setPlaceholder('Email') |
|
47
|
|
|
->setId('wts-email'); |
|
48
|
|
|
$data = (new PostMetaFieldManager('wts-email')); |
|
49
|
|
|
$email = new FormFieldController('wts-email', $field, $data); |
|
50
|
|
|
$email->addRule('email', Validator::optional(Validator::email()), 'Enter Valid Email'); |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* |
|
55
|
|
|
*/ |
|
56
|
|
|
$formController = (new PostMetaboxFormSubmissionManager($postType)) |
|
57
|
|
|
->setFields($phone, $fax, $email) |
|
58
|
|
|
->setNonce($nonce) |
|
59
|
|
|
->hook(); |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* create fieldset |
|
63
|
|
|
*/ |
|
64
|
|
|
$contactInfo = new Fieldset('Contact Information', $formController); |
|
65
|
|
|
$contactInfo->addFields([ |
|
66
|
|
|
'phone' => [ |
|
67
|
|
|
'field' => $phone, |
|
68
|
|
|
'label' => 'Phone', |
|
69
|
|
|
'description' => 'Enter phone number', |
|
70
|
|
|
], |
|
71
|
|
|
|
|
72
|
|
|
'fax' => [ |
|
73
|
|
|
'field' => $fax, |
|
74
|
|
|
'label' => 'Fax', |
|
75
|
|
|
'description' => 'Enter fax number', |
|
76
|
|
|
], |
|
77
|
|
|
|
|
78
|
|
|
'email' => [ |
|
79
|
|
|
'field' => $email, |
|
80
|
|
|
'label' => 'Email', |
|
81
|
|
|
'description' => 'Enter email address', |
|
82
|
|
|
], |
|
83
|
|
|
]); |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
// |
|
87
|
|
|
$metabox = (new AutoLoadingMetabox('fieldset-test', 'Fieldset Test', $postType)) |
|
88
|
|
|
->setNonce($nonce) |
|
89
|
|
|
->addContent('contact_info', $contactInfo) |
|
90
|
|
|
->hook(); |
|
91
|
|
|
|
|
92
|
|
|
################################################################################ |
|
93
|
|
|
# |
|
94
|
|
|
################################################################################ |
|
95
|
|
|
|
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