Skip to content

Commit fa072e8

Browse files
authored
Merge pull request #26 from circuscode/develop
Version 0.4
2 parents c74f69d + ad9e1c0 commit fa072e8

File tree

6 files changed

+162
-8
lines changed

6 files changed

+162
-8
lines changed

readme.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,36 @@ TootPress creates 2 folders within the WordPress Uploads Directory.
9999

100100
## TootPress API
101101

102-
WordPress Action: tootpress_toots_update (fired on toot update)
102+
### Actions
103+
104+
#### tootpress_toots_update
105+
106+
This action will be fired after toot update to execute custom post-processing.
107+
You can use the following code.
108+
109+
function tootpress_toots_update_postprocessing() {
110+
111+
// Add your code to be executed here
112+
113+
}
114+
add_action('tootpress_toots_update', 'tootpress_toots_update_postprocessing');
115+
116+
### Filter
117+
118+
#### tootpress_preamble_add
119+
120+
This filter outputs html content before the toot loop.
121+
You can use the following code.
122+
123+
function tootpress_preamble_add( $preamble ) {
124+
125+
// Add your filter code here
126+
// Example: $preamble='<p>Hello World.</p>';
127+
128+
return $preamble;
129+
130+
}
131+
add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 );
103132

104133
## WordPress Framework
105134

@@ -116,6 +145,7 @@ Following components of WordPress are used in TootPress.
116145
* File Functions
117146
* Content Functions
118147
* Escaping Functions
148+
* Hooks
119149

120150
## Frequently Asked Questions
121151

@@ -177,6 +207,11 @@ This project is licensed under the GPL3 License.
177207

178208
## Changelog
179209

210+
### 0.4 "Cassie Lang"
211+
212+
* June 2024
213+
* Feature: Preamble Filter
214+
180215
### 0.3 "Deadpool"
181216

182217
* April 2024

readme.txt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: unmus
33
Tags: mastodon, toots, microblogging, blog, fediverse
44
Requires at least: 6.1
55
Tested up to: 6.5
6-
Stable tag: 0.3
6+
Stable tag: 0.4
77
License: GNU General Public License v3 or later
88
License URI: https://www.gnu.org/licenses/gpl-3.0.html
99

@@ -105,7 +105,30 @@ TootPress creates 2 folders within the WordPress Uploads Directory.
105105

106106
= TootPress API =
107107

108-
WordPress Action: tootpress_toots_update (fired on toot update)
108+
**Action: tootpress_toots_update**
109+
It will be fired after toot update to execute custom post-processing.
110+
You can use the following code.
111+
112+
`function tootpress_toots_update_postprocessing() {`
113+
``
114+
` // Add your code to be executed here`
115+
``
116+
`}`
117+
`add_action('tootpress_toots_update', 'tootpress_toots_update_postprocessing');`
118+
119+
**Filter: tootpress_preamble_add**
120+
It outputs html content before the toot loop.
121+
You can use the following code.
122+
123+
`function tootpress_preamble_add( $preamble ) {`
124+
``
125+
` // Add your filter code here`
126+
` // Example: $preamble='<p>Hello World.</p>';`
127+
``
128+
` return $preamble;`
129+
``
130+
`}`
131+
`add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 );`
109132

110133
= Related Links =
111134

@@ -142,6 +165,11 @@ No. TootPress does not support the WordPress Multisite Feature. The plugin is wo
142165

143166
== Changelog ==
144167

168+
= 0.4 "Cassie Lang" =
169+
170+
* June 2024
171+
* Feature: Preamble Filter
172+
145173
= 0.3 "Deadpool" =
146174

147175
* April 2024
@@ -172,6 +200,9 @@ No. TootPress does not support the WordPress Multisite Feature. The plugin is wo
172200

173201
== Upgrade Notice ==
174202

203+
= 0.4 =
204+
This version includes a preamble filter.
205+
175206
= 0.3 =
176207
This version brings gallery support and contains major bugfixes.
177208

tootpress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Plugin Name: TootPress
55
Description: TootPress copies your Toots from Mastodon to WordPress.
6-
Version: 0.3
6+
Version: 0.4
77
Author: Marco Hitschler
88
Author URI: https://www.unmus.de/
99
License: GPL3

tootpress_blog.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,31 @@ function tootpress_paint_elephant( $instance, $account, $mastodon_id, $backlink)
154154

155155
}
156156

157+
/**
158+
* Creates the Preamble
159+
*
160+
* @since 0.4
161+
*
162+
* @param int TootPress Current Page
163+
* @return string html
164+
*/
165+
166+
function tootpress_paint_preamble($tootpress_current_page) {
167+
168+
$preamble='';
169+
170+
if($tootpress_current_page==1) {
171+
172+
$preamble.=tootpress_preamble_filter_apply($preamble);
173+
174+
if($preamble) {
175+
$preamble='<div class="tootpress-preamble">'.$preamble.'</div>';
176+
}
177+
178+
}
179+
180+
return $preamble;
181+
182+
}
183+
157184
?>

tootpress_hooks.php

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,74 @@
1111
if (!defined('ABSPATH')) { exit; }
1212

1313
/**
14-
* Fires hook when new toots are loaded
14+
* Actions
15+
*/
16+
17+
/**
18+
* Fires when new toots are loaded
1519
*
16-
* This hook can be used by other plugins.
17-
* For example: Refresh Cache
20+
* This hook can be used by other plugins to process after load functions.
21+
* For example: Cache Refresh
1822
*
1923
* @since 0.1
2024
*/
2125

22-
function tootpress_fire_toots_update() {
26+
function tootpress_fire_toots_update() {
2327
do_action( 'tootpress_toots_update' );
2428
}
2529

30+
/**
31+
* Action Example: tootpress_toots_update
32+
*
33+
* @since 0.4
34+
*
35+
* function tootpress_toots_update_postprocessing() {
36+
*
37+
* // Add your code to be executed here
38+
*
39+
* }
40+
* add_action('tootpress_toots_update', 'tootpress_toots_update_postprocessing');
41+
*
42+
*/
43+
44+
/**
45+
* Filter
46+
*/
47+
48+
/**
49+
* Preample
50+
*
51+
* This filter outputs html content before the toot loop.
52+
*
53+
* @since 0.4
54+
*
55+
* @param string Unfiltered Preample
56+
* @return html Filtered Preample
57+
*/
58+
59+
function tootpress_preamble_filter_apply($preamble) {
60+
$preamble.=apply_filters( 'tootpress_preamble_filter', $preamble );
61+
return $preamble;
62+
}
63+
64+
/**
65+
* Filter Example: tootpress_preamble_filter
66+
*
67+
* @since 0.4
68+
*
69+
* @param string Unfiltered Preample
70+
* @return html Filtered Preample
71+
*
72+
* function tootpress_preamble_add( $preamble ) {
73+
*
74+
* // Add your filter code here
75+
* // Example: $preamble='<p>Hello World.</p>';
76+
*
77+
* return $preamble;
78+
*
79+
* }
80+
* add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 );
81+
*
82+
*/
83+
2684
?>

tootpress_loop.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ function tootpress_content($content) {
3232
// TootPress Content
3333
$tootpress_content='<div id="tootpress-area">';
3434

35+
// TootPress Preamble
36+
$tootpress_content.=tootpress_paint_preamble($tootpress_current_page);
37+
3538
// TootPress Loop
3639
$tootpress_content.=tootpress_loop($tootpress_current_page);
3740

0 commit comments

Comments
 (0)