| 1 |
<?php |
| 2 |
/** |
| 3 |
* Framework Tabbed fields. |
| 4 |
* |
| 5 |
* @link https://shapedplugin.com/ |
| 6 |
* |
| 7 |
* @package Smart_Post_Show |
| 8 |
* @subpackage Smart_Post_Show/admin/views |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
die; |
| 13 |
} // Cannot access directly. |
| 14 |
|
| 15 |
/** |
| 16 |
* |
| 17 |
* Field: tabbed |
| 18 |
* |
| 19 |
* @since 1.0.0 |
| 20 |
* @version 1.0.0 |
| 21 |
*/ |
| 22 |
if ( ! class_exists( 'SP_PC_Field_tabbed' ) ) { |
| 23 |
|
| 24 |
/** |
| 25 |
* SP_PC_Field_tabbed |
| 26 |
*/ |
| 27 |
class SP_PC_Field_tabbed extends SP_PC_Fields { |
| 28 |
|
| 29 |
/** |
| 30 |
* Field constructor. |
| 31 |
* |
| 32 |
* @param array $field The field type. |
| 33 |
* @param string $value The values of the field. |
| 34 |
* @param string $unique The unique ID for the field. |
| 35 |
* @param string $where To where show the output CSS. |
| 36 |
* @param string $parent The parent args. |
| 37 |
*/ |
| 38 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 39 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Render field |
| 44 |
* |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
public function render() { |
| 48 |
|
| 49 |
$unallows = array( 'tabbed' ); |
| 50 |
|
| 51 |
echo wp_kses_post( $this->field_before() ); |
| 52 |
|
| 53 |
echo '<div class="spf-tabbed-nav">'; |
| 54 |
foreach ( $this->field['tabs'] as $key => $tab ) { |
| 55 |
|
| 56 |
$tabbed_icon = ( ! empty( $tab['icon'] ) ) ? $tab['icon'] : ''; |
| 57 |
$tabbed_class = ( ! empty( $tab['class'] ) ) ? $tab['class'] : ''; |
| 58 |
$tabbed_active = ( empty( $key ) ) ? ' spf-tabbed-active' : ''; |
| 59 |
|
| 60 |
echo '<a href="#" class="' . esc_attr( $tabbed_class . $tabbed_active ) . '" >' . wp_kses_post( $tabbed_icon . $tab['title'] ) . '</a>'; |
| 61 |
|
| 62 |
} |
| 63 |
echo '</div>'; |
| 64 |
|
| 65 |
echo '<div class="spf-tabbed-sections">'; |
| 66 |
foreach ( $this->field['tabs'] as $key => $tab ) { |
| 67 |
|
| 68 |
$tabbed_hidden = ( ! empty( $key ) ) ? ' hidden' : ''; |
| 69 |
$tabbed_class = ( ! empty( $tab['class'] ) ) ? ' ' . $tab['class'] : ''; |
| 70 |
echo '<div class="spf-tabbed-section' . esc_attr( $tabbed_hidden . $tabbed_class ) . '">'; |
| 71 |
|
| 72 |
foreach ( $tab['fields'] as $field ) { |
| 73 |
if ( in_array( $field['type'], $unallows ) ) { |
| 74 |
$field['_notice'] = true; } |
| 75 |
$field_id = ( isset( $field['id'] ) ) ? $field['id'] : ''; |
| 76 |
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : ''; |
| 77 |
$field_value = ( isset( $this->value[ $field_id ] ) ) ? $this->value[ $field_id ] : $field_default; |
| 78 |
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : ''; |
| 79 |
|
| 80 |
SP_PC::field( $field, $field_value, $unique_id, 'field/tabbed' ); |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
echo '</div>'; |
| 85 |
|
| 86 |
} |
| 87 |
echo '</div>'; |
| 88 |
|
| 89 |
echo wp_kses_post( $this->field_after() ); |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|