PluginProbe
Advanced Custom Fields (ACF®) / 4.4.12
Advanced Custom Fields (ACF®) v4.4.12
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 / password.php
password.php
155 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_field_password extends acf_field
4 {
5
6 /*
7 * __construct
8 *
9 * Set name / label needed for actions / filters
10 *
11 * @since 3.6
12 * @date 23/01/13
13 */
14
15 function __construct()
16 {
17 // vars
18 $this->name = 'password';
19 $this->label = __("Password",'acf');
20 $this->defaults = array(
21 'placeholder' => '',
22 'prepend' => '',
23 'append' => ''
24 );
25
26
27 // do not delete!
28 parent::__construct();
29 }
30
31
32 /*
33 * create_field()
34 *
35 * Create the HTML interface for your field
36 *
37 * @param $field - an array holding all the field's data
38 *
39 * @type action
40 * @since 3.6
41 * @date 23/01/13
42 */
43
44 function create_field( $field )
45 {
46 // vars
47 $o = array( 'id', 'class', 'name', 'value', 'placeholder' );
48 $e = '';
49
50
51 // prepend
52 if( $field['prepend'] !== "" )
53 {
54 $field['class'] .= ' acf-is-prepended';
55 $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
56 }
57
58
59 // append
60 if( $field['append'] !== "" )
61 {
62 $field['class'] .= ' acf-is-appended';
63 $e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
64 }
65
66
67 $e .= '<div class="acf-input-wrap">';
68 $e .= '<input type="password"';
69
70 foreach( $o as $k )
71 {
72 $e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
73 }
74
75 $e .= ' />';
76 $e .= '</div>';
77
78
79 // return
80 echo $e;
81 }
82
83
84 /*
85 * create_options()
86 *
87 * Create extra options for your field. This is rendered when editing a field.
88 * The value of $field['name'] can be used (like bellow) to save extra data to the $field
89 *
90 * @type action
91 * @since 3.6
92 * @date 23/01/13
93 *
94 * @param $field - an array holding all the field's data
95 */
96
97 function create_options( $field )
98 {
99 // vars
100 $key = $field['name'];
101
102 ?>
103 <tr class="field_option field_option_<?php echo $this->name; ?>">
104 <td class="label">
105 <label><?php _e("Placeholder Text",'acf'); ?></label>
106 <p><?php _e("Appears within the input",'acf') ?></p>
107 </td>
108 <td>
109 <?php
110 do_action('acf/create_field', array(
111 'type' => 'text',
112 'name' => 'fields[' .$key.'][placeholder]',
113 'value' => $field['placeholder'],
114 ));
115 ?>
116 </td>
117 </tr>
118 <tr class="field_option field_option_<?php echo $this->name; ?>">
119 <td class="label">
120 <label><?php _e("Prepend",'acf'); ?></label>
121 <p><?php _e("Appears before the input",'acf') ?></p>
122 </td>
123 <td>
124 <?php
125 do_action('acf/create_field', array(
126 'type' => 'text',
127 'name' => 'fields[' .$key.'][prepend]',
128 'value' => $field['prepend'],
129 ));
130 ?>
131 </td>
132 </tr>
133 <tr class="field_option field_option_<?php echo $this->name; ?>">
134 <td class="label">
135 <label><?php _e("Append",'acf'); ?></label>
136 <p><?php _e("Appears after the input",'acf') ?></p>
137 </td>
138 <td>
139 <?php
140 do_action('acf/create_field', array(
141 'type' => 'text',
142 'name' => 'fields[' .$key.'][append]',
143 'value' => $field['append'],
144 ));
145 ?>
146 </td>
147 </tr>
148 <?php
149 }
150
151 }
152
153 new acf_field_password();
154
155 ?>