-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtootpress_loop.php
96 lines (69 loc) · 2.13 KB
/
tootpress_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
<?php
/**
* Loop
*
* @package TootPress
* @since 0.1
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Starts TootPres in the Blog
*
* @since 0.1
*
* @param html Content WordPress
* @return html Content TootPress or WordPress
*/
function tootpress_content($content) {
// Should we toot here?
// Are any Toots in the Database?
// Is this the FrontEnd?
if (tootpress_toot_here() & tootpress_are_toots_in_the_database() & !is_admin()) {
// TootPress Paging
$tootpress_current_page=tootpress_get_query_var();
// TootPress Content
$tootpress_content='<div id="tootpress-area">';
// TootPress Preamble
$tootpress_content.=tootpress_paint_preamble($tootpress_current_page);
// TootPress Loop
$tootpress_content.=tootpress_loop($tootpress_current_page);
// TootPress Bottom Navigation
$tootpress_content.=tootpress_create_menu($tootpress_current_page);
// TootPress End
$tootpress_content.='</div>';
return $tootpress_content;
} else {
return $content;
}
}
add_filter ('the_content', 'tootpress_content');
/**
* TootPress Loop
*
* @since 0.1
*
* @param int TootPress Page Numnber
* @return html Toots
*/
function tootpress_loop($range) {
$tootloop='';
$amount_toots_page=get_option('tootpress_amount_toots_page');
// Read Toots
$toot_cache=array();
$toot_cache=tootpress_get_toots_from_database($amount_toots_page, $range);
$amount_toots_cache=count($toot_cache);
// Get Configuration
$mastodon_instance=tootpress_get_mastodon_instance();
$mastodon_account=tootpress_get_mastodon_account_name();
$tootpress_backlink=tootpress_get_backlink_option();
// Loop
if($amount_toots_cache>0) {
foreach($toot_cache as $toot) {
// Paint
$tootloop.=tootpress_paint_toot( $toot['toot_mastodon_id'], $toot['toot_date'], $toot['toot_content'], $toot['toot_media'], $mastodon_instance, $mastodon_account, $tootpress_backlink);
}
}
return $tootloop;
}
?>