PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.10
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.10
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-callback.php

class-callback.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.10, at includes/class-callback.php

300 lines 10.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Setting fields callback functions
4 *
5 * This class defines all code necessary to display setting field input.
6 *
7 * @link http://wpgeodirectory.com
8 * @since 1.0.0
9 *
10 * @package userswp
11 */
12 class UsersWP_Callback {
13
14 public function uwp_missing_callback($args) {
15 printf(
16 __( 'The callback function used for the %s setting is missing.', 'userswp' ),
17 '<strong>' . $args['id'] . '</strong>'
18 );
19 }
20
21 public function uwp_select_callback($args) {
22
23 global $uwp_options;
24
25 $global = isset( $args['global'] ) ? $args['global'] : true;
26 if ($global) {
27 if ( isset( $uwp_options[ $args['id'] ] ) ) {
28 $value = $uwp_options[ $args['id'] ];
29 } else {
30 $value = isset( $args['std'] ) ? $args['std'] : '';
31 }
32 } else {
33 if ( isset( $args['value'] ) ) {
34 $value = $args['value'];
35 } else {
36 $value = isset( $args['std'] ) ? $args['std'] : '';
37 }
38 }
39
40
41 if ( isset( $args['placeholder'] ) ) {
42 $placeholder = $args['placeholder'];
43 } else {
44 $placeholder = '';
45 }
46
47 if ( isset( $args['chosen'] ) ) {
48 $chosen = ($args['multiple'] ? '[]" multiple="multiple" class="uwp_chosen_select" style="height:auto"' : "'");
49 } else {
50 $chosen = '';
51 }
52
53 $html = '<select id="uwp_settings[' . $args['id'] . ']" name="uwp_settings[' . $args['id'] . ']' . $chosen . ' data-placeholder="' . $placeholder . '" />';
54
55 foreach ( $args['options'] as $option => $name ) {
56 if (is_array($value)) {
57 if (in_array($option, $value)) {
58 $selected = 'selected="selected"';
59 } else {
60 $selected = '';
61 }
62 } else {
63 $selected = selected( $option, $value, false );
64 }
65 $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
66 }
67
68 $html .= '</select>';
69 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
70
71 echo $html;
72 }
73
74 public function uwp_select_order_callback($args) {
75
76 global $uwp_options;
77
78 $global = isset( $args['global'] ) ? $args['global'] : true;
79 if ($global) {
80 if ( isset( $uwp_options[ $args['id'] ] ) ) {
81 $value = $uwp_options[ $args['id'] ];
82 } else {
83 $value = isset( $args['std'] ) ? $args['std'] : '';
84 }
85 } else {
86 if ( isset( $args['value'] ) ) {
87 $value = $args['value'];
88 } else {
89 $value = isset( $args['std'] ) ? $args['std'] : '';
90 }
91 }
92
93
94 if ( isset( $args['placeholder'] ) ) {
95 $placeholder = $args['placeholder'];
96 } else {
97 $placeholder = '';
98 }
99
100 if ( isset( $args['chosen'] ) ) {
101 $chosen = ($args['multiple'] ? '[]" multiple="multiple" class="uwp_chosen_select" style="height:auto"' : "'");
102 } else {
103 $chosen = '';
104 }
105
106 //print_r($args);
107
108 $html = '<select id="uwp_dummy_' . $args['id'] . '" name="uwp_dummy_settings[' . $args['id'] . ']' . $chosen . ' data-placeholder="' . $placeholder . '" />';
109
110 foreach ( $args['options'] as $option => $name ) {
111 if (is_array($value)) {
112 if (in_array($option, $value)) {
113 $selected = 'selected="selected"';
114 } else {
115 $selected = '';
116 }
117 } else {
118 $selected = selected( $option, $value, false );
119 }
120 $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
121 }
122
123 $html .= '</select>';
124 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
125
126 // The hidden select with correct orders
127 $html .= '<select style="visibility: hidden;
128 height: 0px;
129 padding: 0;
130 margin: 0;
131 float: left;" id="' . $args['id'] . '" name="uwp_settings[' . $args['id'] . '][]" multiple="multiple" data-placeholder="' . $placeholder . '" />';
132
133 if (is_array($value)) {
134 foreach ( $value as $option ) {
135 if ( in_array( $option,array_keys($args['options']) ) ) {
136 $selected = 'selected="selected"';
137 $html .= '<option value="' . $option . '" ' . $selected . '>' . $args['options'][$option] . '</option>';
138 }
139 }
140 }
141
142 $html .= '</select>';
143
144 echo $html;
145
146
147 ?>
148 <script>
149 jQuery(document).ready(function() {
150 setTimeout(function(){
151
152 // Set the current order on load
153 var current_order = jQuery('#<?php echo $args['id'];?>').val();
154
155 if(current_order){
156 current_order = jQuery.unique( current_order );
157 ChosenOrder.setSelectionOrder(jQuery("#uwp_dummy_<?php echo $args['id'];?>"), current_order);
158 }
159
160
161 // on order change update the hidden real values
162 jQuery("#uwp_dummy_<?php echo $args['id'];?>").chosen().change(function () {
163 console.log('changed');
164
165 setTimeout(function(){ // trigers before the item is removed so we add a slight delay
166 var selection = ChosenOrder.getSelectionOrder(jQuery("#uwp_dummy_<?php echo $args['id'];?>"));
167 console.log(selection);
168 jQuery('#<?php echo $args['id'];?>').find('option').remove().end();
169
170 jQuery.each( selection, function( key, value ) {
171 jQuery('#<?php echo $args['id'];?>').append('<option value="'+value+'" selected>'+value+'</option>')
172 });
173
174 }, 50);
175
176 });
177
178 }, 100);
179 });
180 </script>
181
182 <?php
183 }
184
185 public function uwp_text_callback( $args ) {
186 global $uwp_options;
187
188 $global = isset( $args['global'] ) ? $args['global'] : true;
189 if ($global) {
190 if ( isset( $uwp_options[ $args['id'] ] ) ) {
191 $value = $uwp_options[ $args['id'] ];
192 } else {
193 $value = isset( $args['std'] ) ? $args['std'] : '';
194 }
195 } else {
196 if ( isset( $args['value'] ) ) {
197 $value = $args['value'];
198 } else {
199 $value = isset( $args['std'] ) ? $args['std'] : '';
200 }
201 }
202
203 if ( isset( $args['faux'] ) && true === $args['faux'] ) {
204 $args['readonly'] = true;
205 $value = isset( $args['std'] ) ? $args['std'] : '';
206 $name = '';
207 } else {
208 $name = 'name="uwp_settings[' . $args['id'] . ']"';
209 }
210
211 $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
212 $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
213 $html = '<input type="text" class="' . $size . '-text" id="uwp_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
214 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
215
216 echo $html;
217 }
218
219 public function uwp_textarea_callback( $args ) {
220 global $uwp_options;
221
222 $global = isset( $args['global'] ) ? $args['global'] : true;
223 if ($global) {
224 if ( isset( $uwp_options[ $args['id'] ] ) ) {
225 $value = $uwp_options[ $args['id'] ];
226 } else {
227 $value = isset( $args['std'] ) ? $args['std'] : '';
228 }
229 } else {
230 if ( isset( $args['value'] ) ) {
231 $value = $args['value'];
232 } else {
233 $value = isset( $args['std'] ) ? $args['std'] : '';
234 }
235 }
236
237 $html = '<textarea class="large-text" cols="50" rows="5" id="uwp_settings[' . $args['id'] . ']" name="uwp_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
238 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
239
240 echo $html;
241 }
242
243 public function uwp_checkbox_callback( $args ) {
244 global $uwp_options;
245
246 if ( isset( $args['faux'] ) && true === $args['faux'] ) {
247 $name = '';
248 } else {
249 $name = 'name="uwp_settings[' . $args['id'] . ']"';
250 }
251
252 $checked = isset( $uwp_options[ $args['id'] ] ) ? checked( 1, $uwp_options[ $args['id'] ], false ) : '';
253 $html = '<input type="checkbox" id="uwp_settings[' . $args['id'] . ']"' . $name . ' value="1" ' . $checked . '/>';
254 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
255
256 echo $html;
257 }
258
259 public function uwp_number_callback( $args ) {
260 global $uwp_options;
261
262 $global = isset( $args['global'] ) ? $args['global'] : true;
263 if ($global) {
264 if ( isset( $uwp_options[ $args['id'] ] ) ) {
265 $value = $uwp_options[ $args['id'] ];
266 } else {
267 $value = isset( $args['std'] ) ? $args['std'] : '';
268 }
269 } else {
270 if ( isset( $args['value'] ) ) {
271 $value = $args['value'];
272 } else {
273 $value = isset( $args['std'] ) ? $args['std'] : '';
274 }
275 }
276
277 if ( isset( $args['faux'] ) && true === $args['faux'] ) {
278 $args['readonly'] = true;
279 $value = isset( $args['std'] ) ? $args['std'] : '';
280 $name = '';
281 } else {
282 $name = 'name="uwp_settings[' . $args['id'] . ']"';
283 }
284
285 $max = isset( $args['max'] ) ? $args['max'] : 999999;
286 $min = isset( $args['min'] ) ? $args['min'] : 0;
287 $step = isset( $args['step'] ) ? $args['step'] : 1;
288
289 $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
290 $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="uwp_settings[' . $args['id'] . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
291 $html .= '<label for="uwp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
292
293 echo $html;
294 }
295
296 public function uwp_info_callback( $args ) {
297 echo $args['desc'];
298 }
299
300 }