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
<?php
final class Papi_Admin_Meta_Box_Tabs {
private $tabs = [];
public function __construct( array $tabs = [], $render = true ) {
if ( empty( $tabs ) ) {
return;
}
$this->tabs = papi_tabs_setup( $tabs );
if ( $render ) {
$this->html();
}
}
public function get_tabs() {
return $this->tabs;
}
private function html() {
?>
<div class="papi-tabs-wrapper">
<div class="papi-tabs-table-back"></div>
<div class="papi-tabs-back"></div>
<ul class="papi-tabs">
<?php
foreach ( $this->tabs as $tab ):
$css_classes = $this->tabs[0] === $tab ? 'active ' : '';
if ( empty( $tab->background ) ) {
$no_sidebar = empty( $tab->properties ) ? false : $tab->properties[0]->sidebar;
$css_classes .= ! empty( $tab->properties ) && $no_sidebar ? '' : 'white-tab';
} else {
$css_classes .= $tab->background === 'white' ? 'white-tab' : '';
}
?>
<li class="<?php echo $css_classes; ?>">
<a href="#" data-papi-tab="<?php echo $tab->id; ?>">
<?php if ( ! empty( $tab->icon ) ): ?>
<img src="<?php echo $tab->icon; ?>" alt="<?php echo $tab->title; ?>"/>
<?php endif;
echo $tab->title; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<div class="papi-tabs-content">
<?php
foreach ( $this->tabs as $tab ):
?>
<div class="<?php echo $this->tabs[0] === $tab ? 'active' : ''; ?>" data-papi-tab="<?php echo $tab->id; ?>">
<?php papi_render_properties( $tab->properties ); ?>
</div>
<?php
endforeach;
?>
</div>
</div>
<div class="papi-clear"></div>
<?php
}
}