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 / layouts / bootstrap-3 / bootstrap-3.php
robin-image-optimizer / libs / factory / forms / layouts / bootstrap-3 Last commit date
bootstrap-3.php 5 months ago index.php 6 months ago
bootstrap-3.php
207 lines
1 <?php
2 /**
3 * The file contains a form layout based on Twitter Bootstrap 3
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_Bootstrap3FormLayout' ) ) {
15 /**
16 * A form layout based on Twitter Bootstrap 3
17 */
18 class Wbcr_FactoryForms600_Bootstrap3FormLayout extends Wbcr_FactoryForms600_FormLayout {
19
20 public $name = 'default';
21
22 /**
23 * Creates a new instance of a bootstrap3 form layout.
24 *
25 * @since 1.0.0
26 * @param array $options A holder options.
27 * @param Wbcr_FactoryForms600_Form $form A parent form.
28 */
29 public function __construct( $options, $form ) {
30 parent::__construct( $options, $form );
31
32 $this->addCssClass( 'factory-bootstrap' );
33 if ( isset( $options['cssClass'] ) ) {
34 $this->addCssClass( $options['cssClass'] );
35 }
36 }
37
38 /**
39 * Renders a beginning of a form.
40 *
41 * @since 1.0.0
42 * @return void
43 */
44 public function beforeRendering() {
45 ?>
46 <div <?php $this->attrs(); ?>>
47 <div class="form-horizontal">
48 <?php
49 }
50
51 /**
52 * Renders the end of a form.
53 *
54 * @since 1.0.0
55 * @return void
56 */
57 public function afterRendering() {
58 ?>
59 </div>
60 </div>
61 <?php
62 }
63
64 /**
65 * @param Wbcr_FactoryForms600_Control $control
66 */
67 public function beforeControl( $control ) {
68 if ( $control->getType() == 'hidden' ) {
69 return;
70 }
71
72 $theme_class = '';
73 if ( isset( $control->options['theme'] ) ) {
74 $theme_class = strval( $control->options['theme'] );
75 }
76
77 $control_name = $control->getOption( 'name' );
78 $control_name_class = $control_name
79 ? 'factory-control-' . strval( $control_name )
80 : '';
81
82 $col_left = $control->getLayoutOption( 'column-left', '2' );
83 $col_right = $control->getLayoutOption( 'column-right', '10' );
84 ?>
85 <div class="form-group form-group-<?php echo esc_attr( strval( $control->getType() ) ); ?> <?php echo esc_attr( $theme_class ); ?> <?php echo esc_attr( $control_name_class ); ?>">
86 <label <?php echo $control->getType() !== 'checkbox' ? 'for="' . esc_attr( strval( $control->getNameOnForm() ) ) . '"' : ''; ?> class="col-sm-<?php echo esc_attr( $col_left ); ?> control-label">
87 <?php if ( $control->hasIcon() ) { ?>
88 <img class="control-icon" src="<?php $control->icon(); ?>"/>
89 <?php } ?>
90 <?php
91 $hint_type = $control->getLayoutOption( 'hint-type', 'default' );
92
93 $control->title();
94 if ( $control->hasHint() ) {
95 if ( $hint_type == 'icon' ) :
96 ?>
97 <?php $hint_icon_color = $control->getLayoutOption( 'hint-icon-color', 'green' ); ?>
98 <span class="factory-hint-icon factory-hint-icon-<?php echo esc_attr( $hint_icon_color ); ?>" data-toggle="factory-tooltip" data-placement="right" title="<?php $control->hint( true ); ?>">
99 ?
100
101 </span>
102 <?php endif; ?>
103 <?php if ( $control->getLayoutOption( 'hint-position', 'bottom' ) == 'left' ) : ?>
104 <div class="help-block"><?php $control->hint(); ?></div>
105 <?php endif; ?>
106 <?php } ?>
107 </label>
108 <div class="control-group col-sm-<?php echo esc_attr( $col_right ); ?>">
109 <?php
110 }
111
112 /**
113 * @param Wbcr_FactoryForms600_Control $control
114 */
115 public function afterControl( $control ) {
116 if ( $control->getType() == 'hidden' ) {
117 return;
118 }
119 ?>
120 <?php if ( $control->getOption( 'after', false ) ) { ?>
121 <span class="factory-after">
122 <?php $control->option( 'after' ); ?>
123 </span>
124 <?php } ?>
125
126 <?php
127 $hint_type = $control->getLayoutOption( 'hint-type', 'default' );
128 if ( $control->hasHint() && $hint_type == 'default' && $control->getLayoutOption( 'hint-position', 'bottom' ) == 'bottom' ) :
129 ?>
130 <div class="help-block">
131 <?php $control->hint(); ?>
132 </div>
133 <?php endif; ?>
134 </div>
135 </div>
136 <?php
137 }
138
139 /**
140 * @param int $index
141 * @param int $total
142 */
143 public function startRow( $index, $total ) {
144 ?>
145 <div class='factory-row factory-row-<?php echo esc_attr( $index ); ?> factory-row-<?php echo esc_attr( $index ); ?>-of-<?php echo esc_attr( $total ); ?>'>
146 <div class="form-group form-group">
147 <?php
148 }
149
150 /**
151 * @param int $index
152 * @param int $total
153 */
154 public function endRow( $index, $total ) {
155 ?>
156 </div>
157 </div>
158 <?php
159 }
160
161 /**
162 * @param Wbcr_FactoryForms600_Control $control
163 * @param int $index
164 * @param int $total
165 */
166 public function startColumn( $control, $index, $total ) {
167 $index = $total == 2
168 ? 4
169 : 3;
170 $name = $control->getNameOnForm();
171 ?>
172 <label for="<?php echo $name; ?>" class="col-sm-2 control-label control-label-<?php echo $name; ?>">
173 <?php if ( $control->hasIcon() ) { ?>
174 <img class="control-icon" src="<?php $control->icon(); ?>"/>
175 <?php } ?>
176 <?php $control->title(); ?>
177 <?php if ( $control->hasHint() && $control->getLayoutOption( 'hint-position', 'bottom' ) == 'left' ) { ?>
178 <div class="help-block"><?php $control->hint(); ?></div>
179 <?php } ?>
180 </label>
181 <div class="control-group control-group-<?php echo $name; ?> col-sm-<?php echo $index; ?>">
182 <?php
183 }
184
185 /**
186 * @param Wbcr_FactoryForms600_Control $control
187 * @param int $index
188 * @param int $total
189 */
190 public function endColumn( $control, $index, $total ) {
191 ?>
192 <?php if ( $control->getOption( 'after', false ) ) { ?>
193 <span class="factory-after">
194 <?php $control->option( 'after' ); ?>
195 </span>
196 <?php } ?>
197 <?php if ( $control->hasHint() && $control->getLayoutOption( 'hint-position', 'bottom' ) == 'bottom' ) { ?>
198 <div class="help-block">
199 <?php $control->hint(); ?>
200 </div>
201 <?php } ?>
202 </div>
203 <?php
204 }
205 }
206 }
207