-
Notifications
You must be signed in to change notification settings - Fork 12
/
class.mesh-reponsive-grid.php
180 lines (164 loc) · 4.11 KB
/
class.mesh-reponsive-grid.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
/**
* Responsive Grid/Framework Class for Mesh
*
* @since 1.1.0
* @package Mesh
* @subpackage Responsive_Grid
*/
// Make sure we don't expose any info if called directly.
if ( ! function_exists( 'add_action' ) ) {
exit;
}
/**
* Class Mesh_Responsive_Grid
*/
class Mesh_Responsive_Grid {
/**
* Available Grid Systems,
* Foundation (Default)
* Bootstrap
*
* @since 1.1
*
* @var array
*/
private static $grid_systems = array();
/**
* Get the current responsive grid systems we support
*
* @param string $grid_system Responsive grid are we using.
*
* @return mixed
*/
public static function get_responsive_grid( $grid_system = '' ) {
$grid_systems = self::get_grid_systems();
$mesh_options = get_option( 'mesh_settings' );
// If we do not explicitly pass a grid_system fall back to our option.
if ( empty( $grid_system ) ) {
if ( isset( $mesh_options['grid_system'] ) && '' !== $mesh_options['grid_system'] ) {
$grid_system = $mesh_options['grid_system'];
}
}
// css_mode to grid conversion
// @todo this should be converted (I think we should update css mode to be text instead of int -@aware)
switch ( intval( $mesh_options['css_mode'] ) ) {
case 0:
$css_mode = 'css';
break;
case 2:
$css_mode = 'bootstrap';
break;
case 1:
default:
$css_mode = 'foundation';
if ( empty( $grid_system ) ) {
$grid_system = 'float';
}
}
// Foundation has more options for grid systems
if ( 'foundation' === $css_mode ) {
return $grid_systems[ $css_mode ][ $grid_system ];
}
return $grid_systems[ $css_mode ];
}
/**
* Get our list of grid systems available.
*
* @since 1.2.5
*
* @return array
*/
public static function get_grid_systems() {
self::$grid_systems = array(
'css' => array( // @since 1.2.5
'columns' => array(
'small' => 'small',
'medium' => 'medium',
'large' => 'large',
'x-large' => 'x-large',
'xx-large' => 'xx-large',
),
'offset' => 'offset',
'centered' => 'centered',
'columns_class' => 'columns',
'row_class' => 'row',
),
'foundation' => array(
'float' => array(
'name' => esc_html__( 'Float Grid (legacy)', 'mesh' ),
'columns' => array(
'small' => 'small',
'medium' => 'medium',
'large' => 'large',
'x-large' => 'x-large',
'xx-large' => 'xx-large',
),
'offset' => 'offset',
'centered' => 'centered',
'columns_class' => 'columns',
'row_class' => 'row', // @since 1.2.5
),
'flex' => array(
'name' => esc_html__( 'Flex Grid (Legacy)', 'mesh' ),
'columns' => array(
'small' => 'small',
'medium' => 'medium',
'large' => 'large',
'x-large' => 'x-large',
'xx-large' => 'xx-large',
),
'offset' => 'offset',
'centered' => 'centered',
'columns_class' => 'columns',
'row_class' => 'row',
),
'xy' => array(
'name' => esc_html__( 'XY Grid', 'mesh' ),
'columns' => array(
'small' => 'small',
'medium' => 'medium',
'large' => 'large',
'x-large' => 'x-large',
'xx-large' => 'xx-large',
),
'offset' => 'offset',
'centered' => 'centered',
'columns_class' => 'cell',
'row_class' => 'grid-x',
),
),
'bootstrap' => array(
'columns' => array(
'x-small' => 'col-xs',
'small' => 'col-sm',
'medium' => 'col-md',
'large' => 'col-lg',
),
'offset' => 'offset',
'columns_class' => '',
),
);
return apply_filters( 'mesh_responsive_grid_systems', self::$grid_systems );
}
}
/**
* Return a specific grid systems for usage in our templates.
*
* @since 1.2.5
*
* @return mixed
*/
function mesh_get_responsive_grid() {
return Mesh_Responsive_Grid::get_responsive_grid();
}
/**
* Get our list of filtered grid systems.
*
* @since 1.2.5
*
* @return array
*/
function mesh_get_responsive_grid_systems() {
return Mesh_Responsive_Grid::get_grid_systems();
}