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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
| <?php
if ( ! function_exists( 'ghostpool_data_properties' ) ) {
function ghostpool_data_properties( $type ) {
// Get hub ID
ghostpool_get_hub_id( get_the_ID() );
// Check to see if options exists
if ( is_singular() ) { $GLOBALS['ghostpool_ajax_post_id'] = $GLOBALS['ghostpool_hub_id']; } else { $GLOBALS['ghostpool_ajax_post_id'] = ''; }
$GLOBALS['ghostpool_ajax_cats'] = ! empty( $GLOBALS['ghostpool_cats'] ) ? $GLOBALS['ghostpool_cats'] : '';
$GLOBALS['ghostpool_ajax_hub_field_slugs'] = ! empty( $GLOBALS['ghostpool_hub_field_slugs'] ) ? $GLOBALS['ghostpool_hub_field_slugs'] : '';
$GLOBALS['ghostpool_ajax_post_association'] = ! empty( $GLOBALS['ghostpool_post_association'] ) ? $GLOBALS['ghostpool_post_association'] : '';
$GLOBALS['ghostpool_ajax_post_types'] = ! empty( $GLOBALS['ghostpool_post_types'] ) ? $GLOBALS['ghostpool_post_types'] : '';
$GLOBALS['ghostpool_ajax_format'] = ! empty( $GLOBALS['ghostpool_format'] ) ? $GLOBALS['ghostpool_format'] : '';
$GLOBALS['ghostpool_ajax_size'] = ! empty( $GLOBALS['ghostpool_size'] ) ? $GLOBALS['ghostpool_size'] : '';
$GLOBALS['ghostpool_ajax_orderby'] = ! empty( $GLOBALS['ghostpool_orderby'] ) ? $GLOBALS['ghostpool_orderby'] : '';
$GLOBALS['ghostpool_ajax_date_posted'] = ! empty( $GLOBALS['ghostpool_date_posted'] ) ? $GLOBALS['ghostpool_date_posted'] : '';
$GLOBALS['ghostpool_ajax_date_modified'] = ! empty( $GLOBALS['ghostpool_date_modified'] ) ? $GLOBALS['ghostpool_date_modified'] : '';
$GLOBALS['ghostpool_ajax_per_page'] = ! empty( $GLOBALS['ghostpool_per_page'] ) ? $GLOBALS['ghostpool_per_page'] : '';
$GLOBALS['ghostpool_ajax_menu_per_page'] = ! empty( $GLOBALS['ghostpool_menu_per_page'] ) ? $GLOBALS['ghostpool_menu_per_page'] : '';
$GLOBALS['ghostpool_ajax_offset'] = ! empty( $GLOBALS['ghostpool_offset'] ) ? $GLOBALS['ghostpool_offset'] : '';
$GLOBALS['ghostpool_ajax_featured_image'] = ! empty( $GLOBALS['ghostpool_featured_image'] ) ? $GLOBALS['ghostpool_featured_image'] : '';
$GLOBALS['ghostpool_ajax_image_width'] = ! empty( $GLOBALS['ghostpool_image_width'] ) ? $GLOBALS['ghostpool_image_width'] : '';
$GLOBALS['ghostpool_ajax_image_height'] = ! empty( $GLOBALS['ghostpool_image_height'] ) ? $GLOBALS['ghostpool_image_height'] : '';
$GLOBALS['ghostpool_ajax_hard_crop'] = ! empty( $GLOBALS['ghostpool_hard_crop'] ) ? $GLOBALS['ghostpool_hard_crop'] : '';
$GLOBALS['ghostpool_ajax_image_alignment'] = ! empty( $GLOBALS['ghostpool_image_alignment'] ) ? $GLOBALS['ghostpool_image_alignment'] : '';
$GLOBALS['ghostpool_ajax_title_position'] = ! empty( $GLOBALS['ghostpool_title_position'] ) ? $GLOBALS['ghostpool_title_position'] : '';
$GLOBALS['ghostpool_ajax_content_display'] = ! empty( $GLOBALS['ghostpool_content_display'] ) ? $GLOBALS['ghostpool_content_display'] : '';
$GLOBALS['ghostpool_ajax_excerpt_length'] = ! empty( $GLOBALS['ghostpool_excerpt_length'] ) ? $GLOBALS['ghostpool_excerpt_length'] : 0;
$GLOBALS['ghostpool_ajax_meta_author'] = ! empty( $GLOBALS['ghostpool_meta_author'] ) ? $GLOBALS['ghostpool_meta_author'] : '';
$GLOBALS['ghostpool_ajax_meta_date'] = ! empty( $GLOBALS['ghostpool_meta_date'] ) ? $GLOBALS['ghostpool_meta_date'] : '';
$GLOBALS['ghostpool_ajax_meta_comment_count'] = ! empty( $GLOBALS['ghostpool_meta_comment_count'] ) ? $GLOBALS['ghostpool_meta_comment_count'] : '';
$GLOBALS['ghostpool_ajax_meta_views'] = ! empty( $GLOBALS['ghostpool_meta_views'] ) ? $GLOBALS['ghostpool_meta_views'] : '';
$GLOBALS['ghostpool_ajax_meta_followers'] = ! empty( $GLOBALS['ghostpool_meta_followers'] ) ? $GLOBALS['ghostpool_meta_followers'] : '';
$GLOBALS['ghostpool_ajax_meta_cats'] = ! empty( $GLOBALS['ghostpool_meta_cats'] ) ? $GLOBALS['ghostpool_meta_cats'] : '';
$GLOBALS['ghostpool_ajax_meta_tags'] = ! empty( $GLOBALS['ghostpool_meta_tags'] ) ? $GLOBALS['ghostpool_meta_tags'] : '';
$GLOBALS['ghostpool_ajax_meta_hub_cats'] = ! empty( $GLOBALS['ghostpool_meta_hub_cats'] ) ? $GLOBALS['ghostpool_meta_hub_cats'] : '';
$GLOBALS['ghostpool_ajax_meta_hub_fields'] = ! empty( $GLOBALS['ghostpool_meta_hub_fields'] ) ? $GLOBALS['ghostpool_meta_hub_fields'] : '';
$GLOBALS['ghostpool_ajax_meta_hub_award'] = ! empty( $GLOBALS['ghostpool_meta_hub_award'] ) ? $GLOBALS['ghostpool_meta_hub_award'] : '';
$GLOBALS['ghostpool_ajax_hub_cats_selected'] = ! empty( $GLOBALS['ghostpool_hub_cats_selected'] ) ? implode( ',', $GLOBALS['ghostpool_hub_cats_selected'] ) : '';
$GLOBALS['ghostpool_ajax_display_site_rating'] = ! empty( $GLOBALS['ghostpool_display_site_rating'] ) ? $GLOBALS['ghostpool_display_site_rating'] : '';
$GLOBALS['ghostpool_ajax_display_user_rating'] = ! empty( $GLOBALS['ghostpool_display_user_rating'] ) ? $GLOBALS['ghostpool_display_user_rating'] : '';
$GLOBALS['ghostpool_ajax_read_more_link'] = ! empty( $GLOBALS['ghostpool_read_more_link'] ) ? $GLOBALS['ghostpool_read_more_link'] : '';
$GLOBALS['ghostpool_ajax_page_arrows'] = ! empty( $GLOBALS['ghostpool_page_arrows'] ) ? $GLOBALS['ghostpool_page_arrows'] : '';
$GLOBALS['ghostpool_ajax_page_numbers'] = ! empty( $GLOBALS['ghostpool_page_numbers'] ) ? $GLOBALS['ghostpool_page_numbers'] : '';
$GLOBALS['ghostpool_ajax_author_id'] = ! empty( $GLOBALS['ghostpool_author_id'] ) ? $GLOBALS['ghostpool_author_id'] : '';
// Add to blog wrappers to pull query data
return ' data-type="' . $type . '" data-postid="' . $GLOBALS['ghostpool_ajax_post_id'] . '" data-cats="' . $GLOBALS['ghostpool_ajax_cats'] . '" data-hubfieldslugs="' . $GLOBALS['ghostpool_ajax_hub_field_slugs'] . '" data-postassociation="' . $GLOBALS['ghostpool_ajax_post_association'] . '" data-posttypes="' . $GLOBALS['ghostpool_ajax_post_types'] . '" data-format="' . $GLOBALS['ghostpool_ajax_format'] . '" data-size="' . $GLOBALS['ghostpool_ajax_size'] . '" data-orderby="' . $GLOBALS['ghostpool_ajax_orderby'] . '" data-dateposted="' . $GLOBALS['ghostpool_ajax_date_posted'] . '" data-datemodified="' . $GLOBALS['ghostpool_ajax_date_modified'] . '" data-perpage="' . $GLOBALS['ghostpool_ajax_per_page'] . '" data-menuperpage="' . $GLOBALS['ghostpool_ajax_menu_per_page'] . '" data-offset="' . $GLOBALS['ghostpool_ajax_offset'] . '" data-featuredimage="' . $GLOBALS['ghostpool_ajax_featured_image'] . '" data-imagewidth="' . $GLOBALS['ghostpool_ajax_image_width'] . '" data-imageheight="' . $GLOBALS['ghostpool_ajax_image_height'] . '" data-hardcrop="' . $GLOBALS['ghostpool_ajax_hard_crop'] . '" data-imagealignment="' . $GLOBALS['ghostpool_ajax_image_alignment'] . '" data-titleposition="' . $GLOBALS['ghostpool_ajax_title_position'] . '" data-contentdisplay="' . $GLOBALS['ghostpool_ajax_content_display'] . '" data-excerptlength="' . $GLOBALS['ghostpool_ajax_excerpt_length'] . '" data-metaauthor="' . $GLOBALS['ghostpool_ajax_meta_author'] . '" data-metadate="' . $GLOBALS['ghostpool_ajax_meta_date'] . '" data-metacommentcount="' . $GLOBALS['ghostpool_ajax_meta_comment_count'] . '" data-metaviews="' . $GLOBALS['ghostpool_ajax_meta_views'] . '" data-metafollowers="' . $GLOBALS['ghostpool_ajax_meta_followers'] . '" data-metacats="' . $GLOBALS['ghostpool_ajax_meta_cats'] . '" data-metatags="' . $GLOBALS['ghostpool_ajax_meta_tags'] . '" data-metahubcats="' . $GLOBALS['ghostpool_ajax_meta_hub_cats'] . '" data-metahubfields="' . $GLOBALS['ghostpool_ajax_meta_hub_fields'] . '" data-metahubaward="' . $GLOBALS['ghostpool_ajax_meta_hub_award'] . '" data-hubcatsselected="' . $GLOBALS['ghostpool_ajax_hub_cats_selected'] . '" data-displaysiterating="' . $GLOBALS['ghostpool_ajax_display_site_rating'] . '" data-displayuserrating="' . $GLOBALS['ghostpool_ajax_display_user_rating'] . '" data-readmorelink="' . $GLOBALS['ghostpool_ajax_read_more_link'] . '" data-pagenumbers="' . $GLOBALS['ghostpool_ajax_page_numbers'] . '" data-authorid="' . $GLOBALS['ghostpool_ajax_author_id'] . '"';
}
}
if ( ! function_exists( 'ghostpool_register_ajax' ) ) {
function ghostpool_register_ajax() {
global $query_string;
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-mediaelement' );
wp_enqueue_script( 'gp-flexslider' );
// Determine http or https for admin-ajax.php URL
if ( is_ssl() ) { $gp_scheme = 'https'; } else { $gp_scheme = 'http'; }
wp_enqueue_script( 'ajax-loop', ghostpool_scripts_uri . 'ajax-loop.js', array( 'jquery' ) );
wp_localize_script( 'ajax-loop', 'ghostpoolAjax', array(
'ajaxurl' => admin_url( 'admin-ajax.php', $gp_scheme ),
'ajaxnonce' => wp_create_nonce( 'gp-ajax-nonce' ),
'querystring' => $query_string,
) );
}
}
add_action( 'wp_enqueue_scripts', 'ghostpool_register_ajax' );
if ( ! function_exists( 'ghostpool_ajax' ) ) {
function ghostpool_ajax() {
global $gp;
if ( ! wp_verify_nonce( $_GET['ajaxnonce'], 'gp-ajax-nonce' ) )
die();
// Pagination
$gp_pagination = ( isset( $_GET['pagenumber'] ) ) ? $_GET['pagenumber'] : 0;
// Get theme options from ajax values
$GLOBALS['ghostpool_cats'] = isset( $_GET['cats'] ) ? $_GET['cats'] : '';
$GLOBALS['ghostpool_hub_field_slugs'] = isset( $_GET['hubfieldslugs'] ) ? $_GET['hubfieldslugs'] : '';
$GLOBALS['ghostpool_post_types'] = isset( $_GET['posttypes'] ) ? $_GET['posttypes'] : '';
$GLOBALS['ghostpool_format'] = isset( $_GET['format'] ) ? $_GET['format'] : '';
$GLOBALS['ghostpool_size'] = isset( $_GET['size'] ) ? $_GET['size'] : '';
$GLOBALS['ghostpool_orderby'] = isset( $_GET['orderby'] ) ? $_GET['orderby'] : '';
$GLOBALS['ghostpool_date_posted'] = isset( $_GET['dateposted'] ) ? $_GET['dateposted'] : '';
$GLOBALS['ghostpool_date_modified'] = isset( $_GET['datemodified'] ) ? $_GET['datemodified'] : '';
$GLOBALS['ghostpool_per_page'] = isset( $_GET['perpage'] ) ? $_GET['perpage'] : '';
$GLOBALS['ghostpool_menu_per_page'] = isset( $_GET['menuperpage'] ) ? $_GET['menuperpage'] : '';
$GLOBALS['ghostpool_offset'] = isset( $_GET['offset'] ) ? $_GET['offset'] : '';
$GLOBALS['ghostpool_featured_image'] = isset( $_GET['featuredimage'] ) ? $_GET['featuredimage'] : '';
$GLOBALS['ghostpool_image_width'] = isset( $_GET['imagewidth'] ) ? $_GET['imagewidth'] : '';
$GLOBALS['ghostpool_image_height'] = isset( $_GET['imageheight'] ) ? $_GET['imageheight'] : '';
$GLOBALS['ghostpool_hard_crop'] = isset( $_GET['hardcrop'] ) ? $_GET['hardcrop'] : '';
$GLOBALS['ghostpool_image_alignment'] = isset( $_GET['imagealignment'] ) ? $_GET['imagealignment'] : '';
$GLOBALS['ghostpool_title_position'] = isset( $_GET['titleposition'] ) ? $_GET['titleposition'] : '';
$GLOBALS['ghostpool_content_display'] = isset( $_GET['contentdisplay'] ) ? $_GET['contentdisplay'] : '';
$GLOBALS['ghostpool_excerpt_length'] = isset( $_GET['excerptlength'] ) ? $_GET['excerptlength'] : 0;
$GLOBALS['ghostpool_meta_author'] = isset( $_GET['metaauthor'] ) ? $_GET['metaauthor'] : '';
$GLOBALS['ghostpool_meta_date'] = isset( $_GET['metadate'] ) ? $_GET['metadate'] : '';
$GLOBALS['ghostpool_meta_comment_count'] = isset( $_GET['metacommentcount'] ) ? $_GET['metacommentcount'] : '';
$GLOBALS['ghostpool_meta_views'] = isset( $_GET['metaviews'] ) ? $_GET['metaviews'] : '';
$GLOBALS['ghostpool_meta_followers'] = isset( $_GET['metafollowers'] ) ? $_GET['metafollowers'] : '';
$GLOBALS['ghostpool_meta_cats'] = isset( $_GET['metacats'] ) ? $_GET['metacats'] : '';
$GLOBALS['ghostpool_meta_tags'] = isset( $_GET['metatags'] ) ? $_GET['metatags'] : '';
$GLOBALS['ghostpool_meta_hub_cats'] = isset( $_GET['metahubcats'] ) ? $_GET['metahubcats'] : '';
$GLOBALS['ghostpool_meta_hub_fields'] = isset( $_GET['metahubfields'] ) ? $_GET['metahubfields'] : '';
$GLOBALS['ghostpool_meta_hub_award'] = isset( $_GET['metahubaward'] ) ? $_GET['metahubaward'] : '';
$GLOBALS['ghostpool_hub_cats_selected'] = isset( $_GET['hubcatsselected'] ) ? explode( ',', $_GET['hubcatsselected'] ) : '';
$GLOBALS['ghostpool_display_site_rating'] = isset( $_GET['displaysiterating'] ) ? $_GET['displaysiterating'] : '';
$GLOBALS['ghostpool_display_user_rating'] = isset( $_GET['displayuserrating'] ) ? $_GET['displayuserrating'] : '';
$GLOBALS['ghostpool_read_more_link'] = isset( $_GET['readmorelink'] ) ? $_GET['readmorelink'] : '';
$GLOBALS['ghostpool_page_numbers'] = isset( $_GET['pagenumbers'] ) ? $_GET['pagenumbers'] : '';
$GLOBALS['ghostpool_author_id'] = isset( $_GET['authorid'] ) ? $_GET['authorid'] : '';
// Post Type
if ( $_GET['type'] == 'news' OR $_GET['type'] == 'news-template' OR $_GET['type'] == 'videos' OR $_GET['type'] == 'videos-template' ) {
$gp_post_type = 'post';
} elseif ( $_GET['type'] == 'user-reviews' ) {
$gp_post_type = 'gp_user_review';
} else {
$gp_post_type = explode( ',', $GLOBALS['ghostpool_post_types'] );
}
// Use filtered category is selected
if ( isset( $_GET['cats_new'] ) && $_GET['cats_new'] != '0' ) {
$GLOBALS['ghostpool_cats'] = $_GET['cats_new'];
}
// Use filtered menu category is selected
if ( isset( $_GET['menu_cats_new'] ) && $_GET['menu_cats_new'] != '0' ) {
$GLOBALS['ghostpool_cats'] = $_GET['menu_cats_new'];
}
// Use filtered orderby if selected
if ( isset( $_GET['orderby_new'] ) && $_GET['orderby_new'] != '0' ) {
$GLOBALS['ghostpool_orderby'] = $_GET['orderby_new'];
}
// Use filtered date posted if selected
if ( isset( $_GET['date_posted_new'] ) && $_GET['date_posted_new'] != '0' ) {
$GLOBALS['ghostpool_date_posted'] = $_GET['date_posted_new'];
}
// Use filtered date modified if selected
if ( isset( $_GET['date_modified_new'] ) && $_GET['date_modified_new'] != '0' ) {
$GLOBALS['ghostpool_date_modified'] = $_GET['date_modified_new'];
}
ghostpool_query_variables();
// Get blog posts associated with hub
if ( ( $_GET['type'] == 'blog' && $_GET['postassociation'] != 'disabled' && ( get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-template.php' OR get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-review-template.php' ) ) OR ( $_GET['type'] == 'blog-template' && get_post_meta( $_GET['postid'], 'blog_template_post_association', true ) == 'enabled' ) ) {
$GLOBALS['ghostpool_meta_query'] = array( 'relation' => 'OR', array( 'key' => 'post_association', 'value' => sprintf( ' "%s" ', $_GET['postid'] ), 'compare' => 'LIKE' ), array( 'key' => '_hub_page_id', 'value' => $_GET['postid'], 'compare' => '=' ) );
// Removed since v6.0
//$GLOBALS['ghostpool_meta_key'] = 'post_association';
}
// Get news posts associated with hub
if ( ( $_GET['type'] == 'news' && $_GET['postassociation'] != 'disabled' && ( get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-template.php' OR get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-review-template.php' ) ) OR ( $_GET['type'] == 'news-template' && get_post_meta( $_GET['postid'], 'news_post_association', true ) != 'disabled' ) ) {
$GLOBALS['ghostpool_meta_query'] = array( 'relation' => 'OR', array( 'key' => 'post_association', 'value' => sprintf( ' "%s" ', $_GET['postid'] ), 'compare' => 'LIKE' ), array( 'key' => '_hub_page_id', 'value' => $_GET['postid'], 'compare' => '=' ) );
// Removed since v6.0
//$GLOBALS['ghostpool_meta_key'] = 'post_association';
}
echo get_post_meta( $_GET['postid'], 'news_post_association', true );
// Get video posts associated with hub
if ( ( $_GET['type'] == 'videos' && $_GET['postassociation'] != 'disabled' && ( get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-template.php' OR get_post_meta( $_GET['postid'], '_wp_page_template', true ) == 'hub-review-template.php' ) ) OR ( $_GET['type'] == 'videos-template' && get_post_meta( $_GET['postid'], 'videos_post_association', true ) != 'disabled' ) ) {
$GLOBALS['ghostpool_meta_query'] = array( 'relation' => 'OR', array( 'key' => 'post_association', 'value' => sprintf( ' "%s" ', $_GET['postid'] ), 'compare' => 'LIKE' ), array( 'key' => '_hub_page_id', 'value' => $_GET['postid'], 'compare' => '=' ) );
// Removed since v6.0
//$GLOBALS['ghostpool_meta_key'] = 'post_association';
}
// Hub fields
if ( $_GET['type'] == 'blog' ) {
$gp_hub_field_args = '';
if ( $_GET['hubfieldslugs'] ) {
// Put hub fields into an array
$gp_hub_fields_array = explode( ',', $GLOBALS['ghostpool_hub_field_slugs'] );
foreach ( $gp_hub_fields_array as $gp_hub_field ) {
// Get taxonomy e.g. genre
$gp_taxonomy = strstr( $gp_hub_field, ':', true );
// Get terms e.g. horror, romance
$gp_terms = strstr( $gp_hub_field, ':', false );
// Remove : from front of terms
$gp_terms = ltrim( $gp_terms, ':' );
// Put list of terms into an array
$gp_terms = explode( ':', $gp_terms );
// Hub field tax query
$gp_hub_field_args[] = array(
'taxonomy' => $gp_taxonomy,
'field' => 'slug',
'terms' => $gp_terms,
'operator' => 'AND',
);
}
}
}
// Tax query
if ( $_GET['type'] == 'news' OR $_GET['type'] == 'news-template' ) {
$gp_tax_query = array( 'relation' => 'AND', $GLOBALS['ghostpool_post_cats'], array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-quote', 'post-format-audio', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-video' ), 'operator' => 'NOT IN' ) );
} elseif ( $_GET['type'] == 'videos' OR $_GET['type'] == 'videos-template' ) {
$gp_tax_query = array( 'relation' => 'AND', $GLOBALS['ghostpool_video_cats'], array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-video' ) ) );
} elseif ( $_GET['type'] == 'blog-template' OR $_GET['type'] == 'menu' ) {
$gp_tax_query = $GLOBALS['ghostpool_tax'];
} elseif ( $_GET['type'] == 'blog' ) {
$gp_tax_query = array(
$GLOBALS['ghostpool_tax'],
array(
'relation' => 'AND',
$gp_hub_field_args,
),
);
} else {
$gp_tax_query = '';
}
// Query
if ( $_GET['type'] == 'taxonomy' ) {
$gp_defaults = array(
'meta_query' => $GLOBALS['ghostpool_meta_query'],
'orderby' => $GLOBALS['ghostpool_orderby_value'],
'date_query' => array( $GLOBALS['ghostpool_date_posted_value'], $GLOBALS['ghostpool_date_modified_value'] ),
);
$gp_args = $_GET['querystring'] . "&post_status=publish&order=" . $GLOBALS['ghostpool_order'] . "&meta_key=" . $GLOBALS['ghostpool_meta_key'] . "&posts_per_page=" . $GLOBALS['ghostpool_per_page'] . "&paged=$gp_pagination";
$gp_args = wp_parse_args( $gp_args, $gp_defaults );
} elseif ( $_GET['type'] == 'author' ) {
$gp_args = array(
'post_status' => 'publish',
'post_type' => array( 'post', 'page', 'gp_user_review' ),
'author' => $GLOBALS['ghostpool_author_id'],
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_wp_page_template',
'value' => array( 'hub-template.php', 'hub-review-template.php', 'review-template.php' ),
'compare' => 'IN',
),
array(
'key' => '_wp_page_template',
'compare' => 'NOT EXISTS',
),
),
'orderby' => $GLOBALS['ghostpool_orderby_value'],
'order' => $GLOBALS['ghostpool_order'],
'posts_per_page' => $GLOBALS['ghostpool_per_page'],
'paged' => $gp_pagination,
'date_query' => array( $GLOBALS['ghostpool_date_posted_value'], $GLOBALS['ghostpool_date_modified_value'] ),
);
} elseif ( $_GET['type'] == 'menu' ) {
$gp_args = array(
'post_status' => 'publish',
'post_type' => array( 'post', 'page' ),
'tax_query' => $gp_tax_query,
'orderby' => 'date',
'order' => 'desc',
'posts_per_page' => $GLOBALS['ghostpool_menu_per_page'],
'paged' => $gp_pagination,
);
} else {
$gp_args = array(
'post_status' => 'publish',
'post_type' => $gp_post_type,
'tax_query' => $gp_tax_query,
'orderby' => $GLOBALS['ghostpool_orderby_value'],
'order' => $GLOBALS['ghostpool_order'],
'meta_query' => $GLOBALS['ghostpool_meta_query'],
'meta_key' => $GLOBALS['ghostpool_meta_key'],
'posts_per_page' => $GLOBALS['ghostpool_per_page'],
'offset' => $GLOBALS['ghostpool_offset'],
'paged' => $gp_pagination,
'date_query' => array( $GLOBALS['ghostpool_date_posted_value'], $GLOBALS['ghostpool_date_modified_value'] ),
);
}
//print_r($gp_args);
$gp_query = new wp_query( $gp_args );
if ( $gp_query->have_posts() ) :
$gp_total_pages = $gp_query->max_num_pages;
// Pagination (Arrows)
if ( $gp_total_pages > 1 && $_GET['type'] == 'menu' ) {
echo '<div class="gp-ajax-pagination gp-pagination-arrows">';
if ( $gp_pagination > 1 ) {
echo '<a href="#" data-pagelink="' . ( $gp_pagination - 1 ) . '" class="prev"></a>';
}
if ( $gp_pagination < $gp_total_pages ) {
echo '<a href="#" data-pagelink="' . ( $gp_pagination + 1 ) . '" class="next"></a>';
}
echo '</div>';
}
while ( $gp_query->have_posts() ) : $gp_query->the_post(); ?>
<?php if ( $_GET['type'] == 'menu' ) {
// Post link
if ( get_post_format() == 'link' ) {
$gp_link = esc_url( get_post_meta( get_the_ID(), 'link', true ) );
} else {
$gp_link = get_permalink();
}
echo '<section class="' . implode( ' ' , get_post_class( 'gp-post-item' ) ) . '">';
if ( has_post_thumbnail() ) {
$gp_image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 198, 125, true, false, true );
if ( $gp['retina'] == 'gp-retina' ) {
$gp_retina = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 198 * 2, 125 * 2, true, true, true );
} else {
$gp_retina = '';
}
echo '<div class="gp-post-thumbnail"><div class="gp-image-above">
<a href="' . $gp_link . '" title="' . ghostpool_prefix_hub_title( get_the_ID() ) . '" target="' . get_post_meta( get_the_ID(), 'link_target', true ) . '">
<img src="' . $gp_image[0] . '" data-rel="' . $gp_retina . '" width="' . $gp_image[1] . '" height="' . $gp_image[2] . '" alt="' . ghostpool_prefix_hub_title( get_the_ID() ) . '" class="gp-post-image" />
</a>
</div></div>';
}
echo '<h2 class="gp-loop-title"><a href="' . $gp_link . '" title="' . ghostpool_prefix_hub_title( get_the_ID() ) . '" target="' . get_post_meta( get_the_ID(), 'link_target', true ) . '">' . ghostpool_prefix_hub_title( get_the_ID() ) . '</a></h2>
</section>';
} elseif ( get_post_meta( get_the_ID(), '_wp_page_template', true ) == 'review-template.php' OR get_post_meta( get_the_ID(), '_wp_page_template', true ) == 'hub-template.php' OR get_post_meta( get_the_ID(), '_wp_page_template', true ) == 'hub-review-template.php' OR get_post_meta( get_the_ID(), '_user_review_rating', true ) ) {
get_template_part( 'review', 'loop' );
} else {
get_template_part( 'post', 'loop' );
} ?>
<?php endwhile; ?>
<?php
// Pagination (Numbers)
if ( $gp_total_pages > 1 && $_GET['type'] != 'menu' && $GLOBALS['ghostpool_page_numbers'] == 'enabled' ) {
echo '<div class="gp-pagination gp-pagination-numbers gp-ajax-pagination">';
echo paginate_links(array(
'base' => '%_%',
'format' => '/page/%#%',
'current' => $gp_pagination,
'total' => $gp_total_pages,
'type' => 'list',
'prev_text' => '',
'next_text' => '',
'end_size' => 1,
'mid_size' => 1,
));
echo '</div>';
}
?>
<?php else : ?>
<strong class="gp-no-items-found"><?php esc_html_e( 'No items found.', 'gauge' ); ?></strong>
<?php endif; wp_reset_postdata();
die();
}
}
add_action( 'wp_ajax_ghostpool_ajax', 'ghostpool_ajax' );
add_action( 'wp_ajax_nopriv_ghostpool_ajax', 'ghostpool_ajax' );
?> |