-
Notifications
You must be signed in to change notification settings - Fork 0
/
front-page.php
250 lines (206 loc) · 6.32 KB
/
front-page.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
/**
* Front page for the Utility Pro theme
*
* @package Utility_Pro
* @author Carrie Dils
* @license GPL-2.0+
*/
add_action( 'genesis_meta', 'utility_pro_homepage_setup' );
/**
* Set up the homepage layout by conditionally loading sections when widgets
* are active.
*
* @since 1.0.0
*/
function utility_pro_homepage_setup() {
$home_sidebars = array(
'home_welcome' => is_active_sidebar( 'utility-home-welcome' ),
'home_welcome-b1' => is_active_sidebar( 'utility-home-welcome-b1' ),
'home_welcome-2' => is_active_sidebar( 'utility-home-welcome-2' ),
'home_welcome-b2' => is_active_sidebar( 'utility-home-welcome-b2' ),
'home_welcome-3' => is_active_sidebar( 'utility-home-welcome-3' ),
'home_welcome-b3' => is_active_sidebar( 'utility-home-welcome-b3' ),
'home_welcome-4' => is_active_sidebar( 'utility-home-welcome-4' ),
'home_gallery_1' => is_active_sidebar( 'utility-home-gallery-1' ),
'call_to_action' => is_active_sidebar( 'utility-call-to-action' ),
);
// Return early if no sidebars are active.
if ( ! in_array( true, $home_sidebars ) ) {
return;
}
// Get static home page number.
$page = ( get_query_var( 'page' ) ) ? (int) get_query_var( 'page' ) : 1;
// Only show home page widgets on page 1.
if ( 1 === $page ) {
// Add home welcome area if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcome' );
}
// Add home welcome area b1 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-b1'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcomeb1' );
}
// Add home welcome area 2 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-2'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcome2' );
}
// Add home welcome area b2 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-b2'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcomeb2' );
}
// Add home welcome area 3 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-3'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcome3' );
}
// Add home welcome area b3 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-b3'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcomeb3' );
}
// Add home welcome area 4 if "Home Welcome" widget area is active.
if ( $home_sidebars['home_welcome-4'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_welcome4' );
}
// Add home gallery area if "Home Gallery 1" widget area is active.
if ( $home_sidebars['home_gallery_1'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_home_gallery' );
}
// Add call to action area if "Call to Action" widget area is active.
if ( $home_sidebars['call_to_action'] ) {
add_action( 'genesis_after_header', 'utility_pro_add_call_to_action' );
}
}
// Full width layout.
//add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
// Remove standard loop and replace with loop showing Posts, not Page content.
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'utility_pro_front_loop' );
}
/**
* Display content for the "Home Welcome" section.
*
* @since 1.0.0
*/
function utility_pro_add_home_welcome() {
genesis_widget_area( 'utility-home-welcome',
array(
'before' => '<div class="home-welcome"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcomeb1() {
genesis_widget_area( 'utility-home-welcome-b1',
array(
'before' => '<div class="home-welcome-b1"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcome2() {
genesis_widget_area( 'utility-home-welcome-2',
array(
'before' => '<div class="home-welcome-2"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcomeb2() {
genesis_widget_area( 'utility-home-welcome-b2',
array(
'before' => '<div class="home-welcome-b2"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcome3() {
genesis_widget_area( 'utility-home-welcome-3',
array(
'before' => '<div class="home-welcome-3"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcomeb3() {
genesis_widget_area( 'utility-home-welcome-b3',
array(
'before' => '<div class="home-welcome-b3"><div class="wrap">',
'after' => '</div></div>',
)
);
}
function utility_pro_add_home_welcome4() {
genesis_widget_area( 'utility-home-welcome-4',
array(
'before' => '<div class="home-welcome-4"><div class="wrap">',
'after' => '</div></div>',
)
);
}
/**
* Display content for the "Home Gallery" section.
*
* @since 1.0.0
*/
function utility_pro_add_home_gallery() {
printf( '<div %s>', genesis_attr( 'home-gallery' ) );
genesis_structural_wrap( 'home-gallery' );
genesis_widget_area(
'utility-home-gallery-1',
array(
'before' => '<div class="home-gallery-1 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-2',
array(
'before' => '<div class="home-gallery-2 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-3',
array(
'before' => '<div class="home-gallery-3 widget-area">',
'after' => '</div>',
)
);
genesis_widget_area(
'utility-home-gallery-4',
array(
'before' => '<div class="home-gallery-4 widget-area">',
'after' => '</div>',
)
);
genesis_structural_wrap( 'home-gallery', 'close' );
echo '</div>';
}
/**
* Display content for the "Call to action" section.
*
* @since 1.0.0
*/
function utility_pro_add_call_to_action() {
genesis_widget_area(
'utility-call-to-action',
array(
'before' => '<div class="call-to-action-bar"><div class="wrap">',
'after' => '</div></div>',
)
);
}
/**
* Display latest posts instead of static page.
*
* @since 1.0.0
*/
function utility_pro_front_loop() {
global $query_args;
genesis_custom_loop( wp_parse_args( $query_args, array( 'post_type' => 'post', 'paged' => get_query_var( 'page' ) ) ) );
}
/**
* Remove sidebar from fromt page
*/
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
genesis();