PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / forms / controls / holders / tab.php
robin-image-optimizer / libs / factory / forms / controls / holders Last commit date
accordion-item.php 5 months ago accordion.php 5 months ago columns.php 5 months ago control-group-item.php 5 months ago control-group.php 5 months ago div.php 5 months ago form-group.php 5 months ago index.php 6 months ago more-link.php 5 months ago tab-item.php 5 months ago tab.php 5 months ago
tab.php
135 lines
1 <?php
2 /**
3 * The file contains the class of Tab Control Holder.
4 *
5 * @package factory-forms
6 * @since 1.0.0
7 */
8
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 if ( ! class_exists( 'Wbcr_FactoryForms600_TabHolder' ) ) {
15
16 /**
17 * Tab Control Holder
18 *
19 * @since 1.0.0
20 */
21 class Wbcr_FactoryForms600_TabHolder extends Wbcr_FactoryForms600_Holder {
22
23 /**
24 * A holder type.
25 *
26 * @since 1.0.0
27 * @var string
28 */
29 public $type = 'tab';
30
31 /**
32 * An align of a tab (horizontal or vertical).
33 *
34 * @since 1.0.0
35 * @var string
36 */
37 public $align = 'horizontal';
38
39 /**
40 * Creates a new instance of control holder.
41 *
42 * @since 1.0.0
43 * @param mixed[] $options A holder options.
44 * @param FactoryForms600_Form $form A parent form.
45 */
46 public function __construct( $options, $form ) {
47 parent::__construct( $options, $form );
48 $this->align = isset( $options['align'] )
49 ? $options['align']
50 : 'horizontal';
51 }
52
53 /**
54 * Here we should render a beginning html of the tab.
55 *
56 * @since 1.0.0
57 * @return void
58 */
59 public function beforeRendering() {
60
61 $is_first_tab = true;
62 $tab_class = $this->getOption( 'class' );
63
64 if ( ! empty( $tab_class ) ) {
65 $this->addCssClass( $tab_class );
66 }
67
68 $this->addCssClass( 'factory-align-' . $this->align );
69
70 ?>
71 <div <?php $this->attrs(); ?>>
72 <div class="factory-headers">
73 <ul class="nav nav-tabs">
74 <?php
75 foreach ( $this->elements as $element ) {
76 if ( $element->options['type'] !== 'tab-item' ) {
77 continue;
78 }
79
80 $tab_icon = '';
81 $has_icon = isset( $element->options['icon'] );
82
83 if ( $has_icon ) {
84 $tab_icon = $element->options['icon'];
85 }
86
87 $builder = new Wbcr_FactoryForms600_HtmlAttributeBuilder();
88
89 $builder->addCssClass( 'factory-tab-item-header' );
90 $builder->addCssClass( 'factory-tab-item-header-' . $element->getName() );
91
92 if ( $has_icon ) {
93 $builder->addCssClass( 'factory-tab-item-header-with-icon' );
94 }
95 if ( $is_first_tab ) {
96 $builder->addCssClass( 'active' );
97 }
98
99 $builder->addHtmlData( 'tab-id', $element->getName() );
100 $is_first_tab = false;
101
102 if ( $has_icon ) {
103 ?>
104 <style>
105 .factory-form-tab-item-header-<?php $element->name(); ?> a {
106 background-image: url("<?php echo $tab_icon; ?>");
107 }
108 </style>
109 <?php } ?>
110 <li <?php $builder->printAttrs(); ?>>
111 <a href="#<?php $element->name(); ?>" data-toggle="tab">
112 <?php $element->title(); ?>
113 </a>
114 </li>
115 <?php } ?>
116 </ul>
117 </div>
118 <div class='tab-content factory-bodies'>
119 <?php
120 }
121
122 /**
123 * Here we should render an end html of the tab.
124 *
125 * @since 1.0.0
126 * @return void
127 */
128 public function afterRendering() {
129 ?>
130 </div>
131 </div>
132 <?php
133 }
134 }
135 }