1: <?php
2:
3: 4: 5: 6:
7: final class Papi_Admin_Meta_Box_Tabs {
8:
9: 10: 11: 12: 13:
14: private $tabs = [];
15:
16: 17: 18: 19: 20: 21:
22: public function __construct( $tabs = [], $render = true ) {
23: if ( empty( $tabs ) ) {
24: return;
25: }
26:
27: $this->tabs = papi_setup_tabs( $tabs );
28:
29: if ( $render ) {
30: $this->html();
31: }
32: }
33:
34: 35: 36: 37: 38:
39: public function get_tabs() {
40: return $this->tabs;
41: }
42:
43: 44: 45:
46: private function html() {
47: ?>
48: <div class="papi-tabs-wrapper">
49: <div class="papi-tabs-table-back"></div>
50: <div class="papi-tabs-back"></div>
51: <ul class="papi-tabs">
52: <?php
53:
54: foreach ( $this->tabs as $tab ):
55: ?>
56: <li class="<?php echo $this->tabs[0] === $tab ? 'active' : ''; ?>">
57: <a href="#" data-papi-tab="<?php echo $tab->options->_name; ?>">
58: <?php if ( ! empty( $tab->options->icon ) ): ?>
59: <img src="<?php echo $tab->options->icon; ?>" alt="<?php echo $tab->options->title; ?>"/>
60: <?php endif;
61: echo $tab->options->title; ?>
62: </a>
63: </li>
64: <?php
65: endforeach;
66: ?>
67: </ul>
68: <div class="papi-tabs-content">
69: <?php
70: foreach ( $this->tabs as $tab ):
71: ?>
72: <div class="<?php echo $this->tabs[0] === $tab ? 'active' : ''; ?>"
73: data-papi-tab="<?php echo $tab->options->_name; ?>">
74: <?php
75: $properties = papi_populate_properties( $tab->properties );
76:
77: $properties = array_map( function ( $property ) {
78:
79: $property->sidebar = true;
80:
81: return $property;
82: }, $properties );
83:
84: papi_render_properties( $properties );
85: ?>
86: </div>
87: <?php
88: endforeach;
89: ?>
90: </div>
91: </div>
92: <div class="papi-clear"></div>
93: <?php
94: }
95: }
96: