/
fieldset.php
97 lines (72 loc) · 2.46 KB
/
fieldset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Fieldset
*
* - to group elements
* - set element amount per row (1,2,3,4,6) <- like bootstrap
* - title (if more then one) top or bottom of element
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_fieldset' ) ) {
class Exopite_Simple_Options_Framework_Field_fieldset extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
}
public function output() {
echo $this->element_before();
$unallows = array();
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
$self = new Exopite_Simple_Options_Framework( array(
'id' => $this->element_name(),
'multilang' => $this->config['multilang'],
'is_options_simple' => $this->config['is_options_simple'],
), null );
$i = 0;
$fields = $this->field['fields'];
echo '<div class="container">';
echo '<div class="row">';
/**
* 1 -> col-12 col-lg-12 (12/index)
* 2 -> col-12 col-lg-6
* 3 -> col-12 col-lg-4
* 4 -> col-12 col-lg-3
* 6 -> col-12 col-lg-2
*/
$col_classes = array( 'col', 'col-xs-12' );
$allowed_cols = array( 1, 2, 3, 4, 6 );
$col_number = ( isset( $this->field['options']['cols'] ) ) ? intval( $this->field['options']['cols'] ) : 1;
if ( ! in_array( $col_number, $allowed_cols ) ) {
$col_number = 1;
} else {
$col_classes[] = 'col-lg-' . ( 12 / $col_number );
$col_classes[] = 'exopite-sof-col-lg';
}
foreach ( $fields as $field ) {
echo '<div class="' . implode( ' ', $col_classes ) . '">';
if ( in_array( $field['type'], $unallows ) ) {
$field['_notice'] = true;
continue;
}
$self->include_field_class( array( 'type' => $field['type'] ) );
$self->enqueue_field_class( array( 'type' => $field['type'] ) );
if ( is_serialized( $this->value ) ) {
$this->value = unserialize( $this->value );
}
$field_value = '';
if ( isset( $this->value[ $field['id'] ] ) ) {
$field_value = $this->value[ $field['id'] ];
} elseif ( isset( $field['default'] ) ) {
$field_value = $field['default'];
}
echo $self->add_field( $field, $field_value );
echo '</div>'; // col
}
echo '</div>'; // row
echo '</div>'; // container
echo $this->element_after();
}
}
}