forked from mukto90/mdc-meta-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
149 lines (147 loc) · 5.51 KB
/
example.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
<?php
/**
* Plugin name: MDC Meta Box Example
*/
require dirname( __FILE__ ) . '/class.mdc-metabox.php';
$args = array(
'meta_box_id' => 'sample_meta_id',
'label' => 'Sample Meta Box',
'post_type' => array( 'post', 'page' ),
'context' => 'advanced', // side|normal|advanced
'priority' => 'high', // high|low
'fields' => array(
/**
* PLEASE NOTE
* desc, class, default, readonly, disabled, cols, rows, text_mode, teeny and media_buttons are optional.
*/
array(
'name' => 'sample_text',
'label' => __( 'Text Field' ),
'type' => 'text',
'desc' => __( 'This is a text field.' ),
'class' => 'custom-class',
'default' => 'Hello World!',
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_number',
'label' => __( 'Number Field' ),
'type' => 'number',
'desc' => __( 'This is a number field.' ),
'class' => 'custom-class',
'default' => 10,
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_email',
'label' => __( 'Email Field' ),
'type' => 'email',
'desc' => __( 'This is an email field.' ),
'class' => 'custom-class',
'default' => 'john@doe.com',
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_url',
'label' => __( 'URL Field' ),
'type' => 'url',
'desc' => __( 'This is a url field.' ),
'class' => 'custom-class',
'default' => 'http://johndoe.com',
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_password',
'label' => __( 'Password Field' ),
'type' => 'password',
'desc' => __( 'This is a password field.' ),
'class' => 'custom-class',
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_textarea',
'label' => __( 'Textarea Field' ),
'type' => 'textarea',
'desc' => __( 'This is a textarea field.' ),
'class' => 'custom-class',
'columns' => 24,
'rows' => 5,
'default' => 'lorem ipsum dolor sit amet',
'readonly' => false, // true|false
'disabled' => false, // true|false
),
array(
'name' => 'sample_radio',
'label' => __( 'Radio Field' ),
'type' => 'radio',
'desc' => __( 'This is a radio field.' ),
'class' => 'custom-class',
'options' => array(
'item_1' => 'Item One',
'item_2' => 'Item Two',
'item_3' => 'Item Three',
),
'default' => 'item_2',
'disabled' => false, // true|false
),
array(
'name' => 'sample_select',
'label' => __( 'Select Field' ),
'type' => 'select',
'desc' => __( 'This is a select field.' ),
'class' => 'custom-class',
'options' => array(
'option_1' => 'Option One',
'option_2' => 'Option Two',
'option_3' => 'Option Three',
),
'default' => 'option_2',
'disabled' => false, // true|false
),
array(
'name' => 'sample_checkbox',
'label' => __( 'Checkbox Field' ),
'type' => 'checkbox',
'desc' => __( 'This is a checkbox field.' ),
'class' => 'custom-class',
'disabled' => false, // true|false
),
array(
'name' => 'sample_color',
'label' => __( 'Color Field' ),
'type' => 'color',
'desc' => __( 'This is a color field.' ),
'class' => 'regular-text',
'default' => '#f00'
),
array(
'name' => 'sample_wysiwyg',
'label' => __( 'WYSIWYG' ),
'type' => 'wysiwyg',
'desc' => __( 'This is a wysiwyg field.' ),
'class' => 'regular-text',
'width' => '100%',
'rows' => 5,
'teeny' => true,
'text_mode' => false, // true|false
'media_buttons' => false, // true|false
'default' => 'Hello World'
),
array(
'name' => 'sample_file',
'label' => __( 'File Field' ),
'type' => 'file',
'button_text' => __( 'Upload' ),
'desc' => __( 'This is a file field.' ),
'class' => 'regular-text',
'disabled' => false, // true|false
'default' => 'http://example.com/sample/file.txt'
),
)
);
mdc_meta_box( $args );