1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
<?php
namespace SIW\Widgets;
use SIW\Elements;
/**
* Widget met contactinformatie
*
* @copyright 2019 SIW Internationale Vrijwilligersprojecten
* @since 3.0.0
*
* @widget_data
* Widget Name: SIW: Tabs
* Description: Toont tabs.
* Author: SIW Internationale Vrijwilligersprojecten
* Author URI: https://www.siw.nl
*/
class Tabs extends Widget {
/**
* {@inheritDoc}
*/
protected $widget_id ='tabs';
/**
* {@inheritDoc}
*/
protected $widget_dashicon = 'index-card';
/**
* {@inheritDoc}
*/
protected function set_widget_properties() {
$this->widget_name = __( 'Tabs', 'siw');
$this->widget_description = __( 'Toont tabs', 'siw' );
}
/**
* {@inheritDoc}
*/
public function get_widget_form() {
$widget_form = [
'title' => [
'type' => 'text',
'label' => __( 'Titel', 'siw'),
],
'panes' => [
'type' => 'repeater',
'label' => __( 'Tab' , 'siw' ),
'item_name' => __( 'Paneel', 'siw' ),
'item_label' => [
'selector' => "[id*='title']",
'update_event' => 'change',
'value_method' => 'val'
],
'fields' => [
'title' => [
'type' => 'text',
'label' => __( 'Titel', 'siw' )
],
'content' => [
'type' => 'tinymce',
'label' => __( 'Inhoud', 'siw' ),
'rows' => 10,
'default_editor' => 'html',
],
'show_button' => [
'type' => 'checkbox',
'label' => __( 'Toon een knop', 'siw' ),
'default' => false,
'state_emitter' => [
'callback' => 'conditional',
'args' => [
'button_{$repeater}[show]: val',
'button_{$repeater}[hide]: ! val'
],
],
],
'button_text' => [
'type' => 'text',
'label' => __( 'Knoptekst', 'siw' ),
'state_handler' => [
'button_{$repeater}[show]' => [ 'show' ],
'button_{$repeater}[hide]' => [ 'hide' ],
],
],
'button_url' => [
'type' => 'text',
'label' => __( 'URL', 'siw' ),
'description' => __( 'Relatief', 'siw' ),
'state_handler' => [
'button_{$repeater}[show]' => [ 'show' ],
'button_{$repeater}[hide]' => [ 'hide' ],
],
],
]
]
];
return $widget_form;
}
/**
* {@inheritDoc}
*/
protected function get_content( $instance, $args, $template_vars, $css_name ) {
$content = Elements::generate_tabs( $instance['panes'] );
return $content;
}
}