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\Field; |
|
|
|
|
7
|
|
|
use Leonidas\Library\Admin\Metabox\Components\Section; |
|
|
|
|
8
|
|
|
use Leonidas\Library\Core\Auth\Nonce; |
9
|
|
|
use Leonidas\Library\Core\Http\Policy\PostConstrainer; |
|
|
|
|
10
|
|
|
use Respect\Validation\Validator; |
11
|
|
|
use WebTheory\Saveyour\Controllers\FormFieldController; |
|
|
|
|
12
|
|
|
use WebTheory\Saveyour\Fields\Email; |
|
|
|
|
13
|
|
|
use WebTheory\Saveyour\Fields\Input; |
|
|
|
|
14
|
|
|
|
15
|
|
|
################################################################################ |
16
|
|
|
# Base |
17
|
|
|
################################################################################ |
18
|
|
|
$postType = 'wts_test_cpt'; |
19
|
|
|
|
20
|
|
|
################################################################################ |
21
|
|
|
# Fields |
22
|
|
|
################################################################################ |
23
|
|
|
|
24
|
|
|
// phone |
25
|
|
|
$field = (new Input()) |
26
|
|
|
->setPlaceholder('Phone') |
27
|
|
|
->setId('wts-phone'); |
28
|
|
|
$phoneData = (new PostMetaFieldManager('wts-phone')); |
29
|
|
|
$phone = (new FormFieldController('wts-phone', $field, $phoneData)); |
30
|
|
|
$phone->addRule('phone', Validator::optional(Validator::phone()), 'Enter Valid Phone Number'); |
31
|
|
|
$phoneField = (new Field($phone)) |
32
|
|
|
->setLabel('phone'); |
33
|
|
|
|
34
|
|
|
// fax |
35
|
|
|
$field = (new Input()) |
36
|
|
|
->setPlaceholder('Fax') |
37
|
|
|
->setId('wts-fax'); |
38
|
|
|
$data = (new PostMetaFieldManager('wts-fax')); |
39
|
|
|
$fax = (new FormFieldController('wts-fax', $field, $data)); |
40
|
|
|
$fax->addRule('fax', Validator::optional(Validator::phone()), 'Enter Valid Fax Number'); |
41
|
|
|
$faxField = (new Field($fax)) |
42
|
|
|
->setLabel('fax') |
43
|
|
|
->setConstraints(new PostConstrainer(4)); |
44
|
|
|
|
45
|
|
|
// email |
46
|
|
|
$field = (new Input()) |
47
|
|
|
->setPlaceholder('Email') |
48
|
|
|
->setId('wts-email'); |
49
|
|
|
$data = (new PostMetaFieldManager('wts-email')); |
50
|
|
|
$email = new FormFieldController('wts-email', $field, $data); |
51
|
|
|
$email->addRule('email', Validator::optional(Validator::email()), 'Enter Valid Email'); |
52
|
|
|
$emailField = (new Field($email)) |
53
|
|
|
->setLabel('email'); |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
################################################################################ |
57
|
|
|
# Form |
58
|
|
|
################################################################################ |
59
|
|
|
$nonce = new Nonce('wts-metabox', 'save-post-fields'); |
60
|
|
|
|
61
|
|
|
# submission manager |
62
|
|
|
$formController = (new PostMetaboxFormSubmissionManager($postType)) |
63
|
|
|
->setFields($phone, $fax, $email) |
64
|
|
|
->setNonce($nonce) |
65
|
|
|
->hook(); |
66
|
|
|
|
67
|
|
|
# section |
68
|
|
|
$contactInfo = (new Section('Contact Information')) |
69
|
|
|
->addContent('phone', $phoneField) |
70
|
|
|
->addContent('fax', $faxField) |
71
|
|
|
->addContent('email', $emailField); |
72
|
|
|
|
73
|
|
|
# metabox |
74
|
|
|
$metabox = (new AutoLoadingMetabox('section-test', 'Section Test', $postType)) |
75
|
|
|
->addContent('contact_info', $contactInfo) |
76
|
|
|
->setNonce($nonce) |
77
|
|
|
->hook(); |
78
|
|
|
|
79
|
|
|
################################################################################ |
80
|
|
|
# |
81
|
|
|
################################################################################ |
82
|
|
|
|
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