123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- if ( ! class_exists( 'acf_field_tab' ) ) :
- class acf_field_tab extends acf_field {
- public $show_in_rest = false;
-
- function initialize() {
-
- $this->name = 'tab';
- $this->label = __( 'Tab', 'acf' );
- $this->category = 'layout';
- $this->defaults = array(
- 'placement' => 'top',
- 'endpoint' => 0,
- );
- }
-
- function render_field( $field ) {
-
- $atts = array(
- 'href' => '',
- 'class' => 'acf-tab-button',
- 'data-placement' => $field['placement'],
- 'data-endpoint' => $field['endpoint'],
- 'data-key' => $field['key'],
- );
- if ( isset( $field['settings-type'] ) ) {
- $atts['class'] .= ' acf-settings-type-' . acf_slugify( $field['settings-type'] );
- }
- ?>
- <a <?php echo acf_esc_attrs( $atts ); ?>><?php echo acf_esc_html( $field['label'] ); ?></a>
- <?php
- }
-
- function render_field_settings( $field ) {
-
-
- acf_render_field_setting(
- $field,
- array(
- 'label' => __( 'Placement', 'acf' ),
- 'type' => 'select',
- 'name' => 'placement',
- 'choices' => array(
- 'top' => __( 'Top aligned', 'acf' ),
- 'left' => __( 'Left aligned', 'acf' ),
- ),
- )
- );
-
- acf_render_field_setting(
- $field,
- array(
- 'label' => __( 'New Tab Group', 'acf' ),
- 'instructions' => __( 'Start a new group of tabs at this tab.', 'acf' ),
- 'name' => 'endpoint',
- 'type' => 'true_false',
- 'ui' => 1,
- )
- );
- }
-
- function load_field( $field ) {
-
- $field['name'] = '';
-
- $field['instructions'] = '';
-
- $field['required'] = 0;
-
- $field['value'] = false;
-
- return $field;
- }
- }
-
- acf_register_field_type( 'acf_field_tab' );
- endif;
- ?>
|