Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Last active March 27, 2017 18:35
Show Gist options
  • Save Tmeister/a581d045f0e880f450bb13999abd780b to your computer and use it in GitHub Desktop.
Save Tmeister/a581d045f0e880f450bb13999abd780b to your computer and use it in GitHub Desktop.
<?php
protected function _register_controls() {
/**
* Start a control section.
*/
$this->start_controls_section(
'section-ine-tabs',
[ 'label' => __( 'INE Tabs', 'sage' ), ]
);
/**
* Repeater Controls
*/
$repeater = new Repeater();
$repeater->start_controls_tabs( 'ine_tabs_repeater' );
$repeater->start_controls_tab( 'tab', [ 'label' => __( 'Tab', 'sage' ) ] );
$repeater->add_control(
'title',
[
'label' => __( 'Tab Title', 'sage' ),
'type' => Controls_Manager::TEXT
]
);
$repeater->end_controls_tab();
$repeater->end_controls_tabs();
/**
* Once the repeater controls are done
* We need to ADD THE REPEATER as a Control
*/
$this->add_control(
'tabs',
[
'label' => __( 'Tabs', 'sage' ),
'type' => Controls_Manager::REPEATER,
'show_label' => true,
'default' => [
[
'title' => __( 'Default Tab', 'sage' ),
]
],
'fields' => array_values( $repeater->get_controls() ),
'title_field' => '{{{title}}}',
]
);
$this->end_controls_section();
}
<?php
protected function _register_controls() {
$this->start_controls_section(
'section-ine-tabs',
[ 'label' => __( 'INE Tabs', 'sage' ), ]
);
$repeater = new Repeater();
$repeater->start_controls_tabs( 'ine_tabs_repeater' );
$repeater->start_controls_tab( 'tab', [ 'label' => __( 'Tab', 'sage' ) ] );
$repeater->add_control(
'tab_title',
[
'label' => __( 'Tab Title', 'sage' ),
'type' => Controls_Manager::TEXT
]
);
$repeater->end_controls_tab();
$repeater->end_controls_tabs();
$this->end_controls_section();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment