forked from cipherdevgroup/alpha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.php
161 lines (149 loc) · 3.89 KB
/
layout.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
<?php
/**
* Functions for controlling layout options.
*
* @package Alpha\Functions\Layout
* @subpackage Alpha
* @author Robert Neu
* @copyright Copyright (c) 2015, WP Site Care, LLC
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
add_action( 'alpha_register_layouts', 'alpha_register_layouts', 10 );
/**
* Register our theme's custom layout options.
*
* @since 1.0.0
* @access public
* @return void
*/
function alpha_register_layouts() {
$layouts = array(
'2c-r' => array(
'label' => _x( '2 Columns: Right Sidebar', 'theme layout', 'alpha' ),
'is_global_layout' => true,
'is_post_layout' => true,
'image' => '%s/images/sidebar-right.svg',
),
'2c-l' => array(
'label' => _x( '2 Columns: Left Sidebar', 'theme layout', 'alpha' ),
'is_global_layout' => true,
'is_post_layout' => true,
'image' => '%s/images/sidebar-left.svg',
),
'1c' => array(
'label' => _x( '1 Column Wide', 'theme layout', 'alpha' ),
'is_global_layout' => true,
'is_post_layout' => true,
'image' => '%s/images/one-column.svg',
),
'1c-narrow' => array(
'label' => _x( '1 Column Narrow', 'theme layout', 'alpha' ),
'is_global_layout' => true,
'is_post_layout' => true,
'image' => '%s/images/one-column-narrow.svg',
),
);
foreach ( $layouts as $layout => $args ) {
carelib_get( 'layouts' )->register_layout( $layout, $args );
}
}
/**
* Return the full width content slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the full width content layout.
*/
function alpha_return_full_width_layout() {
return '1c';
}
/**
* Force the full width layout and return the slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the full content layout.
*/
function alpha_force_full_width_layout() {
add_filter( 'alpha_allow_layout_control', '__return_false' );
return alpha_return_full_width_layout();
}
/**
* Return the narrow narrow full width content slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the narrow full width content layout.
*/
function alpha_return_full_narrow_layout() {
return '1c-narrow';
}
/**
* Force the narrow full width layout and return the slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the narrow full content layout.
*/
function alpha_force_full_narrow_layout() {
add_filter( 'alpha_allow_layout_control', '__return_false' );
return alpha_return_full_narrow_layout();
}
/**
* Return the 2 column content / sidebar layout slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the right sidebar layout.
*/
function alpha_return_right_sidebar_layout() {
return '2c-r';
}
/**
* Force the 2 column content / sidebar layout slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the right sidebar layout.
*/
function alpha_force_right_sidebar_layout() {
add_filter( 'alpha_allow_layout_control', '__return_false' );
return alpha_return_right_sidebar_layout();
}
/**
* Return the 2 column sidebar / content layout slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the left sidebar layout.
*/
function alpha_return_left_sidebar_layout() {
return '2c-l';
}
/**
* Force the 2 column content / sidebar layout slug.
*
* @since 1.0.0
* @access public
* @return string the slug of the right sidebar layout.
*/
function alpha_force_left_sidebar_layout() {
add_filter( 'alpha_allow_layout_control', '__return_false' );
return alpha_return_left_sidebar_layout();
}
/**
* Check whether the current layout includes a sidebar.
*
* @since 1.0.0
* @access public
* @uses CareLib_Layouts::get_theme_layout
* @return bool true if the current layout includes a sidebar
*/
function alpha_layout_has_sidebar() {
return ! in_array(
carelib_get( 'layouts' )->get_theme_layout(),
array( '1c', '1c-narrow' ),
true
);
}