PluginProbe
ActivityPub / 8.3.0
ActivityPub v8.3.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
activitypub / includes / wp-admin / class-advanced-settings-fields.php

class-advanced-settings-fields.php in ActivityPub 8.3.0, at includes/wp-admin/class-advanced-settings-fields.php

292 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Advanced Settings Fields file.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\WP_Admin;
9
10 /**
11 * Advanced Settings Fields class.
12 */
13 class Advanced_Settings_Fields {
14
15 /**
16 * Initialize.
17 */
18 public static function init() {
19 \add_action( 'load-settings_page_activitypub', array( self::class, 'register_advanced_fields' ) );
20 }
21
22 /**
23 * Register settings.
24 */
25 public static function register_advanced_fields() {
26 \add_settings_section(
27 'activitypub_advanced_settings',
28 \__( 'Advanced Settings', 'activitypub' ),
29 array( self::class, 'render_advanced_settings_section' ),
30 'activitypub_advanced_settings'
31 );
32
33 if ( ! defined( 'ACTIVITYPUB_SEND_VARY_HEADER' ) ) {
34 \add_settings_field(
35 'activitypub_vary_header',
36 \__( 'Vary Header', 'activitypub' ),
37 array( self::class, 'render_vary_header_field' ),
38 'activitypub_advanced_settings',
39 'activitypub_advanced_settings',
40 array( 'label_for' => 'activitypub_vary_header' )
41 );
42 }
43
44 \add_settings_field(
45 'activitypub_content_negotiation',
46 \__( 'Content Negotiation', 'activitypub' ),
47 array( self::class, 'render_content_negotiation_field' ),
48 'activitypub_advanced_settings',
49 'activitypub_advanced_settings',
50 array( 'label_for' => 'activitypub_content_negotiation' )
51 );
52
53 if ( ! defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) ) {
54 \add_settings_field(
55 'activitypub_authorized_fetch',
56 \__( 'Authorized Fetch', 'activitypub' ),
57 array( self::class, 'render_authorized_fetch_field' ),
58 'activitypub_advanced_settings',
59 'activitypub_advanced_settings',
60 array( 'label_for' => 'activitypub_authorized_fetch' )
61 );
62 }
63
64 \add_settings_field(
65 'activitypub_rfc9421_signature',
66 \__( 'Modern Signature Format', 'activitypub' ),
67 array( self::class, 'render_rfc9421_signature_field' ),
68 'activitypub_advanced_settings',
69 'activitypub_advanced_settings',
70 array( 'label_for' => 'activitypub_rfc9421_signature' )
71 );
72
73 \add_settings_field(
74 'activitypub_following_ui',
75 \__( 'Following User Interface', 'activitypub' ),
76 array( self::class, 'render_following_ui_field' ),
77 'activitypub_advanced_settings',
78 'activitypub_advanced_settings',
79 array( 'label_for' => 'activitypub_following_ui' )
80 );
81
82 if ( \version_compare( \get_bloginfo( 'version' ), '6.9-alpha', '>=' ) ) {
83 \add_settings_field(
84 'activitypub_reader_ui',
85 \__( 'Reader', 'activitypub' ),
86 array( self::class, 'render_reader_field' ),
87 'activitypub_advanced_settings',
88 'activitypub_advanced_settings',
89 array( 'label_for' => 'activitypub_reader_ui' )
90 );
91 }
92
93 \add_settings_field(
94 'activitypub_api',
95 \__( 'ActivityPub API', 'activitypub' ),
96 array( self::class, 'render_api_field' ),
97 'activitypub_advanced_settings',
98 'activitypub_advanced_settings',
99 array( 'label_for' => 'activitypub_api' )
100 );
101
102 \add_settings_field(
103 'activitypub_object_type',
104 \__( 'Activity-Object-Type', 'activitypub' ),
105 array( self::class, 'render_object_type_field' ),
106 'activitypub_advanced_settings',
107 'activitypub_advanced_settings',
108 array( 'label_for' => 'activitypub_object_type' )
109 );
110 }
111
112 /**
113 * Render Advanced Settings Section.
114 */
115 public static function render_advanced_settings_section() {
116 ?>
117 <p>
118 <?php
119 $allowed_html = array(
120 'a' => array(
121 'href' => true,
122 'target' => true,
123 ),
124 );
125 echo \wp_kses( \__( 'Advanced settings allow deep customization but can affect your site&#8217;s functionality, security, or performance if misconfigured. Only proceed if you fully understand the changes, and always back up your site beforehand. If unsure, consult <a href="https://github.com/Automattic/wordpress-activitypub/tree/trunk/docs" target="_blank">documentation</a> or seek <a href="https://wordpress.org/support/plugin/activitypub/" target="_blank">expert advice</a>.', 'activitypub' ), $allowed_html );
126 ?>
127 </p>
128 <?php
129 }
130
131 /**
132 * Render vary header field.
133 */
134 public static function render_vary_header_field() {
135 $value = \get_option( 'activitypub_vary_header', '1' );
136 ?>
137 <p>
138 <label>
139 <input type="checkbox" id="activitypub_vary_header" name="activitypub_vary_header" value="1" <?php checked( '1', $value ); ?> />
140 <?php echo \wp_kses( \__( 'Help prevent incorrect caching of ActivityPub responses.', 'activitypub' ), array( 'code' => array() ) ); ?>
141 </label>
142 </p>
143 <p class="description">
144 <?php \esc_html_e( 'Enable this if you notice your site showing technical content instead of normal web pages, or if your ActivityPub connections seem unreliable. This setting helps your site deliver the right format of content to different services automatically.', 'activitypub' ); ?>
145 </p>
146 <?php
147 }
148
149 /**
150 * Render content negotiation field.
151 */
152 public static function render_content_negotiation_field() {
153 $value = \get_option( 'activitypub_content_negotiation', '1' );
154 ?>
155 <p>
156 <label>
157 <input type="checkbox" id="activitypub_content_negotiation" name="activitypub_content_negotiation" value="1" <?php checked( '1', $value ); ?> />
158 <?php \esc_html_e( 'Enable content negotiation for browsers and Fediverse services.', 'activitypub' ); ?>
159 </label>
160 </p>
161 <p class="description">
162 <?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' ); ?>
163 </p>
164 <?php
165 }
166
167 /**
168 * Render use Authorized Fetch field.
169 */
170 public static function render_authorized_fetch_field() {
171 $value = \get_option( 'activitypub_authorized_fetch', '0' );
172 ?>
173 <p>
174 <label>
175 <input type="checkbox" id="activitypub_authorized_fetch" name="activitypub_authorized_fetch" value="1" <?php checked( '1', $value ); ?> />
176 <?php \esc_html_e( 'Require HTTP signature authentication on ActivityPub representations of public posts and profiles.', 'activitypub' ); ?>
177 </label>
178 </p>
179 <p class="description">
180 <?php \esc_html_e( '⚠ Secure mode has its limitations, which is why it is not enabled by default. It is not fully supported by all software in the fediverse, and some features may break, especially when interacting with Mastodon servers older than version 3.0. Additionally, since it requires authentication for public content, caching is not possible, leading to higher computational costs.', 'activitypub' ); ?>
181 </p>
182 <p class="description">
183 <?php \esc_html_e( '⚠ Secure mode does not hide the HTML representations of public posts and profiles. While HTML is a less consistent format (that potentially changes often) compared to first-class ActivityPub representations or the REST API, it still poses a potential risk for content scraping.', 'activitypub' ); ?>
184 </p>
185 <?php
186 }
187
188 /**
189 * Render RFC-9421 signature field.
190 */
191 public static function render_rfc9421_signature_field() {
192 $value = \get_option( 'activitypub_rfc9421_signature', '0' );
193 ?>
194 <p>
195 <label>
196 <input type="checkbox" id="activitypub_rfc9421_signature" name="activitypub_rfc9421_signature" value="1" <?php checked( '1', $value ); ?> />
197 <?php \esc_html_e( 'Use modern signature format for Fediverse communications.', 'activitypub' ); ?>
198 </label>
199 </p>
200 <p class="description">
201 <?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' ); ?>
202 </p>
203 <?php
204 }
205
206 /**
207 * Render show following UI field.
208 */
209 public static function render_following_ui_field() {
210 $value = \get_option( 'activitypub_following_ui', '0' );
211 ?>
212 <p>
213 <label>
214 <input type="checkbox" id="activitypub_following_ui" name="activitypub_following_ui" value="1" <?php checked( '1', $value ); ?> />
215 Display the "Following" interface in the admin menus and settings.
216 </label>
217 </p>
218 <p class="description">
219 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.
220 </p>
221 <p class="description">
222 ⚠ 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.
223 </p>
224 <?php
225 }
226
227 /**
228 * Render reader field.
229 */
230 public static function render_reader_field() {
231 $value = \get_option( 'activitypub_reader_ui', '0' );
232 ?>
233 <p>
234 <label>
235 <input type="checkbox" id="activitypub_reader_ui" name="activitypub_reader_ui" value="1" <?php checked( '1', $value ); ?> />
236 Enable the Reader to view posts from accounts you follow.
237 </label>
238 </p>
239 <p class="description">
240 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.
241 </p>
242 <p class="description">
243 ⚠ This feature is experimental and may change significantly in future updates.
244 </p>
245 <?php
246 }
247
248 /**
249 * Render ActivityPub API field.
250 */
251 public static function render_api_field() {
252 $value = \get_option( 'activitypub_api', '0' );
253 ?>
254 <p>
255 <label>
256 <input type="checkbox" id="activitypub_api" name="activitypub_api" value="1" <?php \checked( '1', $value ); ?> />
257 <?php \esc_html_e( 'Enable the ActivityPub API to connect third-party clients.', 'activitypub' ); ?>
258 </label>
259 </p>
260 <p class="description">
261 <?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' ); ?>
262 </p>
263 <p class="description">
264 <?php
265 echo \wp_kses(
266 \__( '⚠ This feature is experimental and may change significantly in future updates.', 'activitypub' ),
267 'data'
268 );
269 ?>
270 </p>
271 <?php
272 }
273
274 /**
275 * Render object type field.
276 */
277 public static function render_object_type_field() {
278 $value = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
279 ?>
280 <p>
281 <label>
282 <input type="checkbox" name="activitypub_object_type" value="note" <?php \checked( 'note', $value ); ?> />
283 <?php \esc_html_e( 'Use Template Tags instead of letting the plugin choose the best possible format for you.', 'activitypub' ); ?>
284 </label>
285 </p>
286 <p class="description">
287 <?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' ); ?>
288 </p>
289 <?php
290 }
291 }
292