PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / fields / field-checkbox.php
acf-extended / includes / fields Last commit date
field-advanced-link.php 3 months ago field-button-group.php 1 week ago field-button.php 7 months ago field-checkbox.php 3 months ago field-clone.php 2 years ago field-code-editor.php 3 months ago field-column.php 3 years ago field-dynamic-render.php 3 years ago field-file.php 3 months ago field-flexible-content-actions-title.php 3 months ago field-flexible-content-actions-toggle.php 3 months ago field-flexible-content-actions.php 3 months ago field-flexible-content-async.php 4 months ago field-flexible-content-compatibility.php 3 months ago field-flexible-content-controls.php 9 months ago field-flexible-content-hide.php 3 months ago field-flexible-content-hooks.php 9 months ago field-flexible-content-modal-edit.php 9 months ago field-flexible-content-modal-select.php 3 months ago field-flexible-content-modal-settings.php 3 months ago field-flexible-content-popup.php 3 months ago field-flexible-content-preview.php 3 months ago field-flexible-content-state.php 9 months ago field-flexible-content-thumbnail.php 9 months ago field-flexible-content-wysiwyg.php 9 months ago field-flexible-content.php 3 months ago field-forms.php 3 months ago field-gallery.php 3 months ago field-google-map.php 3 months ago field-group.php 3 months ago field-hidden.php 3 years ago field-image.php 3 months ago field-post-object.php 3 months ago field-post-statuses.php 3 months ago field-post-types.php 3 months ago field-radio.php 3 months ago field-recaptcha.php 3 months ago field-relationship.php 3 months ago field-repeater.php 3 months ago field-select.php 3 months ago field-slug.php 1 year ago field-taxonomies.php 3 months ago field-taxonomy-terms.php 3 months ago field-taxonomy.php 3 months ago field-textarea.php 3 months ago field-user-roles.php 3 months ago field-user.php 3 months ago field-wysiwyg.php 3 months ago
field-checkbox.php
95 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_field_checkbox')):
8
9 class acfe_field_checkbox extends acfe_field_extend{
10
11 /**
12 * initialize
13 */
14 function initialize(){
15
16 $this->name = 'checkbox';
17
18 }
19
20
21 /**
22 * format_front_value
23 *
24 * @param $formatted
25 * @param $unformatted
26 * @param $post_id
27 * @param $field
28 * @param $form
29 *
30 * @return string
31 */
32 function format_front_value($formatted, $unformatted, $post_id, $field, $form){
33
34 // vars
35 $value = acfe_as_array($unformatted);
36 $array = array();
37
38 // loop values
39 foreach($value as $v){
40 $array[] = acfe_get($field['choices'], $v, $v);
41 }
42
43 // merge
44 return implode(', ', $array);
45
46 }
47
48
49 /**
50 * validate_front_value
51 *
52 * @param $valid
53 * @param $value
54 * @param $field
55 * @param $input
56 * @param $form
57 *
58 * @return false
59 */
60 function validate_front_value($valid, $value, $field, $input, $form){
61
62 // bail early
63 if(!$this->pre_validate_front_value($valid, $value, $field, $form)){
64 return $valid;
65 }
66
67 // custom value allowed
68 if(!empty($field['allow_custom'])){
69 return $valid;
70 }
71
72 // vars
73 $value = acfe_as_array($value);
74 $choices = acfe_as_array($field['choices']);
75
76 // empty choices
77 if(empty($choices)){
78 return false; // value is always invalid as there no choice is allowed
79 }
80
81 // check values against choices
82 if(!empty(array_diff($value, array_keys($choices)))){
83 return false;
84 }
85
86 // return
87 return $valid;
88
89 }
90
91 }
92
93 acf_new_instance('acfe_field_checkbox');
94
95 endif;