PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.0-beta2
Secure Custom Fields v6.4.0-beta2
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / fields / class-acf-field-tab.php
secure-custom-fields / includes / fields Last commit date
class-acf-field-accordion.php 1 year ago class-acf-field-button-group.php 1 year ago class-acf-field-checkbox.php 1 year ago class-acf-field-color_picker.php 1 year ago class-acf-field-date_picker.php 1 year ago class-acf-field-date_time_picker.php 1 year ago class-acf-field-email.php 1 year ago class-acf-field-file.php 1 year ago class-acf-field-google-map.php 1 year ago class-acf-field-group.php 1 year ago class-acf-field-icon_picker.php 1 year ago class-acf-field-image.php 1 year ago class-acf-field-link.php 1 year ago class-acf-field-message.php 1 year ago class-acf-field-number.php 1 year ago class-acf-field-oembed.php 1 year ago class-acf-field-output.php 1 year ago class-acf-field-page_link.php 1 year ago class-acf-field-password.php 1 year ago class-acf-field-post_object.php 1 year ago class-acf-field-radio.php 1 year ago class-acf-field-range.php 1 year ago class-acf-field-relationship.php 1 year ago class-acf-field-select.php 1 year ago class-acf-field-separator.php 1 year ago class-acf-field-tab.php 1 year ago class-acf-field-taxonomy.php 1 year ago class-acf-field-text.php 1 year ago class-acf-field-textarea.php 1 year ago class-acf-field-time_picker.php 1 year ago class-acf-field-true_false.php 1 year ago class-acf-field-url.php 1 year ago class-acf-field-user.php 1 year ago class-acf-field-wysiwyg.php 1 year ago class-acf-field.php 1 year ago index.php 1 year ago
class-acf-field-tab.php
167 lines
1 <?php
2
3 if ( ! class_exists( 'acf_field_tab' ) ) :
4
5 class acf_field_tab extends acf_field {
6
7 public $show_in_rest = false;
8
9 /**
10 * This function will setup the field type data
11 *
12 * @type function
13 * @date 5/03/2014
14 * @since 5.0.0
15 *
16 * @param n/a
17 * @return n/a
18 */
19 function initialize() {
20
21 // vars
22 $this->name = 'tab';
23 $this->label = __( 'Tab', 'acf' );
24 $this->category = 'layout';
25 $this->description = __( 'Allows you to group fields into tabbed sections in the edit screen. Useful for keeping fields organized and structured.', 'acf' );
26 $this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-tabs.png';
27 $this->doc_url = 'https://www.advancedcustomfields.com/resources/tab/';
28 $this->supports = array(
29 'required' => false,
30 'bindings' => false,
31 );
32 $this->defaults = array(
33 'placement' => 'top',
34 'endpoint' => 0, // added in 5.2.8
35 'selected' => 0, // added in 6.3
36 );
37 }
38
39 /**
40 * Output the HTML required for a tab.
41 *
42 * @since 3.6
43 *
44 * @param array $field An array of the field data.
45 */
46 public function render_field( $field ) {
47 $atts = array(
48 'href' => '',
49 'class' => 'acf-tab-button',
50 'data-placement' => $field['placement'],
51 'data-endpoint' => $field['endpoint'],
52 'data-key' => $field['key'],
53 'data-selected' => $field['selected'],
54 );
55
56 if ( isset( $field['unique_tab_key'] ) && ! empty( $field['unique_tab_key'] ) ) {
57 $atts['data-unique-tab-key'] = $field['unique_tab_key'];
58 }
59
60 if ( isset( $field['settings-type'] ) ) {
61 $atts['data-settings-type'] = acf_slugify( $field['settings-type'] );
62 $atts['class'] .= ' acf-settings-type-' . acf_slugify( $field['settings-type'] );
63 }
64
65 if ( isset( $field['class'] ) && ! empty( $field['class'] ) ) {
66 $atts['class'] .= ' ' . $field['class'];
67 }
68
69 ?>
70 <a <?php echo acf_esc_attrs( $atts ); ?>><?php echo acf_esc_html( $field['label'] ); ?></a>
71 <?php
72 }
73
74 /**
75 * Create extra options for your field. This is rendered when editing a field.
76 * The value of $field['name'] can be used (like bellow) to save extra data to the $field
77 *
78 * @param $field - an array holding all the field's data
79 *
80 * @type action
81 * @since 3.6
82 * @date 23/01/13
83 */
84 function render_field_settings( $field ) {
85
86 /*
87 // message
88 $message = '';
89 $message .= '<p>' . __( 'Use "Tab Fields" to better organize your edit screen by grouping fields together.', 'acf') . '</p>';
90 $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>';
91
92
93 // default_value
94 acf_render_field_setting( $field, array(
95 'label' => __('Instructions','acf'),
96 'instructions' => '',
97 'name' => 'notes',
98 'type' => 'message',
99 'message' => $message,
100 ));
101 */
102
103 // preview_size
104 acf_render_field_setting(
105 $field,
106 array(
107 'label' => __( 'Placement', 'acf' ),
108 'type' => 'select',
109 'name' => 'placement',
110 'choices' => array(
111 'top' => __( 'Top aligned', 'acf' ),
112 'left' => __( 'Left aligned', 'acf' ),
113 ),
114 )
115 );
116
117 // endpoint
118 acf_render_field_setting(
119 $field,
120 array(
121 'label' => __( 'New Tab Group', 'acf' ),
122 'instructions' => __( 'Start a new group of tabs at this tab.', 'acf' ),
123 'name' => 'endpoint',
124 'type' => 'true_false',
125 'ui' => 1,
126 )
127 );
128 }
129
130
131 /**
132 * This filter is appied to the $field after it is loaded from the database
133 *
134 * @type filter
135 * @since 3.6
136 * @date 23/01/13
137 *
138 * @param $field - the field array holding all the field options
139 *
140 * @return $field - the field array holding all the field options
141 */
142 function load_field( $field ) {
143
144 // remove name to avoid caching issue
145 $field['name'] = '';
146
147 // remove instructions
148 $field['instructions'] = '';
149
150 // remove required to avoid JS issues
151 $field['required'] = 0;
152
153 // set value other than 'null' to avoid ACF loading / caching issue
154 $field['value'] = false;
155
156 // return
157 return $field;
158 }
159 }
160
161
162 // initialize
163 acf_register_field_type( 'acf_field_tab' );
164 endif; // class_exists check
165
166 ?>
167