PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.5
Filter Everything — WordPress & WooCommerce Filters v1.9.5
1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 All 51 releases
filter-everything / src / Settings / TabRenderer.php

TabRenderer.php in Filter Everything — WordPress & WooCommerce Filters 1.9.5, at src/Settings/TabRenderer.php

54 lines 1009 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FilterEverything\Filter;
4
5 if ( ! defined('ABSPATH') ) {
6 exit;
7 }
8
9 class TabRenderer
10 {
11
12 private $tabs = [];
13
14 public function register(TabInterface $tab)
15 {
16 $this->tabs[$tab->getName()] = $tab;
17 }
18
19 public function init()
20 {
21 foreach ($this->tabs as $tab) {
22 $tab->init();
23 }
24 }
25
26 public function render()
27 {
28 $tab = $this->get($this->current()) ?: reset($this->tabs);
29
30 if ($tab && $tab->valid()) {
31 flrt_include_admin_view( 'options', array('tabs' => $this->tabs, 'current' => $tab) );
32 }
33 }
34
35 public function get($name)
36 {
37 return $this->has($name) ? $this->tabs[$name] : null;
38 }
39
40 public function has($name)
41 {
42 return isset($this->tabs[$name]);
43 }
44
45 public function current()
46 {
47 /**
48 * string
49 */
50 $get = Container::instance()->getTheGet();
51 return isset($get['tab']) ? sanitize_key($get['tab']) : null;
52 }
53 }
54