Skip to content

Commit d7712b2

Browse files
committed
Between Filter
1 parent 3f47ec0 commit d7712b2

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ This project is licensed under the GPL3 License.
269269

270270
### 0.5 "xxx"
271271

272-
* xxx
273272
* Feature: Closing Filter
274273
* Feature: Move Forward Label Filter
275274
* Feature: Move Backward Label Filter
276275
* Feature: Before Loop Filter
277276
* Feature: After Loop Filter
278277
* Feature: Mastodon Logo Filter
278+
* Feature: Between Filter
279279

280280
### 0.4 "Cassie Lang"
281281

tootpress_blog.php

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function tootpress_paint_preamble($tootpress_current_page) {
171171

172172
if($tootpress_current_page==1) {
173173

174-
$preamble.=tootpress_preamble_filter_apply($preamble);
174+
$preamble=tootpress_preamble_filter_apply($preamble);
175175

176176
if($preamble) {
177177
$preamble='<div class="tootpress-preamble">'.$preamble.'</div>';
@@ -216,13 +216,15 @@ function tootpress_paint_closing($tootpress_current_page) {
216216
*
217217
* @since 0.5
218218
*
219+
* @param string empty
219220
* @param int TootPress Current Page
220221
* @return string Content
221222
*/
222223

223224
function tootpress_paint_beforeloop($tootpress_current_page) {
224225

225-
$content=tootpress_beforeloop_filter_apply($tootpress_current_page);
226+
$content='';
227+
$content=tootpress_beforeloop_filter_apply($content, $tootpress_current_page);
226228

227229
if($content) {
228230
$content='<div class="tootpress-beforeloop">'.$content.'</div>';
@@ -237,13 +239,15 @@ function tootpress_paint_beforeloop($tootpress_current_page) {
237239
*
238240
* @since 0.5
239241
*
242+
* @param string empty
240243
* @param int TootPress Current Page
241244
* @return string Content
242245
*/
243246

244247
function tootpress_paint_afterloop($tootpress_current_page) {
245248

246-
$content=tootpress_afterloop_filter_apply($tootpress_current_page);
249+
$content='';
250+
$content=tootpress_afterloop_filter_apply($content, $tootpress_current_page);
247251

248252
if($content) {
249253
$content='<div class="tootpress-afterloop">'.$content.'</div>';
@@ -253,4 +257,29 @@ function tootpress_paint_afterloop($tootpress_current_page) {
253257

254258
}
255259

260+
/**
261+
* Create the Between Element.
262+
*
263+
* @since 0.5
264+
*
265+
* @param int Open Loops
266+
* @return string Between Element
267+
*/
268+
269+
function tootpress_paint_between($open_loops) {
270+
271+
$content='';
272+
273+
if ($open_loops>1) {
274+
$content=tootpress_between_filter_apply($content);
275+
}
276+
277+
if($content) {
278+
$content='<div class="tootpress-between">'.$content.'</div>';
279+
}
280+
281+
return $content;
282+
283+
}
284+
256285
?>

tootpress_hooks.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function tootpress_fire_toots_update() {
3838
*
3939
* @since 0.4
4040
*
41-
* @param string Empty Preample
42-
* @return html Filtered Preample
41+
* @param string Empty
42+
* @return string Filtered Preample
4343
*/
4444

4545
function tootpress_preamble_filter_apply($preamble) {
@@ -54,7 +54,7 @@ function tootpress_preamble_filter_apply($preamble) {
5454
*
5555
* @since 0.5
5656
*
57-
* @param string Empty Content
57+
* @param string Empty
5858
* @return string Filtered Content
5959
*/
6060

@@ -103,13 +103,13 @@ function tootpress_menu_backward_filter_apply($label) {
103103
*
104104
* @since 0.5
105105
*
106+
* @param string empty
106107
* @param int TootPress Current Page Number
107108
* @return string Content
108109
*/
109110

110-
function tootpress_beforeloop_filter_apply($current_page_number) {
111+
function tootpress_beforeloop_filter_apply($content, $current_page_number) {
111112

112-
$content='';
113113
$last_page_number=tootpress_amount_of_pages();
114114

115115
$content=apply_filters( 'tootpress_beforeloop_filter', $content, $current_page_number, $last_page_number );
@@ -125,13 +125,13 @@ function tootpress_beforeloop_filter_apply($current_page_number) {
125125
*
126126
* @since 0.5
127127
*
128+
* @param string empty
128129
* @param int TootPress Current Page Number
129130
* @return string Content
130131
*/
131132

132-
function tootpress_afterloop_filter_apply($current_page_number) {
133+
function tootpress_afterloop_filter_apply($content, $current_page_number) {
133134

134-
$content='';
135135
$last_page_number=tootpress_amount_of_pages();
136136

137137
$content=apply_filters( 'tootpress_afterloop_filter', $content, $current_page_number, $last_page_number );
@@ -155,4 +155,20 @@ function tootpress_mastodon_logo_filter_apply($img) {
155155
return $img;
156156
}
157157

158+
/**
159+
* Between Filter
160+
*
161+
* This filter adds custom HTML between the toots
162+
*
163+
* @since 0.5
164+
*
165+
* @param string Empty
166+
* @return string Between Content
167+
*/
168+
169+
function tootpress_between_filter_apply($content) {
170+
$content=apply_filters( 'tootpress_between_filter', $content );
171+
return $content;
172+
}
173+
158174
?>

tootpress_loop.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function tootpress_loop($range) {
8080
$toot_cache=array();
8181
$toot_cache=tootpress_get_toots_from_database($amount_toots_page, $range);
8282
$amount_toots_cache=count($toot_cache);
83+
$open_loops=$amount_toots_cache;
8384

8485
// Get Configuration
8586
$mastodon_instance=tootpress_get_mastodon_instance();
@@ -94,6 +95,12 @@ function tootpress_loop($range) {
9495
// Paint
9596
$tootloop.=tootpress_paint_toot( $toot['toot_mastodon_id'], $toot['toot_date'], $toot['toot_content'], $toot['toot_media'], $mastodon_instance, $mastodon_account, $tootpress_backlink);
9697

98+
// Between Filter
99+
$tootloop.=tootpress_paint_between($open_loops);
100+
101+
// -1
102+
$open_loops=($open_loops-1);
103+
97104
}
98105

99106
}

0 commit comments

Comments
 (0)