-
Notifications
You must be signed in to change notification settings - Fork 28
/
wposa-init.php
263 lines (236 loc) · 5.08 KB
/
wposa-init.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
<?php
/**
* Plugin Name: WP OOP Settings API
* Plugin URI: http://AhmadAwais.com/
* Description: Settings API wrapper built with Object Oriented Programming practices.
* Author: mrahmadawais, WPTie, deviodigital
* Author URI: http://AhmadAwais.com/
* Version: 1.0.0
* License: GPL2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*
* @package WPOSA
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Define global constants.
*
* @since 1.0.0
*/
// Plugin version.
if ( ! defined( 'WPOSA_VERSION' ) ) {
define( 'WPOSA_VERSION', '1.0.0' );
}
if ( ! defined( 'WPOSA_NAME' ) ) {
define( 'WPOSA_NAME', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
}
if ( ! defined( 'WPOSA_DIR' ) ) {
define( 'WPOSA_DIR', WP_PLUGIN_DIR . '/' . WPOSA_NAME );
}
if ( ! defined( 'WPOSA_URL' ) ) {
define( 'WPOSA_URL', WP_PLUGIN_URL . '/' . WPOSA_NAME );
}
/**
* WP-OOP-Settings-API Initializer
*
* Initializes the WP-OOP-Settings-API.
*
* @since 1.0.0
*/
/**
* Class `WP_OOP_Settings_API`.
*
* @since 1.0.0
*/
require_once WPOSA_DIR . '/class-wp-osa.php';
/**
* Actions/Filters
*
* Related to all settings API.
*
* @since 1.0.0
*/
if ( class_exists( 'WP_OSA' ) ) {
/**
* Object Instantiation.
*
* Object for the class `WP_OSA`.
*/
$wposa_obj = new WP_OSA();
// Section: Basic Settings.
$wposa_obj->add_section(
array(
'id' => 'wposa_basic',
'title' => __( 'Basic Settings', 'WPOSA' ),
)
);
// Section: Other Settings.
$wposa_obj->add_section(
array(
'id' => 'wposa_other',
'title' => __( 'Other Settings', 'WPOSA' ),
)
);
// Field: Text.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'text',
'type' => 'text',
'name' => __( 'Text Input', 'WPOSA' ),
'desc' => __( 'Text input description', 'WPOSA' ),
'default' => 'Default Text',
)
);
// Field: Number.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'text_no',
'type' => 'number',
'name' => __( 'Number Input', 'WPOSA' ),
'desc' => __( 'Number field with validation callback `intval`', 'WPOSA' ),
'default' => 1,
'sanitize_callback' => 'intval',
)
);
// Field: Password.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'password',
'type' => 'password',
'name' => __( 'Password Input', 'WPOSA' ),
'desc' => __( 'Password field description', 'WPOSA' ),
)
);
// Field: Textarea.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'textarea',
'type' => 'textarea',
'name' => __( 'Textarea Input', 'WPOSA' ),
'desc' => __( 'Textarea description', 'WPOSA' ),
)
);
// Field: Separator.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'separator',
'type' => 'separator',
)
);
// Field: Title.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'title',
'type' => 'title',
'name' => '<h1>Title</h1>',
)
);
// Field: Checkbox.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'checkbox',
'type' => 'checkbox',
'name' => __( 'Checkbox', 'WPOSA' ),
'desc' => __( 'Checkbox Label', 'WPOSA' ),
)
);
// Field: Radio.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'radio',
'type' => 'radio',
'name' => __( 'Radio', 'WPOSA' ),
'desc' => __( 'Radio Button', 'WPOSA' ),
'options' => array(
'yes' => 'Yes',
'no' => 'No',
),
)
);
// Field: Multicheck.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'multicheck',
'type' => 'multicheck',
'name' => __( 'Multile checkbox', 'WPOSA' ),
'desc' => __( 'Multile checkbox description', 'WPOSA' ),
'options' => array(
'yes' => 'Yes',
'no' => 'No',
),
)
);
// Field: Select.
$wposa_obj->add_field(
'wposa_basic',
array(
'id' => 'select',
'type' => 'select',
'name' => __( 'A Dropdown', 'WPOSA' ),
'desc' => __( 'A Dropdown description', 'WPOSA' ),
'options' => array(
'yes' => 'Yes',
'no' => 'No',
),
)
);
// Field: Image.
$wposa_obj->add_field(
'wposa_other',
array(
'id' => 'image',
'type' => 'image',
'name' => __( 'Image', 'WPOSA' ),
'desc' => __( 'Image description', 'WPOSA' ),
'options' => array(
'button_label' => 'Choose Image',
),
)
);
// Field: File.
$wposa_obj->add_field(
'wposa_other',
array(
'id' => 'file',
'type' => 'file',
'name' => __( 'File', 'WPOSA' ),
'desc' => __( 'File description', 'WPOSA' ),
'options' => array(
'button_label' => 'Choose file',
),
)
);
// Field: Color.
$wposa_obj->add_field(
'wposa_other',
array(
'id' => 'color',
'type' => 'color',
'name' => __( 'Color', 'WPOSA' ),
'desc' => __( 'Color description', 'WPOSA' ),
'placeholder' => __( '#5F4B8B', 'WPOSA' ),
)
);
// Field: WYSIWYG.
$wposa_obj->add_field(
'wposa_other',
array(
'id' => 'wysiwyg',
'type' => 'wysiwyg',
'name' => __( 'WP_Editor', 'WPOSA' ),
'desc' => __( 'WP_Editor description', 'WPOSA' ),
)
);
}