Skip to content

Commit ae8d342

Browse files
committed
Before Loop Filter
1 parent 64e69ea commit ae8d342

File tree

5 files changed

+95
-2
lines changed

5 files changed

+95
-2
lines changed

readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ You can use the following code.
175175
}
176176
add_filter( 'tootpress_menu_backward_label', 'tootpress_menu_backward_label_change', 10, 1 );
177177

178+
#### tootpress_beforeloop_filter
179+
180+
This filter outputs content before the toot loop (on all tootpress pages).
181+
You can use the following code.
182+
183+
function tootpress_beforeloop_filter_add( $content, $page_number ) {
184+
185+
// Add your filter code here
186+
// Example: $content='<p>Page '.$page_number.'</p>';
187+
188+
return $label;
189+
190+
}
191+
add_filter( 'tootpress_beforeloop_filter', 'tootpress_beforeloop_filter_add', 10, 2 );
192+
178193
## WordPress Framework
179194

180195
Following components of WordPress are used in TootPress.
@@ -258,6 +273,7 @@ This project is licensed under the GPL3 License.
258273
* Feature: Closing Filter
259274
* Feature: Move Forward Label Filter
260275
* Feature: Move Backward Label Filter
276+
* Feature: Before Loop Filter
261277

262278
### 0.4 "Cassie Lang"
263279

readme.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ You can use the following code.
172172
`}`
173173
`add_filter( 'tootpress_menu_backward_label', 'tootpress_menu_backward_label_change', 10, 1 );`
174174

175+
**Filter: tootpress_beforeloop_filter**
176+
This filter outputs content before the toot loop (on all tootpress pages).
177+
You can use the following code.
178+
179+
`function tootpress_beforeloop_filter_add( $content, $page_number ) {`
180+
``
181+
` // Add your filter code here`
182+
` // Example: $content='<p>Page '.$page_number.'</p>';`
183+
``
184+
` return $label;`
185+
``
186+
`}`
187+
`add_filter( 'tootpress_beforeloop_filter', 'tootpress_beforeloop_filter_add', 10, 2 );`
188+
175189
= Related Links =
176190

177191
* [Source Code @ GitHub](https://github.com/circuscode/tootpress)

tootpress_blog.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,25 @@ function tootpress_paint_closing($tootpress_current_page) {
209209

210210
}
211211

212+
/**
213+
* Create the Before Loop Content.
214+
*
215+
* @since 0.5
216+
*
217+
* @param int TootPress Current Page
218+
* @return string Content
219+
*/
220+
221+
function tootpress_paint_beforeloop($tootpress_current_page) {
222+
223+
$content=tootpress_beforeloop_filter_apply($tootpress_current_page);
224+
225+
if($content) {
226+
$content='<div class="tootpress-beforeloop">'.$content.'</div>';
227+
}
228+
229+
return $content;
230+
231+
}
232+
212233
?>

tootpress_hooks.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,44 @@ function tootpress_menu_backward_filter_apply($label) {
184184
* add_filter( 'tootpress_menu_backward_label', 'tootpress_menu_backward_label_change', 10, 1 );
185185
*
186186
*/
187-
187+
188+
/**
189+
* Before Loop Filter
190+
*
191+
* This filter outputs content before the toot loop.
192+
* It will be applied on all tootpress pages.
193+
*
194+
* @since 0.5
195+
*
196+
* @param int TootPress Page Number
197+
* @return string Content
198+
*/
199+
200+
function tootpress_beforeloop_filter_apply($page_number) {
201+
202+
$content='';
203+
204+
$content=apply_filters( 'tootpress_beforeloop_filter', $content, $page_number );
205+
206+
return $content;
207+
}
208+
209+
/**
210+
* Usage Example: tootpress_beforeloop_filter
211+
*
212+
* @param string Content (empty)
213+
* @param int TootPress Page Number
214+
* @return string Content (filtered)
215+
*
216+
* function tootpress_beforeloop_filter_add( $content, $page_number ) {
217+
*
218+
* // Add your filter code here
219+
* // Example: $content='<p>Page '.$page_number.'</p>';
220+
*
221+
* return $content;
222+
*
223+
* }
224+
* add_filter( 'tootpress_beforeloop_filter', 'tootpress_beforeloop_filter_add', 10, 2 );
225+
*/
226+
188227
?>

tootpress_loop.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ function tootpress_content($content) {
3535
// TootPress Preamble
3636
$tootpress_content.=tootpress_paint_preamble($tootpress_current_page);
3737

38+
// TootPress Before Loop
39+
$tootpress_content.=tootpress_paint_beforeloop($tootpress_current_page);
40+
3841
// TootPress Loop
3942
$tootpress_content.=tootpress_loop($tootpress_current_page);
4043

41-
// TootPress Afterloop
44+
// TootPress Closing
4245
$tootpress_content.=tootpress_paint_closing($tootpress_current_page);
4346

4447
// TootPress Bottom Navigation

0 commit comments

Comments
 (0)