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