-
Notifications
You must be signed in to change notification settings - Fork 0
/
wider-flux-css.php
100 lines (75 loc) · 2.66 KB
/
wider-flux-css.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
<?php
/**
* Register and enqueue all CSS.
* Not used if we are using Wonderflux thanks!
*
* @since 0.3
* @version 0.3
*
*/
class flux_layout_css extends wider_flux_layout {
function __construct() {
$this->structure();
$this->columns();
}
/**
* Inserts the core structure static CSS.
*
* Filters available:
* fluxl_css_core_path - full path to file
*
* @since 0.3
* @version 0.3
*
* @param none
*/
function structure() {
$path = apply_filters( 'fluxl_css_core_path', plugins_url( '/flux-layout/flux-layout-core.css', __FILE__ ) );
wp_register_style( 'flux-layout-core', esc_url( $path ), '', $this->version, 'screen, projection' );
wp_enqueue_style( 'flux-layout-core' );
}
/**
* Inserts the core structure dynamic layout CSS.
*
* Filters available:
* fluxl_css_layout_path - full path to file
*
* @since 0.3
* @version 0.3
*
* @param none
* @todo Optimise so we only filter 1 specific CSS file on style_loader_tag
*/
function columns() {
$path = apply_filters( 'fluxl_css_layout_path', plugins_url( '/flux-layout/flux-layout.php', __FILE__ ) );
$version = 'wfx-dynamic'; /* IMPORTANT - No changing, we filter off this and build values for dynamic grid */
wp_register_style( 'flux-layout', esc_url( $path ), '', $version, 'screen, projection' );
wp_enqueue_style( 'flux-layout' );
// IMPORTANT - Append layout arguments to url
add_filter( 'style_loader_tag', array($this,'css_add_args') );
}
/**
* Used to filter in CSS sizing parameters
*
* @since 0.3
* @version 0.3
*
* @param $input - from style_loader_tag (filter)
* @todo Setup values for filtering
*/
function css_add_args($input) {
//echo $input;
//print_r( get_theme_mod( $this->db_key ) );
$data = get_theme_mod( $this->db_key );
$columns = ( is_array($data) && array_key_exists('columns_num', $data ) && is_numeric( $data['columns_num'] ) ) ? $data['columns_num'] : $this->default_vals['columns_num'];
$position = ( is_array($data) && array_key_exists('container_p', $data ) && !empty( $data['container_p'] ) ) ? $data['container_p'] : $this->default_vals['container_p'];
$sb_position = ( is_array($data) && array_key_exists('sidebar_p', $data ) && !empty( $data['sidebar_p'] ) ) ? $data['sidebar_p'] : $this->default_vals['sidebar_p'];
$container_w = ( is_array($data) && array_key_exists('container_w', $data ) && !empty( $data['container_w'] ) ) ? $data['container_w'] : $this->default_vals['container_w'];
$vars = '&w=' . $container_w
. '&wu=' . 'percent'
. '&p=' . $position
. '&sbp=' . $sb_position
. '&c=' . $columns;
return str_replace(array('ver=wfx-dynamic'), array($vars), $input);
}
}