PluginProbe
ANAC XML Bandi di Gara / 0.1
ANAC XML Bandi di Gara v0.1
7.8 trunk 0.1 1.0.0.1 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.1.1 1.1.2 2.0 2.0.1 2.0.2 2.0.3 2.1 2.2 2.3 2.3.1 3 3.0.1 3.1 3.1.1 3.1.2 3.1.3 All 57 releases
avcp / example-functions.php

example-functions.php in ANAC XML Bandi di Gara 0.1, at example-functions.php

237 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Include and setup custom metaboxes and fields.
4 *
5 * @category YourThemeOrPlugin
6 * @package Metaboxes
7 * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
8 * @link https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
9 */
10
11 add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );
12 /**
13 * Define the metabox and field configurations.
14 *
15 * @param array $meta_boxes
16 * @return array
17 */
18 function cmb_sample_metaboxes( array $meta_boxes ) {
19
20 // Start with an underscore to hide fields from custom fields list
21 $prefix = '_cmb_';
22
23 $meta_boxes[] = array(
24 'id' => 'test_metabox',
25 'title' => 'Test Metabox',
26 'pages' => array( 'page', ), // Post type
27 'context' => 'normal',
28 'priority' => 'high',
29 'show_names' => true, // Show field names on the left
30 'fields' => array(
31 array(
32 'name' => 'Test Text',
33 'desc' => 'field description (optional)',
34 'id' => $prefix . 'test_text',
35 'type' => 'text',
36 ),
37 array(
38 'name' => 'Test Text Small',
39 'desc' => 'field description (optional)',
40 'id' => $prefix . 'test_textsmall',
41 'type' => 'text_small',
42 ),
43 array(
44 'name' => 'Test Text Medium',
45 'desc' => 'field description (optional)',
46 'id' => $prefix . 'test_textmedium',
47 'type' => 'text_medium',
48 ),
49 array(
50 'name' => 'Test Date Picker',
51 'desc' => 'field description (optional)',
52 'id' => $prefix . 'test_textdate',
53 'type' => 'text_date',
54 ),
55 array(
56 'name' => 'Test Date Picker (UNIX timestamp)',
57 'desc' => 'field description (optional)',
58 'id' => $prefix . 'test_textdate_timestamp',
59 'type' => 'text_date_timestamp',
60 ),
61 array(
62 'name' => 'Test Date/Time Picker Combo (UNIX timestamp)',
63 'desc' => 'field description (optional)',
64 'id' => $prefix . 'test_datetime_timestamp',
65 'type' => 'text_datetime_timestamp',
66 ),
67 array(
68 'name' => 'Test Time',
69 'desc' => 'field description (optional)',
70 'id' => $prefix . 'test_time',
71 'type' => 'text_time',
72 ),
73 array(
74 'name' => 'Test Money',
75 'desc' => 'field description (optional)',
76 'id' => $prefix . 'test_textmoney',
77 'type' => 'text_money',
78 // 'before' => '£', // override '$' symbol if needed
79 ),
80 array(
81 'name' => 'Test Color Picker',
82 'desc' => 'field description (optional)',
83 'id' => $prefix . 'test_colorpicker',
84 'type' => 'colorpicker',
85 'std' => '#ffffff'
86 ),
87 array(
88 'name' => 'Test Text Area',
89 'desc' => 'field description (optional)',
90 'id' => $prefix . 'test_textarea',
91 'type' => 'textarea',
92 ),
93 array(
94 'name' => 'Test Text Area Small',
95 'desc' => 'field description (optional)',
96 'id' => $prefix . 'test_textareasmall',
97 'type' => 'textarea_small',
98 ),
99 array(
100 'name' => 'Test Text Area Code',
101 'desc' => 'field description (optional)',
102 'id' => $prefix . 'test_textarea_code',
103 'type' => 'textarea_code',
104 ),
105 array(
106 'name' => 'Test Title Weeeee',
107 'desc' => 'This is a title description',
108 'id' => $prefix . 'test_title',
109 'type' => 'title',
110 ),
111 array(
112 'name' => 'Test Select',
113 'desc' => 'field description (optional)',
114 'id' => $prefix . 'test_select',
115 'type' => 'select',
116 'options' => array(
117 array( 'name' => 'Option One', 'value' => 'standard', ),
118 array( 'name' => 'Option Two', 'value' => 'custom', ),
119 array( 'name' => 'Option Three', 'value' => 'none', ),
120 ),
121 ),
122 array(
123 'name' => 'Test Radio inline',
124 'desc' => 'field description (optional)',
125 'id' => $prefix . 'test_radio_inline',
126 'type' => 'radio_inline',
127 'options' => array(
128 array( 'name' => 'Option One', 'value' => 'standard', ),
129 array( 'name' => 'Option Two', 'value' => 'custom', ),
130 array( 'name' => 'Option Three', 'value' => 'none', ),
131 ),
132 ),
133 array(
134 'name' => 'Test Radio',
135 'desc' => 'field description (optional)',
136 'id' => $prefix . 'test_radio',
137 'type' => 'radio',
138 'options' => array(
139 array( 'name' => 'Option One', 'value' => 'standard', ),
140 array( 'name' => 'Option Two', 'value' => 'custom', ),
141 array( 'name' => 'Option Three', 'value' => 'none', ),
142 ),
143 ),
144 array(
145 'name' => 'Test Taxonomy Radio',
146 'desc' => 'Description Goes Here',
147 'id' => $prefix . 'text_taxonomy_radio',
148 'type' => 'taxonomy_radio',
149 'taxonomy' => '', // Taxonomy Slug
150 ),
151 array(
152 'name' => 'Test Taxonomy Select',
153 'desc' => 'Description Goes Here',
154 'id' => $prefix . 'text_taxonomy_select',
155 'type' => 'taxonomy_select',
156 'taxonomy' => '', // Taxonomy Slug
157 ),
158 array(
159 'name' => 'Test Taxonomy Multi Checkbox',
160 'desc' => 'field description (optional)',
161 'id' => $prefix . 'test_multitaxonomy',
162 'type' => 'taxonomy_multicheck',
163 'taxonomy' => '', // Taxonomy Slug
164 ),
165 array(
166 'name' => 'Test Checkbox',
167 'desc' => 'field description (optional)',
168 'id' => $prefix . 'test_checkbox',
169 'type' => 'checkbox',
170 ),
171 array(
172 'name' => 'Test Multi Checkbox',
173 'desc' => 'field description (optional)',
174 'id' => $prefix . 'test_multicheckbox',
175 'type' => 'multicheck',
176 'options' => array(
177 'check1' => 'Check One',
178 'check2' => 'Check Two',
179 'check3' => 'Check Three',
180 ),
181 ),
182 array(
183 'name' => 'Test wysiwyg',
184 'desc' => 'field description (optional)',
185 'id' => $prefix . 'test_wysiwyg',
186 'type' => 'wysiwyg',
187 'options' => array( 'textarea_rows' => 5, ),
188 ),
189 array(
190 'name' => 'Test Image',
191 'desc' => 'Upload an image or enter an URL.',
192 'id' => $prefix . 'test_image',
193 'type' => 'file',
194 ),
195 array(
196 'name' => 'oEmbed',
197 'desc' => 'Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.',
198 'id' => $prefix . 'test_embed',
199 'type' => 'oembed',
200 ),
201 ),
202 );
203
204 $meta_boxes[] = array(
205 'id' => 'about_page_metabox',
206 'title' => 'About Page Metabox',
207 'pages' => array( 'page', ), // Post type
208 'context' => 'normal',
209 'priority' => 'high',
210 'show_names' => true, // Show field names on the left
211 'show_on' => array( 'key' => 'id', 'value' => array( 2, ), ), // Specific post IDs to display this metabox
212 'fields' => array(
213 array(
214 'name' => 'Test Text',
215 'desc' => 'field description (optional)',
216 'id' => $prefix . 'test_text',
217 'type' => 'text',
218 ),
219 )
220 );
221
222 // Add other metaboxes as needed
223
224 return $meta_boxes;
225 }
226
227 add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 );
228 /**
229 * Initialize the metabox class.
230 */
231 function cmb_initialize_cmb_meta_boxes() {
232
233 if ( ! class_exists( 'cmb_Meta_Box' ) )
234 require_once 'init.php';
235
236 }
237