PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / samples / widget-options.php

widget-options.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/samples/widget-options.php

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