@@ -24,3 +24,179 @@ Per avere maggiore controllo sulle opzioni, puoi usare direttamente la classe `I
24
24
Aggiorna il repository composer di Idearia come da istruzioni:
25
25
26
26
* https://trello.com/c/Q4wyOV9u/
27
+
28
+
29
+ # Esempio pagina di menu semplice
30
+
31
+ ``` php
32
+ <?php
33
+
34
+ use Idearia\MenuPage;
35
+
36
+ class ExampleMenuPage extends MenuPage
37
+ {
38
+ protected $label = 'Example Menu Page';
39
+
40
+ protected $slug = 'example-menu-page';
41
+
42
+ protected $capability = 'edit_posts';
43
+
44
+ public function view()
45
+ {
46
+ echo '<h1 >Hello world</h1 >';
47
+ echo '<p >';
48
+ echo 'Questa pagina può essere vista solo dagli editor in su.';
49
+ echo '</p >';
50
+ }
51
+ }
52
+ ```
53
+
54
+ # Esempio pagina dei settings completa
55
+
56
+ ``` php
57
+ <?php
58
+
59
+ use Idearia\SettingsPage;
60
+
61
+ class ExampleSettingsPage extends SettingsPage
62
+ {
63
+ protected $label = 'Example Settings Page';
64
+
65
+ protected $slug = 'example-settings-page';
66
+
67
+ public function getSections()
68
+ {
69
+ return array(
70
+ array(
71
+ 'id' => 'wedevs_basics',
72
+ 'title' => __( 'Basic Settings', 'wedevs' )
73
+ ),
74
+ array(
75
+ 'id' => 'wedevs_advanced',
76
+ 'title' => __( 'Advanced Settings', 'wedevs' )
77
+ )
78
+ );
79
+ }
80
+
81
+ public function getFields()
82
+ {
83
+ return array(
84
+ 'wedevs_basics' => array(
85
+ array(
86
+ 'name' => 'text_val',
87
+ 'label' => __( 'Text Input', 'wedevs' ),
88
+ 'desc' => __( 'Text input description', 'wedevs' ),
89
+ 'placeholder' => __( 'Text Input placeholder', 'wedevs' ),
90
+ 'type' => 'text',
91
+ 'default' => 'Title',
92
+ 'sanitize_callback' => 'sanitize_text_field'
93
+ ),
94
+ array(
95
+ 'name' => 'number_input',
96
+ 'label' => __( 'Number Input', 'wedevs' ),
97
+ 'desc' => __( 'Number field with validation callback `floatval`', 'wedevs' ),
98
+ 'placeholder' => __( '1.99', 'wedevs' ),
99
+ 'min' => 0,
100
+ 'max' => 100,
101
+ 'step' => '0.01',
102
+ 'type' => 'number',
103
+ 'default' => 'Title',
104
+ 'sanitize_callback' => 'floatval'
105
+ ),
106
+ array(
107
+ 'name' => 'textarea',
108
+ 'label' => __( 'Textarea Input', 'wedevs' ),
109
+ 'desc' => __( 'Textarea description', 'wedevs' ),
110
+ 'placeholder' => __( 'Textarea placeholder', 'wedevs' ),
111
+ 'type' => 'textarea'
112
+ ),
113
+ array(
114
+ 'name' => 'html',
115
+ 'desc' => __( 'HTML area description. You can use any <strong >bold</strong > or other HTML elements.', 'wedevs' ),
116
+ 'type' => 'html'
117
+ ),
118
+ array(
119
+ 'name' => 'checkbox',
120
+ 'label' => __( 'Checkbox', 'wedevs' ),
121
+ 'desc' => __( 'Checkbox Label', 'wedevs' ),
122
+ 'type' => 'checkbox'
123
+ ),
124
+ array(
125
+ 'name' => 'radio',
126
+ 'label' => __( 'Radio Button', 'wedevs' ),
127
+ 'desc' => __( 'A radio button', 'wedevs' ),
128
+ 'type' => 'radio',
129
+ 'options' => array(
130
+ 'yes' => 'Yes',
131
+ 'no' => 'No'
132
+ )
133
+ ),
134
+ array(
135
+ 'name' => 'selectbox',
136
+ 'label' => __( 'A Dropdown', 'wedevs' ),
137
+ 'desc' => __( 'Dropdown description', 'wedevs' ),
138
+ 'type' => 'select',
139
+ 'default' => 'no',
140
+ 'options' => array(
141
+ 'yes' => 'Yes',
142
+ 'no' => 'No'
143
+ )
144
+ ),
145
+ array(
146
+ 'name' => 'password',
147
+ 'label' => __( 'Password', 'wedevs' ),
148
+ 'desc' => __( 'Password description', 'wedevs' ),
149
+ 'type' => 'password',
150
+ 'default' => ''
151
+ ),
152
+ array(
153
+ 'name' => 'file',
154
+ 'label' => __( 'File', 'wedevs' ),
155
+ 'desc' => __( 'File description', 'wedevs' ),
156
+ 'type' => 'file',
157
+ 'default' => '',
158
+ 'options' => array(
159
+ 'button_label' => 'Choose Image'
160
+ )
161
+ )
162
+ ),
163
+ 'wedevs_advanced' => array(
164
+ array(
165
+ 'name' => 'color',
166
+ 'label' => __( 'Color', 'wedevs' ),
167
+ 'desc' => __( 'Color description', 'wedevs' ),
168
+ 'type' => 'color',
169
+ 'default' => ''
170
+ ),
171
+ array(
172
+ 'name' => 'password',
173
+ 'label' => __( 'Password', 'wedevs' ),
174
+ 'desc' => __( 'Password description', 'wedevs' ),
175
+ 'type' => 'password',
176
+ 'default' => ''
177
+ ),
178
+ array(
179
+ 'name' => 'wysiwyg',
180
+ 'label' => __( 'Advanced Editor', 'wedevs' ),
181
+ 'desc' => __( 'WP_Editor description', 'wedevs' ),
182
+ 'type' => 'wysiwyg',
183
+ 'default' => ''
184
+ ),
185
+ array(
186
+ 'name' => 'multicheck',
187
+ 'label' => __( 'Multile checkbox', 'wedevs' ),
188
+ 'desc' => __( 'Multi checkbox description', 'wedevs' ),
189
+ 'type' => 'multicheck',
190
+ 'default' => array('one' => 'one', 'four' => 'four'),
191
+ 'options' => array(
192
+ 'one' => 'One',
193
+ 'two' => 'Two',
194
+ 'three' => 'Three',
195
+ 'four' => 'Four'
196
+ )
197
+ ),
198
+ )
199
+ );
200
+ }
201
+ }
202
+ ```
0 commit comments