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