-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
72 lines (65 loc) · 1.6 KB
/
functions.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
<?php
/**
* Get the posts that make up the social stream
* @return array
*/
function get_social_stream() {
global $ss_stream;
return $ss_stream->fetch();
}
/**
* Render the social stream using the default template
* @return void
*/
function the_social_stream() {
$posts = get_social_stream();
$theme_file = get_stylesheet_directory().'/social_stream.php';
if(file_exists($theme_file)) {
require_once $theme_file;
} else {
require_once __DIR__.'/views/social_stream.php';
}
}
/**
* Pull out the social stream via Ajax
* @return void
*/
function ajax_social_stream() {
require_once __DIR__.'/views/loader.php';
}
/**
* Check if it's a Twitter post
* @param array $post Post from the social stream
* @return boolean
*/
function is_twitter_post($post) {
return (isset($post['retweet_count']));
}
/**
* Check if it's a Facebook post
* @param array $post Post from the social stream
* @return boolean
*/
function is_facebook_post($post) {
return (isset($post['created_time']));
}
/**
* Pull out an array of Twitter posts on their own
* @param int $number Number or twitter posts to pull out
* @return array
*/
function twitter_posts($number) {
global $ss_stream;
$chunks = array_chunk($ss_stream->twitter->fetch()->posts, $number);
return $chunks[0];
}
/**
* Pull out an array of Facebook posts on their own
* @param int $number Number or posts posts to pull out
* @return array
*/
function facebook_posts($number) {
global $ss_stream;
$chunks = array_chunk($ss_stream->facebook->fetch()->posts, $number);
return $chunks[0];
}