PluginProbe
Advanced Custom Fields (ACF®) / 3.1.5
Advanced Custom Fields (ACF®) v3.1.5
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / core / fields / true_false.php
true_false.php
112 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_True_false extends acf_Field
4 {
5
6 /*--------------------------------------------------------------------------------------
7 *
8 * Constructor
9 *
10 * @author Elliot Condon
11 * @since 1.0.0
12 * @updated 2.2.0
13 *
14 *-------------------------------------------------------------------------------------*/
15
16 function __construct($parent)
17 {
18 parent::__construct($parent);
19
20 $this->name = 'true_false';
21 $this->title = __("True / False",'acf');
22
23 }
24
25
26 /*--------------------------------------------------------------------------------------
27 *
28 * create_field
29 *
30 * @author Elliot Condon
31 * @since 2.0.5
32 * @updated 2.2.0
33 *
34 *-------------------------------------------------------------------------------------*/
35
36 function create_field($field)
37 {
38 // vars
39 $field['message'] = isset($field['message']) ? $field['message'] : '';
40
41 // html
42 echo '<ul class="checkbox_list ' . $field['class'] . '">';
43 echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
44 $selected = ($field['value'] == 1) ? 'checked="yes"' : '';
45 echo '<li><label><input type="checkbox" name="'.$field['name'].'" value="1" ' . $selected . ' />' . $field['message'] . '</label></li>';
46
47 echo '</ul>';
48
49 }
50
51
52 /*--------------------------------------------------------------------------------------
53 *
54 * create_options
55 *
56 * @author Elliot Condon
57 * @since 2.0.6
58 * @updated 2.2.0
59 *
60 *-------------------------------------------------------------------------------------*/
61
62 function create_options($key, $field)
63 {
64 $field['message'] = isset($field['message']) ? $field['message'] : '';
65 ?>
66 <tr class="field_option field_option_<?php echo $this->name; ?>">
67 <td class="label">
68 <label><?php _e("Message",'acf'); ?></label>
69 <p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
70 </td>
71 <td>
72 <?php
73 $this->parent->create_field(array(
74 'type' => 'text',
75 'name' => 'fields['.$key.'][message]',
76 'value' => $field['message'],
77 ));
78 ?>
79 </td>
80 </tr>
81
82 <?php
83 }
84
85
86 /*--------------------------------------------------------------------------------------
87 *
88 * get_value_for_api
89 *
90 * @author Elliot Condon
91 * @since 3.0.0
92 *
93 *-------------------------------------------------------------------------------------*/
94
95 function get_value_for_api($post_id, $field)
96 {
97 // get value
98 $value = parent::get_value($post_id, $field);
99
100 if($value == '1')
101 {
102 return true;
103 }
104 else
105 {
106 return false;
107 }
108 }
109
110 }
111
112 ?>