|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* LSX functions and definitions - Widgets. |
|
4
|
|
|
* |
|
5
|
|
|
* @package lsx |
|
6
|
|
|
* @subpackage widgets |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
10
|
|
|
exit; |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
if ( ! function_exists( 'lsx_widget_area_init' ) ) : |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Register widgetized area and update sidebar with default widgets. |
|
17
|
|
|
* |
|
18
|
|
|
* @package lsx |
|
19
|
|
|
* @subpackage widgets |
|
20
|
|
|
*/ |
|
21
|
|
|
function lsx_widget_area_init() { |
|
22
|
|
|
register_sidebar( array( |
|
23
|
|
|
'name' => esc_html__( 'Home', 'lsx' ), |
|
24
|
|
|
'id' => 'sidebar-home', |
|
25
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
|
26
|
|
|
'after_widget' => '</aside>', |
|
27
|
|
|
'before_title' => '<h3 class="widget-title">', |
|
28
|
|
|
'after_title' => '</h3>', |
|
29
|
|
|
) ); |
|
30
|
|
|
|
|
31
|
|
|
register_sidebar( array( |
|
32
|
|
|
'name' => esc_html__( 'Sidebar', 'lsx' ), |
|
33
|
|
|
'id' => 'sidebar-1', |
|
34
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
|
35
|
|
|
'after_widget' => '</aside>', |
|
36
|
|
|
'before_title' => '<h3 class="widget-title">', |
|
37
|
|
|
'after_title' => '</h3>', |
|
38
|
|
|
) ); |
|
39
|
|
|
|
|
40
|
|
|
register_sidebar( array( |
|
41
|
|
|
'name' => esc_html__( 'Footer', 'lsx' ), |
|
42
|
|
|
'id' => 'sidebar-footer', |
|
43
|
|
|
'before_widget' => '<div class="styler"><aside id="%1$s" class="widget %2$s">', |
|
44
|
|
|
'after_widget' => '</aside></div>', |
|
45
|
|
|
'before_title' => '<h3 class="widget-title">', |
|
46
|
|
|
'after_title' => '</h3>', |
|
47
|
|
|
) ); |
|
48
|
|
|
|
|
49
|
|
|
register_sidebar( array( |
|
50
|
|
|
'name' => esc_html__( 'Footer Call to Action', 'lsx' ), |
|
51
|
|
|
'id' => 'sidebar-footer-cta', |
|
52
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
|
53
|
|
|
'after_widget' => '</aside>', |
|
54
|
|
|
'before_title' => '<h3 class="widget-title">', |
|
55
|
|
|
'after_title' => '</h3>', |
|
56
|
|
|
) ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
endif; |
|
60
|
|
|
|
|
61
|
|
|
add_action( 'widgets_init', 'lsx_widget_area_init' ); |
|
62
|
|
|
|
|
63
|
|
|
if ( ! function_exists( 'lsx_sidebar_footer_params' ) ) : |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Register widgetized area and update sidebar with default widgets. |
|
67
|
|
|
* |
|
68
|
|
|
* @package lsx |
|
69
|
|
|
* @subpackage widgets |
|
70
|
|
|
*/ |
|
71
|
|
|
function lsx_sidebar_footer_params( $params ) { |
|
72
|
|
|
$sidebar_id = $params[0]['id']; |
|
73
|
|
|
|
|
74
|
|
|
if ( 'sidebar-footer' === $sidebar_id ) { |
|
75
|
|
|
$total_widgets = wp_get_sidebars_widgets(); |
|
76
|
|
|
$sidebar_widgets = count( $total_widgets[ $sidebar_id ] ); |
|
77
|
|
|
$params[0]['before_widget'] = str_replace( 'class="styler', 'class="col-md-' . floor( 12 / $sidebar_widgets ), $params[0]['before_widget'] ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $params; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
endif; |
|
84
|
|
|
|
|
85
|
|
|
add_filter( 'dynamic_sidebar_params', 'lsx_sidebar_footer_params' ); |
|
86
|
|
|
|