PluginProbe
Advanced Custom Fields (ACF®) / 5.9.2
Advanced Custom Fields (ACF®) v5.9.2
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 / includes / fields / class-acf-field-tab.php
class-acf-field-tab.php
164 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( ! class_exists('acf_field_tab') ) :
4
5 class acf_field_tab extends acf_field {
6
7
8 /*
9 * __construct
10 *
11 * This function will setup the field type data
12 *
13 * @type function
14 * @date 5/03/2014
15 * @since 5.0.0
16 *
17 * @param n/a
18 * @return n/a
19 */
20
21 function initialize() {
22
23 // vars
24 $this->name = 'tab';
25 $this->label = __("Tab",'acf');
26 $this->category = 'layout';
27 $this->defaults = array(
28 'placement' => 'top',
29 'endpoint' => 0 // added in 5.2.8
30 );
31
32 }
33
34
35 /*
36 * render_field()
37 *
38 * Create the HTML interface for your field
39 *
40 * @param $field - an array holding all the field's data
41 *
42 * @type action
43 * @since 3.6
44 * @date 23/01/13
45 */
46
47 function render_field( $field ) {
48
49 // vars
50 $atts = array(
51 'href' => '',
52 'class' => 'acf-tab-button',
53 'data-placement' => $field['placement'],
54 'data-endpoint' => $field['endpoint'],
55 'data-key' => $field['key']
56 );
57
58 ?>
59 <a <?php acf_esc_attr_e( $atts ); ?>><?php echo acf_esc_html($field['label']); ?></a>
60 <?php
61
62
63 }
64
65
66
67 /*
68 * render_field_settings()
69 *
70 * Create extra options for your field. This is rendered when editing a field.
71 * The value of $field['name'] can be used (like bellow) to save extra data to the $field
72 *
73 * @param $field - an array holding all the field's data
74 *
75 * @type action
76 * @since 3.6
77 * @date 23/01/13
78 */
79
80 function render_field_settings( $field ) {
81
82 /*
83 // message
84 $message = '';
85 $message .= '<p>' . __( 'Use "Tab Fields" to better organize your edit screen by grouping fields together.', 'acf') . '</p>';
86 $message .= '<p>' . __( 'All fields following this "tab field" (or until another "tab field" is defined) will be grouped together using this field\'s label as the tab heading.','acf') . '</p>';
87
88
89 // default_value
90 acf_render_field_setting( $field, array(
91 'label' => __('Instructions','acf'),
92 'instructions' => '',
93 'name' => 'notes',
94 'type' => 'message',
95 'message' => $message,
96 ));
97 */
98
99
100 // preview_size
101 acf_render_field_setting( $field, array(
102 'label' => __('Placement','acf'),
103 'type' => 'select',
104 'name' => 'placement',
105 'choices' => array(
106 'top' => __("Top aligned", 'acf'),
107 'left' => __("Left aligned", 'acf'),
108 )
109 ));
110
111
112 // endpoint
113 acf_render_field_setting( $field, array(
114 'label' => __('Endpoint','acf'),
115 'instructions' => __('Define an endpoint for the previous tabs to stop. This will start a new group of tabs.', 'acf'),
116 'name' => 'endpoint',
117 'type' => 'true_false',
118 'ui' => 1,
119 ));
120
121 }
122
123
124 /*
125 * load_field()
126 *
127 * This filter is appied to the $field after it is loaded from the database
128 *
129 * @type filter
130 * @since 3.6
131 * @date 23/01/13
132 *
133 * @param $field - the field array holding all the field options
134 *
135 * @return $field - the field array holding all the field options
136 */
137 function load_field( $field ) {
138
139 // remove name to avoid caching issue
140 $field['name'] = '';
141
142 // remove instructions
143 $field['instructions'] = '';
144
145 // remove required to avoid JS issues
146 $field['required'] = 0;
147
148 // set value other than 'null' to avoid ACF loading / caching issue
149 $field['value'] = false;
150
151 // return
152 return $field;
153
154 }
155
156 }
157
158
159 // initialize
160 acf_register_field_type( 'acf_field_tab' );
161
162 endif; // class_exists check
163
164 ?>