0
|
1 |
<?php |
|
2 |
/** |
11
|
3 |
* Initialize the custom Meta Boxes. |
|
4 |
* |
|
5 |
* @package OptionTree |
0
|
6 |
*/ |
11
|
7 |
|
5
|
8 |
add_action( 'admin_init', 'custom_meta_boxes' ); |
0
|
9 |
|
|
10 |
/** |
|
11 |
* Meta Boxes demo code. |
|
12 |
* |
5
|
13 |
* You can find all the available option types in demo-theme-options.php. |
0
|
14 |
* |
11
|
15 |
* @since 2.0 |
0
|
16 |
*/ |
5
|
17 |
function custom_meta_boxes() { |
0
|
18 |
|
11
|
19 |
/** |
|
20 |
* Create a custom meta boxes array that we pass to |
|
21 |
* the OptionTree Meta Box API Class. |
|
22 |
*/ |
|
23 |
$my_meta_box = array( |
|
24 |
'id' => 'demo_meta_box', |
|
25 |
'title' => __( 'Demo Meta Box', 'theme-text-domain' ), |
|
26 |
'desc' => '', |
|
27 |
'pages' => array( 'post' ), |
|
28 |
'context' => 'normal', |
|
29 |
'priority' => 'high', |
|
30 |
'fields' => array( |
|
31 |
array( |
|
32 |
'label' => __( 'Conditions', 'theme-text-domain' ), |
|
33 |
'id' => 'demo_conditions', |
|
34 |
'type' => 'tab', |
|
35 |
), |
|
36 |
array( |
|
37 |
'label' => __( 'Show Gallery', 'theme-text-domain' ), |
|
38 |
'id' => 'demo_show_gallery', |
|
39 |
'type' => 'on-off', |
|
40 |
'desc' => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), '<code>on</code>' ), |
|
41 |
'std' => 'off', |
|
42 |
), |
|
43 |
array( |
|
44 |
'label' => '', |
|
45 |
'id' => 'demo_textblock', |
|
46 |
'type' => 'textblock', |
|
47 |
'desc' => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ), |
|
48 |
'operator' => 'and', |
|
49 |
'condition' => 'demo_show_gallery:is(on),demo_gallery:not()', |
|
50 |
), |
|
51 |
array( |
|
52 |
'label' => __( 'Gallery', 'theme-text-domain' ), |
|
53 |
'id' => 'demo_gallery', |
|
54 |
'type' => 'gallery', |
|
55 |
'desc' => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), '<code>demo_show_gallery:is(on)</code>' ), |
|
56 |
'condition' => 'demo_show_gallery:is(on)', |
|
57 |
), |
|
58 |
array( |
|
59 |
'label' => __( 'More Options', 'theme-text-domain' ), |
|
60 |
'id' => 'demo_more_options', |
|
61 |
'type' => 'tab', |
|
62 |
), |
|
63 |
array( |
|
64 |
'label' => __( 'Text', 'theme-text-domain' ), |
|
65 |
'id' => 'demo_text', |
|
66 |
'type' => 'text', |
|
67 |
'desc' => __( 'This is a demo Text field.', 'theme-text-domain' ), |
|
68 |
), |
|
69 |
array( |
|
70 |
'label' => __( 'Textarea', 'theme-text-domain' ), |
|
71 |
'id' => 'demo_textarea', |
|
72 |
'type' => 'textarea', |
|
73 |
'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' ), |
|
74 |
), |
|
75 |
), |
|
76 |
); |
|
77 |
|
|
78 |
/** |
|
79 |
* Register our meta boxes using the |
|
80 |
* ot_register_meta_box() function. |
|
81 |
*/ |
|
82 |
if ( function_exists( 'ot_register_meta_box' ) ) { |
|
83 |
ot_register_meta_box( $my_meta_box ); |
|
84 |
} |
|
85 |
} |