-
Notifications
You must be signed in to change notification settings - Fork 2
/
card-loop.php
executable file
·312 lines (219 loc) · 7.92 KB
/
card-loop.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php // The loop for displaying cards
function wpcc_card_display($wpcc_display_query,$wpcc_shortcode_layout){
//SET Get Default Layout for the cards
$layout = get_option( 'wpcc_layout' );
// Check URL vars for layout
if ( isset($_GET["layout"]) ) {
$layout = esc_html( $_GET["layout"] );
}
// Check if Layout is set by the shortcode
if ( $wpcc_shortcode_layout ) {
$layout = $wpcc_shortcode_layout;
}
// Construct outer 'cardHolder' DIV with classes
$wpcc_card_output= '<div class="cardHolder ';
$wpcc_card_output.= $layout;
if($layout == 'card') {
$wpcc_card_output.= ' ' . get_option( 'wpcc_scroll_direction' );
}
if( defined( 'WPCC_LAYOUT_SWITCHING') && WPCC_LAYOUT_SWITCHING === 1){
$wpcc_card_output.= ' layoutSwitching';
}
$wpcc_card_output.= '">';
// Construct Internal 'cards' DIV with classes
$wpcc_card_output.= '<div class="cards ';
if(get_option( 'wpcc_greyscale' ) == 1) {
$wpcc_card_output.= 'greyscale ';
}
if(get_option( 'wpcc_tinting ' ) == 1) {
$wpcc_card_output.= 'tint ';
}
if($layout == 'small-card') {
$wpcc_card_output.= 'js-masonry ' . get_option('wpcc_small_card_columns');
}
$wpcc_card_output.= '">';
// The Loop
if ( $wpcc_display_query -> have_posts() ) {
while ( $wpcc_display_query -> have_posts() ) {
$wpcc_display_query -> the_post();
global $post;
//set up the link for the card
if(get_field("wpcc_card_type") === 'external'){
$card_link = esc_url(get_field('wpcc_external_url') );
}else{
$card_link = get_permalink($post->ID);
}
//Add a filter on $card_link to let plugins change it
if(has_filter('wpcc_card_link')) {
$card_link = apply_filters('wpcc_card_link', $card_link);
}
// Set Card Title
$cardTitle = get_the_title();
if(has_filter('wpcc_archive_card_title')) {
$cardTitle = apply_filters('wpcc_archive_card_title', $cardTitle);
}
// Set Card Subtitle
$cardSubtitle = get_field('wpcc_subtitle');
if(has_filter('wpcc_archive_card_subtitle')) {
$cardSubtitle = apply_filters('wpcc_archive_card_subtitle', $cardSubtitle);
}
// when 'List' is the layout type
if ( $layout =='list') {
do_action('wpcc_before_card');
// Card Link
$wpcc_card_output.= '<a class="card ';
// Card Link Classes
ob_start();
do_action('wpcc_card_link_classes');
$link_classes = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_classes;
// Card Link Href
$wpcc_card_output.= '" href="' . $card_link . '" ';
// Card Link Inline Style
$wpcc_card_output.= 'style="background-color: ' . get_field('wpcc_color') . '" ';
// Card Link Target
if(get_field("wppc_external_new_window") == '1'){
$wpcc_card_output.= 'target="_blank" ';
}
//Action to add additional attributes to the anchor
ob_start();
do_action('wpcc_card_link_attr');
$link_attrs = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_attrs;
//END Anchor
$wpcc_card_output.= '>';
// Card List Body DIV
$wpcc_card_output.= '<div class="cardBody">';
// Output Card Title
$wpcc_card_output.= '<h3 style="color: ' . get_field('wpcc_color') . '">' . $cardTitle . '</h3>';
// Output Card Subtitle
if($cardSubtitle){
$wpcc_card_output.= '<p>' . $cardSubtitle . '</p>';
}
// Close List Body Div
$wpcc_card_output.= '</div>';
// Output Card List Arrow
$wpcc_card_output.= '<i class="fa fa-angle-circled-right" style="color: ' . get_field('wpcc_color') . '"></i>';
// CLOSE Anchor
$wpcc_card_output.= '</a>';
do_action('wpcc_after_card');
// If 'Small Card' is the layout type
} elseif ( $layout == 'small-card' ) {
do_action('wpcc_before_card');
// Card Link
$wpcc_card_output.= '<a class="card ';
// Card Link Classes
ob_start();
do_action('wpcc_card_link_classes');
$link_classes = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_classes;
// Card Link Href
$wpcc_card_output.= '" href="' . $card_link . '" ';
// Card Link Target
if(get_field("wppc_external_new_window") == '1'){
$wpcc_card_output.= 'target="_blank" ';
}
//Action to add additional attributes to the anchor
ob_start();
do_action('wpcc_card_link_attr');
$link_attrs = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_attrs;
$wpcc_card_output.= '>';
// Card List Body DIV
$wpcc_card_output.= '<div class="cardBody">';
// Card Image DIV
$wpcc_card_output.= '<div class="cardImage" ';
// Set Card Image
$image = get_field('wpcc_image');
$image_obj = wp_get_attachment_image_src( $image, 'card_image' );
// Card Image Styles
$wpcc_card_output.= 'style="background: ' . get_field('wpcc_color') . ' url(' . $image_obj[0] . ') no-repeat 50% 50%; background-size:cover;">';
// Close Card Image DIV
$wpcc_card_output.= '</div>';
// Card Overlay SPAN
$wpcc_card_output.= '<span class="overlay" ';
if(get_option( 'wpcc_tinting' ) == 1) {
$wpcc_card_output.= 'style="background-color: ' . get_field('wpcc_color') . '"';
}
$wpcc_card_output.= '></span>';
// Card Details DIV
$wpcc_card_output.= '<div class="cardDetails">';
// Output Card Title
$wpcc_card_output.= '<h3 style="color: ' . get_field('wpcc_color') . '">' . $cardTitle . '</h3>';
// Output Card Subtitle
if($cardSubtitle){
$wpcc_card_output.= '<p>' . $cardSubtitle . '</p>';
}
// Close Card Details DIV
$wpcc_card_output.= '</div>';
// Close Card List Body DIV
$wpcc_card_output.= '</div>';
// END Anchor
$wpcc_card_output.= '</a>';
do_action('wpcc_after_card');
// All other card types
} else {
do_action('wpcc_before_card');
// Card Link
$wpcc_card_output.= '<a class="card ';
// Card Link Classes
ob_start();
do_action('wpcc_card_link_classes');
$link_classes = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_classes;
// Card Link Href
$wpcc_card_output.= '" href="' . $card_link . '" ';
// Card Link Tab Index
$wpcc_card_output.= 'tabindex="-1" ';
// Card Link Target
if(get_field("wppc_external_new_window") == '1'){
$wpcc_card_output.= 'target="_blank" ';
}
//Action to add additional attributes to the anchor
ob_start();
do_action('wpcc_card_link_attr');
$link_attrs = ob_get_contents();
ob_end_clean();
$wpcc_card_output.= $link_attrs;
$wpcc_card_output.= '>';
// Card List Body DIV
$wpcc_card_output.= '<div class="cardBody">';
// Card Top Section
$wpcc_card_output.= '<div class="topSection" style="background: url(';
$image = get_field('wpcc_image');
$image_obj = wp_get_attachment_image_src( $image, 'card_image' );
$wpcc_card_output.= $image_obj[0] . ') no-repeat 50% 50%; background-size:cover;">';
$wpcc_card_output.= '</div>';
// Card Overlay SPAN
$wpcc_card_output.= '<span class="overlay" ';
if(get_option( 'wpcc_tinting' ) == 1) {
$wpcc_card_output.= 'style="background-color: ' . get_field('wpcc_color') . '"';
}
$wpcc_card_output.= '></span>';
// Card Bottom Section.
$wpcc_card_output.= '<div class="bottomSection">';
$wpcc_card_output.= '<div class="intro">';
// Output Card Title
$wpcc_card_output.= '<h3 style="color: ' . get_field('wpcc_color') . '">' . $cardTitle . '</h3>';
// Output Card Subtitle
if($cardSubtitle){
$wpcc_card_output.= '<p>' . $cardSubtitle . '</p>';
}
$wpcc_card_output.= '</div>';
$wpcc_card_output.= '</div>';
$wpcc_card_output.= '</div>';
$wpcc_card_output.= '</a>';
do_action('wpcc_after_card');
}
}
}
wp_reset_query();
$wpcc_card_output.= '</div>';
$wpcc_card_output.= '</div></div>';
return $wpcc_card_output;
}