PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.2.3
StreamCast – bring live radio to your site with a sleek player v2.2.3
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / admin / codestar-framework / samples / widget-options.php

widget-options.php in StreamCast – bring live radio to your site with a sleek player 2.2.3, at admin/codestar-framework/samples/widget-options.php

183 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2
3 //
4 // Create a widget 1
5 //
6 CSF::createWidget( 'csf_widget_example_1', array(
7 'title' => 'Codestar Widget Example 1',
8 'classname' => 'csf-widget-classname',
9 'description' => 'A description for widget example 1',
10 'fields' => array(
11
12 array(
13 'id' => 'title',
14 'type' => 'text',
15 'title' => 'Title',
16 ),
17
18 array(
19 'id' => 'opt-text',
20 'type' => 'text',
21 'title' => 'Text',
22 'default' => 'Default text value'
23 ),
24
25 array(
26 'id' => 'opt-color',
27 'type' => 'color',
28 'title' => 'Color',
29 ),
30
31 array(
32 'id' => 'opt-upload',
33 'type' => 'upload',
34 'title' => 'Upload',
35 ),
36
37 array(
38 'id' => 'opt-textarea',
39 'type' => 'textarea',
40 'title' => 'Textarea',
41 'help' => 'The help text of the field.',
42 ),
43
44 )
45 ) );
46
47 //
48 // Front-end display of widget example 1
49 // Attention: This function named considering above widget base id.
50 //
51 if ( ! function_exists( 'csf_widget_example_1' ) ) {
52 function csf_widget_example_1( $args, $instance ) {
53
54 echo $args['before_widget'];
55
56 // if ( ! empty( $instance['title'] ) ) {
57 // echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
58 // }
59
60 echo '<div style="padding: 20px; background-color: #f7f7f7;">';
61 echo '<h3>Codestar Widget Example 1</h3>';
62 echo '<p><strong>Title:</strong> '. $instance['title'] .'</p>';
63 echo '<p><strong>Text:</strong> '. $instance['opt-text'] .'</p>';
64 echo '<p><strong>Color:</strong> '. $instance['opt-color'] .'</p>';
65 echo '<p><strong>Upload:</strong> '. $instance['opt-upload'] .'</p>';
66 echo '<p><strong>Textarea:</strong> '. $instance['opt-textarea'] .'</p>';
67 echo '</div>';
68
69 echo $args['after_widget'];
70
71 }
72 }
73
74 //
75 // Create a widget 2
76 //
77 CSF::createWidget( 'csf_widget_example_2', array(
78 'title' => 'Codestar Widget Example 2',
79 'classname' => 'csf-widget-classname',
80 'description' => 'A description for widget example 2',
81 'fields' => array(
82
83 array(
84 'id' => 'title',
85 'type' => 'text',
86 'title' => 'Title',
87 ),
88
89 array(
90 'id' => 'opt-text',
91 'type' => 'text',
92 'title' => 'Text',
93 'default' => 'Default text value'
94 ),
95
96 array(
97 'id' => 'opt-color',
98 'type' => 'color',
99 'title' => 'Color',
100 ),
101
102 array(
103 'id' => 'opt-switcher',
104 'type' => 'switcher',
105 'title' => 'Switcher',
106 'label' => 'The label text of the switcher.',
107 ),
108
109 array(
110 'id' => 'opt-checkbox',
111 'type' => 'checkbox',
112 'title' => 'Checkbox',
113 'label' => 'The label text of the checkbox.',
114 ),
115
116 array(
117 'id' => 'opt-select',
118 'type' => 'select',
119 'title' => 'Select',
120 'placeholder' => 'Select an option',
121 'options' => array(
122 'opt-1' => 'Option 1',
123 'opt-2' => 'Option 2',
124 'opt-3' => 'Option 3',
125 ),
126 ),
127
128 array(
129 'id' => 'opt-radio',
130 'type' => 'radio',
131 'title' => 'Radio',
132 'options' => array(
133 'yes' => 'Yes, Please.',
134 'no' => 'No, Thank you.',
135 ),
136 'default' => 'yes',
137 ),
138 array(
139 'type' => 'notice',
140 'style' => 'success',
141 'content' => 'A <strong>notice</strong> field with <strong>success</strong> style.',
142 ),
143
144 array(
145 'id' => 'opt-textarea',
146 'type' => 'textarea',
147 'title' => 'Textarea',
148 'help' => 'The help text of the field.',
149 ),
150
151 )
152 ) );
153
154 //
155 // Front-end display of widget example 2
156 // Attention: This function named considering above widget base id.
157 //
158 if ( ! function_exists( 'csf_widget_example_2' ) ) {
159 function csf_widget_example_2( $args, $instance ) {
160
161 echo $args['before_widget'];
162
163 // if ( ! empty( $instance['title'] ) ) {
164 // echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
165 // }
166
167 echo '<div style="padding: 20px; background-color: #f7f7f7;">';
168 echo '<h3>Codestar Widget Example 2</h3>';
169 echo '<p><strong>Title:</strong> '. $instance['title'] .'</p>';
170 echo '<p><strong>Text:</strong> '. $instance['opt-text'] .'</p>';
171 echo '<p><strong>Color:</strong> '. $instance['opt-color'] .'</p>';
172 echo '<p><strong>Switcher:</strong> '. $instance['opt-switcher'] .'</p>';
173 echo '<p><strong>Checkbox:</strong> '. $instance['opt-checkbox'] .'</p>';
174 echo '<p><strong>Select:</strong> '. $instance['opt-select'] .'</p>';
175 echo '<p><strong>Radio:</strong> '. $instance['opt-radio'] .'</p>';
176 echo '<p><strong>Textarea:</strong> '. $instance['opt-textarea'] .'</p>';
177 echo '</div>';
178
179 echo $args['after_widget'];
180
181 }
182 }
183