← All changes
|
vendor/tareq1988/wordpress-settings-api-class/example/oop-example.php
+116
-20
2.2
→
3.7.2
View file →
| @@ -33,14 +33,18 @@ | ||
| 33 | 33 | |
| 34 | 34 | function get_settings_sections() { |
| 35 | 35 | $sections = array( |
| 36 | 36 | array( |
| 37 | - 'id' => 'wedevs_basics', | |
| 37 | + 'id' => 'wedevs_basics', | |
| 38 | 38 | 'title' => __( 'Basic Settings', 'wedevs' ) |
| 39 | 39 | ), |
| 40 | 40 | array( |
| 41 | - 'id' => 'wedevs_advanced', | |
| 41 | + 'id' => 'wedevs_advanced', | |
| 42 | 42 | 'title' => __( 'Advanced Settings', 'wedevs' ) |
| 43 | + ), | |
| 44 | + array( | |
| 45 | + 'id' => 'wedevs_others', | |
| 46 | + 'title' => __( 'Other Settings', 'wpuf' ) | |
| 43 | 47 | ) |
| 44 | 48 | ); |
| 45 | 49 | return $sections; |
| 46 | 50 | } |
| @@ -56,38 +60,27 @@ | ||
| 56 | 60 | array( |
| 57 | 61 | 'name' => 'text_val', |
| 58 | 62 | 'label' => __( 'Text Input', 'wedevs' ), |
| 59 | 63 | 'desc' => __( 'Text input description', 'wedevs' ), |
| 60 | - 'placeholder' => __( 'Text Input placeholder', 'wedevs' ), | |
| 61 | 64 | 'type' => 'text', |
| 62 | 65 | 'default' => 'Title', |
| 63 | - 'sanitize_callback' => 'sanitize_text_field' | |
| 66 | + 'sanitize_callback' => 'intval' | |
| 64 | 67 | ), |
| 65 | 68 | array( |
| 66 | 69 | 'name' => 'number_input', |
| 67 | 70 | 'label' => __( 'Number Input', 'wedevs' ), |
| 68 | - 'desc' => __( 'Number field with validation callback `floatval`', 'wedevs' ), | |
| 69 | - 'placeholder' => __( '1.99', 'wedevs' ), | |
| 70 | - 'min' => 0, | |
| 71 | - 'max' => 100, | |
| 72 | - 'step' => '0.01', | |
| 71 | + 'desc' => __( 'Number field with validation callback `intval`', 'wedevs' ), | |
| 73 | 72 | 'type' => 'number', |
| 74 | 73 | 'default' => 'Title', |
| 75 | - 'sanitize_callback' => 'floatval' | |
| 74 | + 'sanitize_callback' => 'intval' | |
| 76 | 75 | ), |
| 77 | 76 | array( |
| 78 | - 'name' => 'textarea', | |
| 79 | - 'label' => __( 'Textarea Input', 'wedevs' ), | |
| 80 | - 'desc' => __( 'Textarea description', 'wedevs' ), | |
| 81 | - 'placeholder' => __( 'Textarea placeholder', 'wedevs' ), | |
| 82 | - 'type' => 'textarea' | |
| 77 | + 'name' => 'textarea', | |
| 78 | + 'label' => __( 'Textarea Input', 'wedevs' ), | |
| 79 | + 'desc' => __( 'Textarea description', 'wedevs' ), | |
| 80 | + 'type' => 'textarea' | |
| 83 | 81 | ), |
| 84 | 82 | array( |
| 85 | - 'name' => 'html', | |
| 86 | - 'desc' => __( 'HTML area description. You can use any <strong>bold</strong> or other HTML elements.', 'wedevs' ), | |
| 87 | - 'type' => 'html' | |
| 88 | - ), | |
| 89 | - array( | |
| 90 | 83 | 'name' => 'checkbox', |
| 91 | 84 | 'label' => __( 'Checkbox', 'wedevs' ), |
| 92 | 85 | 'desc' => __( 'Checkbox Label', 'wedevs' ), |
| 93 | 86 | 'type' => 'checkbox' |
| @@ -102,8 +95,20 @@ | ||
| 102 | 95 | 'no' => 'No' |
| 103 | 96 | ) |
| 104 | 97 | ), |
| 105 | 98 | array( |
| 99 | + 'name' => 'multicheck', | |
| 100 | + 'label' => __( 'Multile checkbox', 'wedevs' ), | |
| 101 | + 'desc' => __( 'Multi checkbox description', 'wedevs' ), | |
| 102 | + 'type' => 'multicheck', | |
| 103 | + 'options' => array( | |
| 104 | + 'one' => 'One', | |
| 105 | + 'two' => 'Two', | |
| 106 | + 'three' => 'Three', | |
| 107 | + 'four' => 'Four' | |
| 108 | + ) | |
| 109 | + ), | |
| 110 | + array( | |
| 106 | 111 | 'name' => 'selectbox', |
| 107 | 112 | 'label' => __( 'A Dropdown', 'wedevs' ), |
| 108 | 113 | 'desc' => __( 'Dropdown description', 'wedevs' ), |
| 109 | 114 | 'type' => 'select', |
| @@ -165,8 +170,99 @@ | ||
| 165 | 170 | 'three' => 'Three', |
| 166 | 171 | 'four' => 'Four' |
| 167 | 172 | ) |
| 168 | 173 | ), |
| 174 | + array( | |
| 175 | + 'name' => 'selectbox', | |
| 176 | + 'label' => __( 'A Dropdown', 'wedevs' ), | |
| 177 | + 'desc' => __( 'Dropdown description', 'wedevs' ), | |
| 178 | + 'type' => 'select', | |
| 179 | + 'options' => array( | |
| 180 | + 'yes' => 'Yes', | |
| 181 | + 'no' => 'No' | |
| 182 | + ) | |
| 183 | + ), | |
| 184 | + array( | |
| 185 | + 'name' => 'password', | |
| 186 | + 'label' => __( 'Password', 'wedevs' ), | |
| 187 | + 'desc' => __( 'Password description', 'wedevs' ), | |
| 188 | + 'type' => 'password', | |
| 189 | + 'default' => '' | |
| 190 | + ), | |
| 191 | + array( | |
| 192 | + 'name' => 'file', | |
| 193 | + 'label' => __( 'File', 'wedevs' ), | |
| 194 | + 'desc' => __( 'File description', 'wedevs' ), | |
| 195 | + 'type' => 'file', | |
| 196 | + 'default' => '' | |
| 197 | + ) | |
| 198 | + ), | |
| 199 | + 'wedevs_others' => array( | |
| 200 | + array( | |
| 201 | + 'name' => 'text', | |
| 202 | + 'label' => __( 'Text Input', 'wedevs' ), | |
| 203 | + 'desc' => __( 'Text input description', 'wedevs' ), | |
| 204 | + 'type' => 'text', | |
| 205 | + 'default' => 'Title' | |
| 206 | + ), | |
| 207 | + array( | |
| 208 | + 'name' => 'textarea', | |
| 209 | + 'label' => __( 'Textarea Input', 'wedevs' ), | |
| 210 | + 'desc' => __( 'Textarea description', 'wedevs' ), | |
| 211 | + 'type' => 'textarea' | |
| 212 | + ), | |
| 213 | + array( | |
| 214 | + 'name' => 'checkbox', | |
| 215 | + 'label' => __( 'Checkbox', 'wedevs' ), | |
| 216 | + 'desc' => __( 'Checkbox Label', 'wedevs' ), | |
| 217 | + 'type' => 'checkbox' | |
| 218 | + ), | |
| 219 | + array( | |
| 220 | + 'name' => 'radio', | |
| 221 | + 'label' => __( 'Radio Button', 'wedevs' ), | |
| 222 | + 'desc' => __( 'A radio button', 'wedevs' ), | |
| 223 | + 'type' => 'radio', | |
| 224 | + 'options' => array( | |
| 225 | + 'yes' => 'Yes', | |
| 226 | + 'no' => 'No' | |
| 227 | + ) | |
| 228 | + ), | |
| 229 | + array( | |
| 230 | + 'name' => 'multicheck', | |
| 231 | + 'label' => __( 'Multile checkbox', 'wedevs' ), | |
| 232 | + 'desc' => __( 'Multi checkbox description', 'wedevs' ), | |
| 233 | + 'type' => 'multicheck', | |
| 234 | + 'options' => array( | |
| 235 | + 'one' => 'One', | |
| 236 | + 'two' => 'Two', | |
| 237 | + 'three' => 'Three', | |
| 238 | + 'four' => 'Four' | |
| 239 | + ) | |
| 240 | + ), | |
| 241 | + array( | |
| 242 | + 'name' => 'selectbox', | |
| 243 | + 'label' => __( 'A Dropdown', 'wedevs' ), | |
| 244 | + 'desc' => __( 'Dropdown description', 'wedevs' ), | |
| 245 | + 'type' => 'select', | |
| 246 | + 'options' => array( | |
| 247 | + 'yes' => 'Yes', | |
| 248 | + 'no' => 'No' | |
| 249 | + ) | |
| 250 | + ), | |
| 251 | + array( | |
| 252 | + 'name' => 'password', | |
| 253 | + 'label' => __( 'Password', 'wedevs' ), | |
| 254 | + 'desc' => __( 'Password description', 'wedevs' ), | |
| 255 | + 'type' => 'password', | |
| 256 | + 'default' => '' | |
| 257 | + ), | |
| 258 | + array( | |
| 259 | + 'name' => 'file', | |
| 260 | + 'label' => __( 'File', 'wedevs' ), | |
| 261 | + 'desc' => __( 'File description', 'wedevs' ), | |
| 262 | + 'type' => 'file', | |
| 263 | + 'default' => '' | |
| 264 | + ) | |
| 169 | 265 | ) |
| 170 | 266 | ); |
| 171 | 267 | |
| 172 | 268 | return $settings_fields; |