PluginProbe ʕ •ᴥ•ʔ
Disable Admin Notices – Hide Dashboard Notifications / trunk
Disable Admin Notices – Hide Dashboard Notifications vtrunk
1.4.5 trunk 1.0.0 1.0.2 1.0.3 1.0.5 1.0.6 1.1.1 1.1.3 1.1.4 1.2.0 1.2.2 1.2.3 1.2.4 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4
disable-admin-notices / libs / factory / forms / controls / holders / tab.php
disable-admin-notices / libs / factory / forms / controls / holders Last commit date
accordion-item.php 1 year ago accordion.php 1 year ago columns.php 1 year ago control-group-item.php 1 year ago control-group.php 1 year ago div.php 1 year ago form-group.php 1 year ago index.php 3 years ago more-link.php 1 year ago tab-item.php 1 year ago tab.php 1 year ago
tab.php
139 lines
1 <?php
2 /**
3 * The file contains the class of Tab Control Holder.
4 *
5 * @author Alex Kovalev <alex.kovalevv@gmail.com>
6 * @copyright (c) 2018, Webcraftic Ltd
7 *
8 * @package factory-forms
9 * @since 1.0.0
10 */
11
12 // Exit if accessed directly
13 if( !defined('ABSPATH') ) {
14 exit;
15 }
16
17 if( !class_exists('Wbcr_FactoryForms480_TabHolder') ) {
18
19 /**
20 * Tab Control Holder
21 *
22 * @since 1.0.0
23 */
24 class Wbcr_FactoryForms480_TabHolder extends Wbcr_FactoryForms480_Holder {
25
26 /**
27 * A holder type.
28 *
29 * @since 1.0.0
30 * @var string
31 */
32 public $type = 'tab';
33
34 /**
35 * An align of a tab (horizontal or vertical).
36 *
37 * @since 1.0.0
38 * @var string
39 */
40 public $align = 'horizontal';
41
42 /**
43 * Creates a new instance of control holder.
44 *
45 * @since 1.0.0
46 * @param mixed[] $options A holder options.
47 * @param FactoryForms480_Form $form A parent form.
48 */
49 public function __construct($options, $form)
50 {
51 parent::__construct($options, $form);
52 $this->align = isset($options['align'])
53 ? $options['align']
54 : 'horizontal';
55 }
56
57 /**
58 * Here we should render a beginning html of the tab.
59 *
60 * @since 1.0.0
61 * @return void
62 */
63 public function beforeRendering()
64 {
65
66 $is_first_tab = true;
67 $tab_class = $this->getOption('class');
68
69 if( !empty($tab_class) ) {
70 $this->addCssClass($tab_class);
71 }
72
73 $this->addCssClass('factory-align-' . $this->align);
74
75 ?>
76 <div <?php $this->attrs() ?>>
77 <div class="factory-headers">
78 <ul class="nav nav-tabs">
79 <?php foreach($this->elements as $element) {
80 if( $element->options['type'] !== 'tab-item' ) {
81 continue;
82 }
83
84 $tab_icon = '';
85 $has_icon = isset($element->options['icon']);
86
87 if( $has_icon ) {
88 $tab_icon = $element->options['icon'];
89 }
90
91 $builder = new Wbcr_FactoryForms480_HtmlAttributeBuilder();
92
93 $builder->addCssClass('factory-tab-item-header');
94 $builder->addCssClass('factory-tab-item-header-' . $element->getName());
95
96 if( $has_icon ) {
97 $builder->addCssClass('factory-tab-item-header-with-icon');
98 }
99 if( $is_first_tab ) {
100 $builder->addCssClass('active');
101 }
102
103 $builder->addHtmlData('tab-id', $element->getName());
104 $is_first_tab = false;
105
106 if( $has_icon ) { ?>
107 <style>
108 .factory-form-tab-item-header-<?php $element->name() ?> a {
109 background-image: url("<?php echo $tab_icon ?>");
110 }
111 </style>
112 <?php } ?>
113 <li <?php $builder->printAttrs() ?>>
114 <a href="#<?php $element->name() ?>" data-toggle="tab">
115 <?php $element->title() ?>
116 </a>
117 </li>
118 <?php } ?>
119 </ul>
120 </div>
121 <div class='tab-content factory-bodies'>
122 <?php
123 }
124
125 /**
126 * Here we should render an end html of the tab.
127 *
128 * @since 1.0.0
129 * @return void
130 */
131 public function afterRendering()
132 {
133 ?>
134 </div>
135 </div>
136 <?php
137 }
138 }
139 }