/
ajax_browse.php
48 lines (37 loc) · 1.14 KB
/
ajax_browse.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
<?
require_once ('../../../wp-config.php');
$tag = (int)$_GET['tag'];
$cat = (int)$_GET['cat'];
$year = $_GET['year'] == 'All' ? 'All' : intval($_GET['year']);
$orderby = get_opt_or_default('mosaicdesc') ? 'DESC' : 'ASC';
if ($year && $year == 'All') {
query_posts('showposts=-1&order='.$orderby);
} elseif ($year) {
query_posts('year='.$year.'&showposts=-1&order='.$orderby);
} elseif ($cat) {
query_posts('cat='.$cat.'&showposts=-1&order='.$orderby);
} else {
$tag = get_tag($tag);
$slug = $tag->slug;
query_posts('tag='.$slug.'&showposts=-1&order='.$orderby);
}
$posts = array();
$tips = get_opt_or_default('mosaictips');
while(have_posts()) {
the_post();
if (($imageuri = square_thumb($post->ID)) === false)
continue;
$topush = array(
'image_uri' => str_replace("&", "&", $imageuri),
'post_title' => $post->post_title,
'post_date' => get_the_time('jS F Y'),
'permalink' => get_permalink($post->ID)
);
if ($tips) {
$topush['comment_status'] = $post->comment_status;
$topush['comment_count'] = $post->comment_count;
}
array_push($posts, $topush);
}
echo json_encode($posts);
?>