-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtootpress_hooks.php
More file actions
257 lines (212 loc) · 5.11 KB
/
tootpress_hooks.php
File metadata and controls
257 lines (212 loc) · 5.11 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
/**
* Hooks
*
* @package TootPress
* @since 0.1
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Actions
*/
/**
* Fires when new toots are loaded
*
* This action will be fired after toot update to execute custom post-processing.
* For example: Cache Refresh
*
* @since 0.1
*/
function tootpress_fire_toots_update() {
do_action( 'tootpress_toots_update' );
}
/**
* Filter
*/
/**
* Preample
*
* This filter outputs html content before the initial toot loop.
*
* @since 0.4
*
* @param string Preamble
* @return html Filtered Preamble
*/
function tootpress_preamble_filter_apply($preamble) {
$preamble=apply_filters( 'tootpress_preamble_filter', $preamble );
$preamble=wp_kses_post($preamble);
return $preamble;
}
/**
* Closing Filter
*
* This filter outputs content after the last toot loop.
*
* @since 0.5
*
* @param string Closing
* @return html Filtered Closing
*/
function tootpress_closing_filter_apply($content) {
$content=apply_filters( 'tootpress_closing_filter', $content );
$content=wp_kses_post($content);
return $content;
}
/**
* Move Forward Filter
*
* This filter overwrites the forward label in the menu
*
* @since 0.5
*
* @param string Original Label
* @return string New Label
*/
function tootpress_menu_forward_filter_apply($label) {
$label=apply_filters( 'tootpress_menu_forward_label', $label );
$label=esc_html($label);
return $label;
}
/**
* Move Backward Filter
*
* This filter overwrites the backward label in the menu
*
* @since 0.5
*
* @param string Original Label
* @return string New Label
*/
function tootpress_menu_backward_filter_apply($label) {
$label=apply_filters( 'tootpress_menu_backward_label', $label );
$label=esc_html($label);
return $label;
}
/**
* Before Loop Filter
*
* This filter outputs content before the toot loop.
* It will be applied on all tootpress pages.
*
* @since 0.5
*
* @param string Content
* @param int TootPress Current Page Number
* @return html Content
*/
function tootpress_beforeloop_filter_apply($content, $current_page_number) {
$last_page_number=tootpress_amount_of_pages();
$content=apply_filters( 'tootpress_beforeloop_filter', $content, $current_page_number, $last_page_number );
$content=wp_kses_post($content);
return $content;
}
/**
* After Loop Filter
*
* This filter outputs content after the toot loop.
* It will be applied on all tootpress pages.
*
* @since 0.5
*
* @param string Content
* @param int TootPress Current Page Number
* @return html Content
*/
function tootpress_afterloop_filter_apply($content, $current_page_number) {
$last_page_number=tootpress_amount_of_pages();
$content=apply_filters( 'tootpress_afterloop_filter', $content, $current_page_number, $last_page_number );
$content=wp_kses_post($content);
return $content;
}
/**
* Mastodon Logo Filter
*
* This filter overwrites the Mastodon Logo with Custom Logo
*
* @since 0.5
*
* @param html Mastodon Logo
* @return html Custom Logo
*/
function tootpress_mastodon_logo_filter_apply($img) {
$img=apply_filters( 'tootpress_mastodon_logo_filter', $img );
$img=wp_kses_post($img);
return $img;
}
/**
* Between Filter
*
* This filter adds custom HTML between the toots
*
* @since 0.5
*
* @param string Content
* @return html Between Content
*/
function tootpress_between_filter_apply($content) {
$content=apply_filters( 'tootpress_between_filter', $content );
$content=wp_kses_post($content);
return $content;
}
/**
* Toot Content Filter
*
* This filter can be used to manipulate the toot content
*
* @since 0.5
*
* @param html Content
* @return html Filtered Content
*/
function tootpress_toot_content_filter_apply($content) {
$content=apply_filters( 'tootpress_toot_content_filter', $content );
$content=wp_kses_post($content);
return $content;
}
/**
* Date Filter
*
* This filter overwrites the date output with custom format
*
* @since 0.5
*
* @param string Date
* @return string Custom Format
*/
function tootpress_date_filter_apply($date) {
// 2023-05-30 22:40:28
$year=substr($date,0,4);
$month=substr($date,5,2);
$day=substr($date,8,2);
$hour=substr($date,11,2);
$minute=substr($date,14,2);
$second=substr($date,17,2);
$date=apply_filters( 'tootpress_date_filter', $date, $year, $month, $day, $hour, $minute, $second );
$date=esc_html($date);
return $date;
}
/**
* Image Filter
*
* This filter can be used to manipulate image tags
*
* @since 0.5
*
* @param html Image Tag
* @param string Image File Name
* @param string Image Description
* @param int Image Width
* @param int Image Height
* @param url TootPress Image Directory
* @param int Amount of Images
* @param int Image Number
* @return html Filtered Image Tag
*/
function tootpress_image_filter_apply($img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number) {
$img_tag=apply_filters( 'tootpress_image_filter',$img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number);
$img_tag=wp_kses_post($img_tag);
return $img_tag;
}
?>