PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/wp-admin/class-advanced-settings-fields.php +46 -258 9.2.0 → 5.7.0 View file →
@@ -1,15 +1,13 @@
1 1 <?php
2 2 /**
3 3 * Advanced Settings Fields file.
4 4 *
5 - * @package Activitypub
5 + * @package ActivityPub
6 6 */
7 7
8 -namespace Activitypub\WP_Admin;
8 +namespace ActivityPub\WP_Admin;
9 9
10 -use Activitypub\Options;
11 -
12 10 /**
13 11 * Advanced Settings Fields class.
14 12 */
15 13 class Advanced_Settings_Fields {
@@ -31,31 +29,18 @@
31 29 array( self::class, 'render_advanced_settings_section' ),
32 30 'activitypub_advanced_settings'
33 31 );
34 32
35 - if ( ! Options::is_distribution_mode_locked() ) {
36 - \add_settings_field(
37 - 'activitypub_distribution_mode',
38 - \__( 'Distribution Mode', 'activitypub' ),
39 - array( self::class, 'render_distribution_mode_field' ),
40 - 'activitypub_advanced_settings',
41 - 'activitypub_advanced_settings'
42 - );
33 + \add_settings_field(
34 + 'activitypub_outbox_purge_days',
35 + \__( 'Outbox Retention Period', 'activitypub' ),
36 + array( self::class, 'render_outbox_purge_days_field' ),
37 + 'activitypub_advanced_settings',
38 + 'activitypub_advanced_settings',
39 + array( 'label_for' => 'activitypub_outbox_purge_days' )
40 + );
43 41
44 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended
45 - $current_tab = isset( $_GET['tab'] ) ? \sanitize_key( \wp_unslash( $_GET['tab'] ) ) : '';
46 - if ( 'advanced' === $current_tab ) {
47 - \wp_enqueue_script(
48 - 'activitypub-distribution-mode',
49 - \plugins_url( 'assets/js/activitypub-distribution-mode.js', ACTIVITYPUB_PLUGIN_FILE ),
50 - array(),
51 - ACTIVITYPUB_PLUGIN_VERSION,
52 - true
53 - );
54 - }
55 - }
56 -
57 - if ( ! \defined( 'ACTIVITYPUB_SEND_VARY_HEADER' ) ) {
42 + if ( ! defined( 'ACTIVITYPUB_SEND_VARY_HEADER' ) ) {
58 43 \add_settings_field(
59 44 'activitypub_vary_header',
60 45 \__( 'Vary Header', 'activitypub' ),
61 46 array( self::class, 'render_vary_header_field' ),
@@ -64,18 +49,9 @@
64 49 array( 'label_for' => 'activitypub_vary_header' )
65 50 );
66 51 }
67 52
68 - \add_settings_field(
69 - 'activitypub_content_negotiation',
70 - \__( 'Content Negotiation', 'activitypub' ),
71 - array( self::class, 'render_content_negotiation_field' ),
72 - 'activitypub_advanced_settings',
73 - 'activitypub_advanced_settings',
74 - array( 'label_for' => 'activitypub_content_negotiation' )
75 - );
76 -
77 - if ( ! \defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) ) {
53 + if ( ! defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) ) {
78 54 \add_settings_field(
79 55 'activitypub_authorized_fetch',
80 56 \__( 'Authorized Fetch', 'activitypub' ),
81 57 array( self::class, 'render_authorized_fetch_field' ),
@@ -84,55 +60,18 @@
84 60 array( 'label_for' => 'activitypub_authorized_fetch' )
85 61 );
86 62 }
87 63
88 - \add_settings_field(
89 - 'activitypub_rfc9421_signature',
90 - \__( 'Modern Signature Format', 'activitypub' ),
91 - array( self::class, 'render_rfc9421_signature_field' ),
92 - 'activitypub_advanced_settings',
93 - 'activitypub_advanced_settings',
94 - array( 'label_for' => 'activitypub_rfc9421_signature' )
95 - );
96 -
97 - \add_settings_field(
98 - 'activitypub_following_ui',
99 - \__( 'Following User Interface', 'activitypub' ),
100 - array( self::class, 'render_following_ui_field' ),
101 - 'activitypub_advanced_settings',
102 - 'activitypub_advanced_settings',
103 - array( 'label_for' => 'activitypub_following_ui' )
104 - );
105 -
106 - // Only offer the Reader opt-in where the app can actually boot (WordPress 7.0+).
107 - if ( App::is_supported() ) {
64 + if ( ! defined( 'ACTIVITYPUB_SHARED_INBOX_FEATURE' ) ) {
108 65 \add_settings_field(
109 - 'activitypub_reader_ui',
110 - \__( 'Reader', 'activitypub' ),
111 - array( self::class, 'render_reader_field' ),
66 + 'activitypub_shared_inbox',
67 + \__( 'Shared Inbox (beta)', 'activitypub' ),
68 + array( self::class, 'render_shared_inbox_field' ),
112 69 'activitypub_advanced_settings',
113 70 'activitypub_advanced_settings',
114 - array( 'label_for' => 'activitypub_reader_ui' )
71 + array( 'label_for' => 'activitypub_shared_inbox' )
115 72 );
116 73 }
117 -
118 - \add_settings_field(
119 - 'activitypub_api',
120 - \__( 'ActivityPub API', 'activitypub' ),
121 - array( self::class, 'render_api_field' ),
122 - 'activitypub_advanced_settings',
123 - 'activitypub_advanced_settings',
124 - array( 'label_for' => 'activitypub_api' )
125 - );
126 -
127 - \add_settings_field(
128 - 'activitypub_object_type',
129 - \__( 'Activity-Object-Type', 'activitypub' ),
130 - array( self::class, 'render_object_type_field' ),
131 - 'activitypub_advanced_settings',
132 - 'activitypub_advanced_settings',
133 - array( 'label_for' => 'activitypub_object_type' )
134 - );
135 74 }
136 75
137 76 /**
138 77 * Render Advanced Settings Section.
@@ -153,16 +92,36 @@
153 92 <?php
154 93 }
155 94
156 95 /**
96 + * Render outbox purge days field.
97 + */
98 + public static function render_outbox_purge_days_field() {
99 + $value = \get_option( 'activitypub_outbox_purge_days', 180 );
100 + echo '<input type="number" id="activitypub_outbox_purge_days" name="activitypub_outbox_purge_days" value="' . esc_attr( $value ) . '" class="small-text" min="0" max="365" />';
101 + echo '<p class="description">' . \wp_kses(
102 + sprintf(
103 + // translators: 1: Definition of Outbox; 2: Default value (180).
104 + \__( 'Maximum number of days to keep items in the <abbr title="%1$s">Outbox</abbr>. A lower value might be better for sites with lots of activity to maintain site performance. Default: <code>%2$s</code>', 'activitypub' ),
105 + \esc_attr__( 'A virtual location on a user&#8217;s profile where all the activities (posts, likes, replies) they publish are stored, acting as a feed that other users can access to see their publicly shared content', 'activitypub' ),
106 + \esc_html( 180 )
107 + ),
108 + array(
109 + 'abbr' => array( 'title' => array() ),
110 + 'code' => array(),
111 + )
112 + ) . '</p>';
113 + }
114 +
115 + /**
157 116 * Render vary header field.
158 117 */
159 118 public static function render_vary_header_field() {
160 - $value = \get_option( 'activitypub_vary_header', '1' );
119 + $value = \get_option( 'activitypub_vary_header', '0' );
161 120 ?>
162 121 <p>
163 122 <label>
164 - <input type="checkbox" id="activitypub_vary_header" name="activitypub_vary_header" value="1" <?php \checked( '1', $value ); ?> />
123 + <input type="checkbox" id="activitypub_vary_header" name="activitypub_vary_header" value="1" <?php checked( '1', $value ); ?> />
165 124 <?php echo \wp_kses( \__( 'Help prevent incorrect caching of ActivityPub responses.', 'activitypub' ), array( 'code' => array() ) ); ?>
166 125 </label>
167 126 </p>
168 127 <p class="description">
@@ -171,26 +130,8 @@
171 130 <?php
172 131 }
173 132
174 133 /**
175 - * Render content negotiation field.
176 - */
177 - public static function render_content_negotiation_field() {
178 - $value = \get_option( 'activitypub_content_negotiation', '1' );
179 - ?>
180 - <p>
181 - <label>
182 - <input type="checkbox" id="activitypub_content_negotiation" name="activitypub_content_negotiation" value="1" <?php \checked( '1', $value ); ?> />
183 - <?php \esc_html_e( 'Enable content negotiation for browsers and Fediverse services.', 'activitypub' ); ?>
184 - </label>
185 - </p>
186 - <p class="description">
187 - <?php \esc_html_e( 'Content negotiation ensures your site displays regular web pages to browsers and machine-readable data to Fediverse services. Disable this if your site shows raw technical data to visitors or if ActivityPub connections have issues.', 'activitypub' ); ?>
188 - </p>
189 - <?php
190 - }
191 -
192 - /**
193 134 * Render use Authorized Fetch field.
194 135 */
195 136 public static function render_authorized_fetch_field() {
196 137 $value = \get_option( 'activitypub_authorized_fetch', '0' );
@@ -196,9 +137,9 @@
196 137 $value = \get_option( 'activitypub_authorized_fetch', '0' );
197 138 ?>
198 139 <p>
199 140 <label>
200 - <input type="checkbox" id="activitypub_authorized_fetch" name="activitypub_authorized_fetch" value="1" <?php \checked( '1', $value ); ?> />
141 + <input type="checkbox" id="activitypub_authorized_fetch" name="activitypub_authorized_fetch" value="1" <?php checked( '1', $value ); ?> />
201 142 <?php \esc_html_e( 'Require HTTP signature authentication on ActivityPub representations of public posts and profiles.', 'activitypub' ); ?>
202 143 </label>
203 144 </p>
204 145 <p class="description">
@@ -210,174 +151,21 @@
210 151 <?php
211 152 }
212 153
213 154 /**
214 - * Render RFC-9421 signature field.
155 + * Render shared inbox field.
215 156 */
216 - public static function render_rfc9421_signature_field() {
217 - $value = \get_option( 'activitypub_rfc9421_signature', '0' );
157 + public static function render_shared_inbox_field() {
158 + $value = \get_option( 'activitypub_shared_inbox', '0' );
218 159 ?>
219 160 <p>
220 161 <label>
221 - <input type="checkbox" id="activitypub_rfc9421_signature" name="activitypub_rfc9421_signature" value="1" <?php \checked( '1', $value ); ?> />
222 - <?php \esc_html_e( 'Use modern signature format for Fediverse communications.', 'activitypub' ); ?>
162 + <input type="checkbox" id="activitypub_shared_inbox" name="activitypub_shared_inbox" value="1" <?php checked( '1', $value ); ?> />
163 + <?php \esc_html_e( 'Use a shared inbox for incoming messages.', 'activitypub' ); ?>
223 164 </label>
224 165 </p>
225 166 <p class="description">
226 - <?php \esc_html_e( 'Enables a newer standard (RFC-9421) for verifying your site&#8217;s identity when communicating with other Fediverse platforms. This alternative signature format may cause compatibility issues with platforms that do not support it. Keep disabled if you experience connection problems with certain Fediverse servers.', 'activitypub' ); ?>
167 + <?php \esc_html_e( 'Allows your site to handle incoming ActivityPub messages more efficiently, especially helpful for busy or multi-user sites. This feature is still in beta and may encounter issues.', 'activitypub' ); ?>
227 168 </p>
228 - <?php
229 - }
230 -
231 - /**
232 - * Render show following UI field.
233 - */
234 - public static function render_following_ui_field() {
235 - $value = \get_option( 'activitypub_following_ui', '0' );
236 - ?>
237 - <p>
238 - <label>
239 - <input type="checkbox" id="activitypub_following_ui" name="activitypub_following_ui" value="1" <?php \checked( '1', $value ); ?> />
240 - Display the "Following" interface in the admin menus and settings.
241 - </label>
242 - </p>
243 - <p class="description">
244 - Activates the Following feature, letting you follow other ActivityPub accounts directly from your WordPress site. Adds a "Following" menu and tab to manage followed accounts.
245 - </p>
246 - <p class="description">
247 - ⚠ A reader interface is not available yet. Please follow accounts sparingly—you won't be able to see their posts or shares. This feature is intended for testing the follow functionality. Once fully implemented, it will be enabled by default.
248 - </p>
249 - <?php
250 - }
251 -
252 - /**
253 - * Render reader field.
254 - */
255 - public static function render_reader_field() {
256 - $value = \get_option( 'activitypub_reader_ui', '0' );
257 - ?>
258 - <p>
259 - <label>
260 - <input type="checkbox" id="activitypub_reader_ui" name="activitypub_reader_ui" value="1" <?php \checked( '1', $value ); ?> />
261 - Enable the Reader to view posts from accounts you follow.
262 - </label>
263 - </p>
264 - <p class="description">
265 - Adds a "Social Web" interface where you can read posts and shares from accounts you follow. Also enables the Following feature. Look for it in Dashboard > Social Web.
266 - </p>
267 - <p class="description">
268 - âš  This feature is experimental and may change significantly in future updates.
269 - </p>
270 - <?php
271 - }
272 -
273 - /**
274 - * Render ActivityPub API field.
275 - */
276 - public static function render_api_field() {
277 - $value = \get_option( 'activitypub_api', '0' );
278 - ?>
279 - <p>
280 - <label>
281 - <input type="checkbox" id="activitypub_api" name="activitypub_api" value="1" <?php \checked( '1', $value ); ?> />
282 - <?php \esc_html_e( 'Enable the ActivityPub API to connect third-party clients.', 'activitypub' ); ?>
283 - </label>
284 - </p>
285 - <p class="description">
286 - <?php \esc_html_e( 'Enables OAuth 2.0 authentication so third-party ActivityPub clients (like Mastodon apps) can post, follow, and interact on your behalf. You can manage connected apps from your profile page.', 'activitypub' ); ?>
287 - </p>
288 - <p class="description">
289 - <?php
290 - echo \wp_kses(
291 - \__( 'âš  This feature is experimental and may change significantly in future updates.', 'activitypub' ),
292 - 'data'
293 - );
294 - ?>
295 - </p>
296 - <?php
297 - }
298 -
299 - /**
300 - * Render object type field.
301 - */
302 - public static function render_object_type_field() {
303 - $value = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
304 - ?>
305 - <p>
306 - <label>
307 - <input type="checkbox" name="activitypub_object_type" value="note" <?php \checked( 'note', $value ); ?> />
308 - <?php \esc_html_e( 'Use Template Tags instead of letting the plugin choose the best possible format for you.', 'activitypub' ); ?>
309 - </label>
310 - </p>
311 - <p class="description">
312 - <?php \esc_html_e( 'This is mainly for backwards compatibility. It is not recommended to use the Template Tags, because it might not be supported in future versions.', 'activitypub' ); ?>
313 - </p>
314 - <?php
315 - }
316 -
317 - /**
318 - * Render distribution mode field.
319 - *
320 - * @since 9.0.0
321 - */
322 - public static function render_distribution_mode_field() {
323 - $mode = \get_option( 'activitypub_distribution_mode', 'default' );
324 -
325 - // Use centralized presets and add the custom option for the UI.
326 - $modes = Options::get_distribution_modes();
327 - $modes['custom'] = array(
328 - 'label' => \__( 'Custom', 'activitypub' ),
329 - 'description' => \__( 'Configure batch size and delay manually.', 'activitypub' ),
330 - );
331 -
332 - // Custom fields fall back to the default preset values when unset.
333 - $custom_batch = \get_option( 'activitypub_custom_batch_size', $modes['default']['batch_size'] );
334 - $custom_pause = \get_option( 'activitypub_custom_batch_pause', $modes['default']['pause'] );
335 -
336 - ?>
337 - <fieldset>
338 - <legend class="screen-reader-text"><span><?php \esc_html_e( 'Distribution Mode', 'activitypub' ); ?></span></legend>
339 - <p class="description">
340 - <?php \esc_html_e( 'Controls how quickly the plugin sends posts to followers. Slower modes reduce server load but delay delivery.', 'activitypub' ); ?>
341 - </p>
342 - <?php
343 - foreach ( $modes as $key => $data ) {
344 - ?>
345 - <p>
346 - <label>
347 - <input type="radio" name="activitypub_distribution_mode" value="<?php echo \esc_attr( $key ); ?>" <?php \checked( $key, $mode ); ?> />
348 - <strong><?php echo \esc_html( $data['label'] ); ?></strong>
349 - </label>
350 - <br />
351 - <?php echo \wp_kses( $data['description'], array( 'code' => array() ) ); ?>
352 - </p>
353 - <?php
354 - }
355 -
356 - /*
357 - * The custom fields are rendered visible so they remain usable when
358 - * JavaScript is disabled. The accompanying script collapses them on
359 - * page load when the active mode is not "custom" and toggles them
360 - * as the radio changes.
361 - */
362 - ?>
363 - <ul id="activitypub-custom-distribution-fields">
364 - <li>
365 - <label>
366 - <?php \esc_html_e( 'Batch size:', 'activitypub' ); ?>
367 - <input type="number" name="activitypub_custom_batch_size" value="<?php echo \esc_attr( $custom_batch ); ?>" min="1" step="1" class="small-text" />
368 - </label>
369 - </li>
370 - <li>
371 - <label>
372 - <?php \esc_html_e( 'Pause between batches (seconds):', 'activitypub' ); ?>
373 - <input type="number" name="activitypub_custom_batch_pause" value="<?php echo \esc_attr( $custom_pause ); ?>" min="0" step="1" class="small-text" />
374 - </label>
375 - </li>
376 - </ul>
377 - <p class="description">
378 - <?php \esc_html_e( 'With many followers, slower modes may delay delivery. For example, Eco Mode with 1,000 followers takes approximately 25 minutes per post.', 'activitypub' ); ?>
379 - </p>
380 - </fieldset>
381 169 <?php
382 170 }
383 171 }