PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.1.5
StreamCast – bring live radio to your site with a sleek player v2.1.5
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.1.5, at admin/codestar-framework/samples/widget-options.php

175 lines 4.1 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 // var_dump( $args ); // Widget arguments
61 // var_dump( $instance ); // Saved values from database
62 echo $instance['title'];
63 echo $instance['opt-text'];
64 echo $instance['opt-color'];
65 echo $instance['opt-upload'];
66 echo $instance['opt-textarea'];
67
68 echo $args['after_widget'];
69
70 }
71 }
72
73 //
74 // Create a widget 2
75 //
76 CSF::createWidget( 'csf_widget_example_2', array(
77 'title' => 'Codestar Widget Example 2',
78 'classname' => 'csf-widget-classname',
79 'description' => 'A description for widget example 2',
80 'fields' => array(
81
82 array(
83 'id' => 'title',
84 'type' => 'text',
85 'title' => 'Title',
86 ),
87
88 array(
89 'id' => 'opt-text',
90 'type' => 'text',
91 'title' => 'Text',
92 'default' => 'Default text value'
93 ),
94
95 array(
96 'id' => 'opt-color',
97 'type' => 'color',
98 'title' => 'Color',
99 ),
100
101 array(
102 'id' => 'opt-switcher',
103 'type' => 'switcher',
104 'title' => 'Switcher',
105 'label' => 'The label text of the switcher.',
106 ),
107
108 array(
109 'id' => 'opt-checkbox',
110 'type' => 'checkbox',
111 'title' => 'Checkbox',
112 'label' => 'The label text of the checkbox.',
113 ),
114
115 array(
116 'id' => 'opt-select',
117 'type' => 'select',
118 'title' => 'Select',
119 'placeholder' => 'Select an option',
120 'options' => array(
121 'opt-1' => 'Option 1',
122 'opt-2' => 'Option 2',
123 'opt-3' => 'Option 3',
124 ),
125 ),
126
127 array(
128 'id' => 'opt-radio',
129 'type' => 'radio',
130 'title' => 'Radio',
131 'options' => array(
132 'yes' => 'Yes, Please.',
133 'no' => 'No, Thank you.',
134 ),
135 'default' => 'yes',
136 ),
137 array(
138 'type' => 'notice',
139 'style' => 'success',
140 'content' => 'A <strong>notice</strong> field with <strong>success</strong> style.',
141 ),
142
143 array(
144 'id' => 'opt-textarea',
145 'type' => 'textarea',
146 'title' => 'Textarea',
147 'help' => 'The help text of the field.',
148 ),
149
150 )
151 ) );
152
153 //
154 // Front-end display of widget example 2
155 // Attention: This function named considering above widget base id.
156 //
157 if ( ! function_exists( 'csf_widget_example_2' ) ) {
158 function csf_widget_example_2( $args, $instance ) {
159
160 echo $args['before_widget'];
161
162 if ( ! empty( $instance['title'] ) ) {
163 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
164 }
165
166 // var_dump( $args ); // Widget arguments
167 // var_dump( $instance ); // Saved values from database
168 echo $instance['title'];
169 echo $instance['opt-text'];
170
171 echo $args['after_widget'];
172
173 }
174 }
175