| 1 |
<?php |
| 2 |
|
| 3 |
use ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
die; } // Cannot access directly. |
| 7 |
/** |
| 8 |
* |
| 9 |
* Field: tabbed |
| 10 |
* |
| 11 |
* @since 1.0.0 |
| 12 |
* @version 1.0.0 |
| 13 |
*/ |
| 14 |
if ( ! class_exists( 'DarkifyField_tabbed' ) ) { |
| 15 |
class DarkifyField_tabbed extends DarkifyFields { |
| 16 |
|
| 17 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 18 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 19 |
} |
| 20 |
|
| 21 |
public function render() { |
| 22 |
|
| 23 |
$unallows = array( 'tabbed' ); |
| 24 |
|
| 25 |
echo wp_kses_post( $this->field_before() ); |
| 26 |
|
| 27 |
echo '<div class="darkify-tabbed-nav" data-depend-id="' . esc_attr( $this->field['id'] ) . '">'; |
| 28 |
foreach ( $this->field['tabs'] as $key => $tab ) { |
| 29 |
|
| 30 |
$tabbed_icon = ( ! empty( $tab['icon'] ) ) ? '<i class="darkify--icon ' . esc_attr( $tab['icon'] ) . '"></i>' : ''; |
| 31 |
$tabbed_active = ( empty( $key ) ) ? 'darkify-tabbed-active' : ''; |
| 32 |
|
| 33 |
echo '<a href="#" class="' . esc_attr( $tabbed_active ) . '"">' . wp_kses_post($tabbed_icon) . esc_attr( $tab['title'] ) . '</a>'; |
| 34 |
|
| 35 |
} |
| 36 |
echo '</div>'; |
| 37 |
|
| 38 |
echo '<div class="darkify-tabbed-contents">'; |
| 39 |
foreach ( $this->field['tabs'] as $key => $tab ) { |
| 40 |
|
| 41 |
$tabbed_hidden = ( ! empty( $key ) ) ? ' hidden' : ''; |
| 42 |
|
| 43 |
echo '<div class="darkify-tabbed-content' . esc_attr( $tabbed_hidden ) . '">'; |
| 44 |
|
| 45 |
foreach ( $tab['fields'] as $field ) { |
| 46 |
|
| 47 |
if ( in_array( $field['type'], $unallows ) ) { |
| 48 |
$field['_notice'] = true; } |
| 49 |
|
| 50 |
$field_id = ( isset( $field['id'] ) ) ? $field['id'] : ''; |
| 51 |
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
| 52 |
$field_value = ( isset( $this->value[ $field_id ] ) ) ? $this->value[ $field_id ] : $field_default; |
| 53 |
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique . '[' . $this->field['id'] . ']' : $this->field['id']; |
| 54 |
|
| 55 |
Darkify::field( $field, $field_value, $unique_id, 'field/tabbed' ); |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
echo '</div>'; |
| 60 |
|
| 61 |
} |
| 62 |
echo '</div>'; |
| 63 |
|
| 64 |
echo wp_kses_post( $this->field_after() ); |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|