PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / admin / ph-meta-box-functions.php

ph-meta-box-functions.php in Property Hive 2.2.6, at includes/admin/ph-meta-box-functions.php

568 lines 22.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive Meta Box Functions
4 *
5 * @author PropertyHive
6 * @category Core
7 * @package PropertyHive/Admin/Functions
8 * @version 1.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
13 /**
14 * Output a text input box.
15 *
16 * @access public
17 * @param array $field
18 * @return void
19 */
20 function propertyhive_wp_text_input( $field ) {
21 global $thepostid, $post, $propertyhive;
22
23 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
24
25 $field = apply_filters( 'propertyhive_meta_box_wp_text_field', $field, $thepostid );
26
27 $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
28 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
29 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
30 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
31 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
32 $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text';
33 $data_type = empty( $field['data_type'] ) ? '' : $field['data_type'];
34
35 switch ( $data_type ) {
36 case 'price' :
37 $field['class'] .= ' ph_input_price';
38 $field['value'] = ph_format_localized_price( $field['value'] );
39 break;
40 case 'decimal' :
41 $field['class'] .= ' ph_input_decimal';
42 $field['value'] = ph_format_localized_decimal( $field['value'] );
43 break;
44 }
45
46 // Custom attribute handling
47 $custom_attributes = array();
48
49 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
50 foreach ( $field['custom_attributes'] as $attribute => $value )
51 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
52
53 echo '
54 <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '">
55 <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label>
56 <input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . implode( ' ', $custom_attributes ) . ' /> ';
57
58 if ( ! empty( $field['description'] ) ) {
59
60 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
61 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
62 } else {
63 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
64 }
65
66 }
67 echo '</p>';
68 }
69
70 /**
71 * Output a photo input box.
72 *
73 * @access public
74 * @param array $field
75 * @return void
76 */
77 function propertyhive_wp_photo_upload( $field ) {
78 global $thepostid, $post, $propertyhive;
79
80 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
81
82 $field = apply_filters( 'propertyhive_meta_box_wp_photo_upload_field', $field, $thepostid );
83
84 $field['id'] = isset( $field['id'] ) ? $field['id'] : '';
85 $field['button_label'] = isset( $field['button_label'] ) ? $field['button_label'] : __('Select Photo', 'propertyhive');
86 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
87 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
88 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
89 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
90 $data_type = empty( $field['data_type'] ) ? '' : $field['data_type'];
91
92 // Custom attribute handling
93 $custom_attributes = array();
94
95 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
96 foreach ( $field['custom_attributes'] as $attribute => $value )
97 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
98
99 propertyhive_wp_hidden_input( $field );
100
101 echo '
102 <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"';
103 if ( $field['value'] == '' )
104 {
105 echo ' style="display:none;"';
106 }
107 echo '>
108 <label for="' . esc_attr( $field['id'] ) . '">' . esc_html(__( 'Uploaded', 'propertyhive' )) . ' ' . wp_kses_post( $field['label'] ) . '</label>
109 <span>';
110 if ( $field['value'] != '' )
111 {
112 $image = wp_get_attachment_image_src( $field['value'], 'thumbnail' );
113 if ($image !== FALSE)
114 {
115 echo '<img src="' . esc_url($image[0]) . '" width="150" alt="">';
116 }
117 else
118 {
119 echo 'Image doesn\'t exist';
120 }
121 }
122 echo '</span>
123 </p>';
124
125 echo '
126 <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '">
127 <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label>
128 <a href="" class="button button-primary ph_upload_photo_button' . esc_attr($field['id']) . '">' . esc_html($field['button_label']) . '</a>';
129
130 if ( ! empty( $field['description'] ) ) {
131
132 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
133 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
134 } else {
135 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
136 }
137
138 }
139 echo '</p>';
140
141 echo '<script>
142
143 var file_frame' . esc_js($field['id']) . ';
144
145 jQuery(document).ready(function()
146 {
147 jQuery(\'body\').on(\'click\', \'.ph_upload_photo_button' . esc_js($field['id']) . '\', function( event ){
148
149 event.preventDefault();
150
151 // If the media frame already exists, reopen it.
152 if ( file_frame' . esc_js($field['id']) . ' ) {
153 file_frame' . esc_js($field['id']) . '.open();
154 return;
155 }
156
157 // Create the media frame.
158 file_frame' . esc_js($field['id']) . ' = wp.media.frames.file_frame' . esc_js($field['id']) . ' = wp.media({
159 title: jQuery( this ).data( \'uploader_title\' ),
160 button: {
161 text: jQuery( this ).data( \'uploader_button_text\' ),
162 },
163 multiple: false // Set to true to allow multiple files to be selected
164 });
165
166 // When an image is selected, run a callback.
167 file_frame' . esc_js($field['id']) . '.on( \'select\', function() {
168 var selection = file_frame' . esc_js($field['id']) . '.state().get(\'selection\');
169
170 selection.map( function( attachment ) {
171
172 attachment = attachment.toJSON();
173
174 // Do something with attachment.id and/or attachment.url here
175 console.log(attachment);
176
177 jQuery(\'.form-field.' . esc_js( $field['id'] ) . '_field\').show();
178 jQuery(\'.form-field.' . esc_js( $field['id'] ) . '_field span\').html(\'<img src="\' + attachment.url + \'" width="150" alt="">\');
179 jQuery(\'#' . esc_js( $field['id'] ) . '\').val(attachment.id);
180 });
181 });
182
183 // Finally, open the modal
184 file_frame' . esc_js($field['id']) . '.open();
185 });
186 });
187
188 </script>';
189 }
190
191 /**
192 * Output a file input box.
193 *
194 * @access public
195 * @param array $field
196 * @return void
197 */
198 function propertyhive_wp_file_upload( $field ) {
199 global $thepostid, $post, $propertyhive;
200
201 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
202
203 $field = apply_filters( 'propertyhive_meta_box_wp_file_upload_field', $field, $thepostid );
204
205 $field['id'] = isset( $field['id'] ) ? $field['id'] : '';
206 $field['button_label'] = isset( $field['button_label'] ) ? $field['button_label'] : __('Select Photo', 'propertyhive');
207 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
208 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
209 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
210 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
211 $data_type = empty( $field['data_type'] ) ? '' : $field['data_type'];
212
213 // Custom attribute handling
214 $custom_attributes = array();
215
216 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
217 foreach ( $field['custom_attributes'] as $attribute => $value )
218 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
219
220 propertyhive_wp_hidden_input( $field );
221
222 echo '
223 <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"';
224 if ( $field['value'] == '' )
225 {
226 echo ' style="display:none;"';
227 }
228 echo '>
229 <label for="' . esc_attr( $field['id'] ) . '">' . esc_html(__( 'Uploaded', 'propertyhive' )) . ' ' . wp_kses_post( $field['label'] ) . '</label>
230 <span>';
231 if ( $field['value'] != '' )
232 {
233 $file = get_attached_file( $field['value'] );
234 if ( $file !== FALSE )
235 {
236 $filename = basename( $file );
237 echo '<a href="' . esc_url(wp_get_attachment_url($field['value'])) . '" target="_blank">' . esc_html($filename) . '</a>';
238 }
239 else
240 {
241 echo 'Image doesn\'t exist';
242 }
243 }
244 echo '</span>
245 </p>';
246
247 echo '
248 <p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '">
249 <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label>
250 <a href="" class="button button-primary ph_upload_file_button' . esc_attr($field['id']) . '">' . esc_html($field['button_label']) . '</a>';
251
252 if ( ! empty( $field['description'] ) ) {
253
254 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
255 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
256 } else {
257 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
258 }
259
260 }
261 echo '</p>';
262
263 echo '<script>
264
265 var file_frame' . esc_js($field['id']) . ';
266
267 jQuery(document).ready(function()
268 {
269 jQuery(\'body\').on(\'click\', \'.ph_upload_file_button' . esc_js($field['id']) . '\', function( event ){
270
271 event.preventDefault();
272
273 // If the media frame already exists, reopen it.
274 if ( file_frame' . esc_js($field['id']) . ' ) {
275 file_frame' . esc_js($field['id']) . '.open();
276 return;
277 }
278
279 // Create the media frame.
280 file_frame' . esc_js($field['id']) . ' = wp.media.frames.file_frame' . esc_js($field['id']) . ' = wp.media({
281 title: jQuery( this ).data( \'uploader_title\' ),
282 button: {
283 text: jQuery( this ).data( \'uploader_button_text\' ),
284 },
285 multiple: false // Set to true to allow multiple files to be selected
286 });
287
288 // When an image is selected, run a callback.
289 file_frame' . esc_js($field['id']) . '.on( \'select\', function() {
290 var selection = file_frame' . esc_js($field['id']) . '.state().get(\'selection\');
291
292 selection.map( function( attachment ) {
293
294 attachment = attachment.toJSON();
295
296 // Do something with attachment.id and/or attachment.url here
297 console.log(attachment);
298
299 jQuery(\'.form-field.' . esc_js($field['id']) . '_field\').show();
300 jQuery(\'.form-field.' . esc_js($field['id']) . '_field span\').html(\'<a href="\' + attachment.url + \'" target="_blank">\' + attachment.filename + \'</a>\');
301 jQuery(\'#' . esc_js($field['id']) . '\').val(attachment.id);
302 });
303 });
304
305 // Finally, open the modal
306 file_frame' . esc_js($field['id']) . '.open();
307 });
308 });
309
310 </script>';
311 }
312
313 /**
314 * Output a hidden input box.
315 *
316 * @access public
317 * @param array $field
318 * @return void
319 */
320 function propertyhive_wp_hidden_input( $field ) {
321 global $thepostid, $post;
322
323 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
324
325 $field = apply_filters( 'propertyhive_meta_box_wp_hidden_field', $field, $thepostid );
326
327 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
328
329 echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" /> ';
330 }
331
332 /**
333 * Output a textarea input box.
334 *
335 * @access public
336 * @param array $field
337 * @return void
338 */
339 function propertyhive_wp_textarea_input( $field ) {
340 global $thepostid, $post, $propertyhive;
341
342 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
343
344 $field = apply_filters( 'propertyhive_meta_box_wp_textarea_field', $field, $thepostid );
345
346 $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
347 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
348 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
349 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
350 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
351
352 // Custom attribute handling
353 $custom_attributes = array();
354
355 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
356 foreach ( $field['custom_attributes'] as $attribute => $value )
357 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
358
359 echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20" ' . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $field['value'] ) . '</textarea> ';
360
361 if ( ! empty( $field['description'] ) ) {
362
363 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
364 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
365 } else {
366 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
367 }
368
369 }
370 echo '</p>';
371 }
372
373 /**
374 * Output a checkbox input box.
375 *
376 * @access public
377 * @param array $field
378 * @return void
379 */
380 function propertyhive_wp_checkbox( $field ) {
381 global $thepostid, $post;
382
383 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
384
385 $field = apply_filters( 'propertyhive_meta_box_wp_checkbox_field', $field, $thepostid );
386
387 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox';
388 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
389 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
390 $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes';
391 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
392
393 echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><input type="checkbox" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['cbvalue'] ) . '" ' . checked( $field['value'], $field['cbvalue'], false ) . ' /> ';
394
395 if ( ! empty( $field['description'] ) ) echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
396
397 echo '</p>';
398 }
399
400 /**
401 * Output a groupd of checkbox input boxes.
402 *
403 * @access public
404 * @param array $field
405 * @return void
406 */
407 function propertyhive_wp_checkboxes( $field ) {
408 global $thepostid, $post;
409
410 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
411
412 $field = apply_filters( 'propertyhive_meta_box_wp_checkboxes_field', $field, $thepostid );
413
414 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox';
415 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
416 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
417 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['name'], true );
418
419 echo '<fieldset class="form-field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul class="ph-radios">';
420
421 foreach ( $field['options'] as $key => $value ) {
422 echo '<li><label><input type="checkbox" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '[]" id="' . esc_attr( $field['name'] . '_' . $key ) . '" value="' . esc_attr( $key ) . '" ' . ( ( !empty($field['value']) && in_array( $key, $field['value'] ) ) ? 'checked' : '' ) . ' /> ' . esc_html($value) . '</label></li>';
423 }
424
425 echo '</ul>';
426
427 if ( ! empty( $field['description'] ) ) echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
428
429 echo '</fieldset>';
430 }
431
432 /**
433 * Output a select input box.
434 *
435 * @access public
436 * @param array $field
437 * @return void
438 */
439 function propertyhive_wp_select( $field ) {
440 global $thepostid, $post, $propertyhive;
441
442 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
443
444 $field = apply_filters( 'propertyhive_meta_box_wp_select_field', $field, $thepostid );
445
446 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
447 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
448 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
449 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
450
451 echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['name'] ) . '" class="' . esc_attr( $field['class'] ) . '">';
452
453 foreach ( $field['options'] as $key => $value ) {
454
455 echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
456
457 }
458
459 echo '</select> ';
460
461 if ( ! empty( $field['description'] ) ) {
462
463 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
464 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
465 } else {
466 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
467 }
468
469 }
470 echo '</p>';
471 }
472
473 /**
474 * Output a select input box with optgroups.
475 *
476 * @access public
477 * @param array $field
478 * @return void
479 */
480 function propertyhive_wp_select_optgroups( $field ) {
481 global $thepostid, $post, $propertyhive;
482
483 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
484
485 $field = apply_filters( 'propertyhive_meta_box_wp_select_optgroups_field', $field, $thepostid );
486
487 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
488 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
489 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
490
491 echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['class'] ) . '">';
492
493 echo '<option value="" ' . selected( esc_attr( $field['value'] ), esc_attr( '' ), false ) . '></option>';
494
495 foreach ( $field['options'] as $optgroup => $options ) {
496
497 echo '<optgroup label="' . esc_html( $optgroup ) . '">';
498
499 foreach ( $options as $key => $value ) {
500
501 echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
502
503 }
504
505 echo '</optgroup>';
506
507 }
508
509 echo '</select> ';
510
511 if ( ! empty( $field['description'] ) ) {
512
513 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
514 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
515 } else {
516 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
517 }
518
519 }
520 echo '</p>';
521 }
522
523 /**
524 * Output a radio input box.
525 *
526 * @access public
527 * @param array $field
528 * @return void
529 */
530 function propertyhive_wp_radio( $field ) {
531 global $thepostid, $post, $propertyhive;
532
533 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
534
535 $field = apply_filters( 'propertyhive_meta_box_wp_radio_field', $field, $thepostid );
536
537 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
538 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
539 $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
540 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
541
542 echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul class="ph-radios">';
543
544 foreach ( $field['options'] as $key => $value ) {
545
546 echo '<li><label><input
547 name="' . esc_attr( $field['name'] ) . '"
548 value="' . esc_attr( $key ) . '"
549 type="radio"
550 class="' . esc_attr( $field['class'] ) . '"
551 ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '
552 /> ' . esc_html( $value ) . '</label>
553 </li>';
554 }
555 echo '</ul>';
556
557 if ( ! empty( $field['description'] ) ) {
558
559 if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
560 echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( PH()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
561 } else {
562 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
563 }
564
565 }
566
567 echo '</fieldset>';
568 }