PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.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-settings-fields.php +114 -302 9.2.07.7.0 View file →
@@ -6,12 +6,10 @@
6 6 */
7 7
8 8 namespace Activitypub\WP_Admin;
9 9
10 -use Activitypub\Blocklist_Subscriptions;
11 10 use Activitypub\Moderation;
12 11
13 -use function Activitypub\get_post_type_description;
14 12 use function Activitypub\home_host;
15 13
16 14 /**
17 15 * Class Settings_Fields.
@@ -20,9 +18,9 @@
20 18 /**
21 19 * Initialize the settings fields.
22 20 */
23 21 public static function init() {
24 - \add_action( 'load-settings_page_activitypub', array( self::class, 'register_settings_fields' ) );
22 + add_action( 'load-settings_page_activitypub', array( self::class, 'register_settings_fields' ) );
25 23 }
26 24
27 25 /**
28 26 * Register settings fields.
@@ -28,51 +26,47 @@
28 26 * Register settings fields.
29 27 */
30 28 public static function register_settings_fields() {
31 29 // Add settings sections.
32 - \add_settings_section(
30 + add_settings_section(
33 31 'activitypub_profiles',
34 - \__( 'Profiles', 'activitypub' ),
32 + __( 'Profiles', 'activitypub' ),
35 33 '__return_empty_string',
36 34 'activitypub_settings'
37 35 );
38 36
39 - \add_settings_section(
37 + add_settings_section(
40 38 'activitypub_activities',
41 - \__( 'Activities', 'activitypub' ),
39 + __( 'Activities', 'activitypub' ),
42 40 '__return_empty_string',
43 41 'activitypub_settings'
44 42 );
45 43
46 - \add_settings_section(
44 + add_settings_section(
47 45 'activitypub_general',
48 - \__( 'General', 'activitypub' ),
46 + __( 'General', 'activitypub' ),
49 47 '__return_empty_string',
50 48 'activitypub_settings'
51 49 );
52 50
53 - \add_settings_section(
51 + add_settings_section(
54 52 'activitypub_server',
55 - \__( 'Server', 'activitypub' ),
53 + __( 'Server', 'activitypub' ),
56 54 '__return_empty_string',
57 55 'activitypub_settings'
58 56 );
59 57
60 - \add_settings_section(
58 + add_settings_section(
61 59 'activitypub_moderation',
62 60 \esc_html__( 'Moderation', 'activitypub' ),
63 61 array( self::class, 'render_moderation_section_description' ),
64 - 'activitypub_settings',
65 - array(
66 - 'before_section' => '<div id="moderation">',
67 - 'after_section' => '</div>',
68 - )
62 + 'activitypub_settings'
69 63 );
70 64
71 65 // Add settings fields.
72 - \add_settings_field(
66 + add_settings_field(
73 67 'activitypub_actor_mode',
74 - \__( 'Enable profiles by type', 'activitypub' ),
68 + __( 'Enable profiles by type', 'activitypub' ),
75 69 array( self::class, 'render_actor_mode_field' ),
76 70 'activitypub_settings',
77 71 'activitypub_profiles'
78 72 );
@@ -78,11 +72,11 @@
78 72 );
79 73
80 74 $object_type = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
81 75 if ( 'note' === $object_type ) {
82 - \add_settings_field(
76 + add_settings_field(
83 77 'activitypub_custom_post_content',
84 - \__( 'Post content', 'activitypub' ),
78 + __( 'Post content', 'activitypub' ),
85 79 array( self::class, 'render_custom_post_content_field' ),
86 80 'activitypub_settings',
87 81 'activitypub_activities',
88 82 array( 'label_for' => 'activitypub_custom_post_content' )
@@ -88,11 +82,11 @@
88 82 array( 'label_for' => 'activitypub_custom_post_content' )
89 83 );
90 84 }
91 85
92 - \add_settings_field(
86 + add_settings_field(
93 87 'activitypub_max_image_attachments',
94 - \__( 'Media attachments', 'activitypub' ),
88 + __( 'Media attachments', 'activitypub' ),
95 89 array( self::class, 'render_max_image_attachments_field' ),
96 90 'activitypub_settings',
97 91 'activitypub_activities',
98 92 array( 'label_for' => 'activitypub_max_image_attachments' )
@@ -97,45 +91,27 @@
97 91 'activitypub_activities',
98 92 array( 'label_for' => 'activitypub_max_image_attachments' )
99 93 );
100 94
101 - \add_settings_field(
95 + add_settings_field(
102 96 'activitypub_support_post_types',
103 - \__( 'Supported post types', 'activitypub' ),
97 + __( 'Supported post types', 'activitypub' ),
104 98 array( self::class, 'render_support_post_types_field' ),
105 99 'activitypub_settings',
106 100 'activitypub_activities'
107 101 );
108 102
109 - \add_settings_field(
103 + add_settings_field(
110 104 'activitypub_allow_interactions',
111 - \__( 'Post interactions', 'activitypub' ),
105 + __( 'Post interactions', 'activitypub' ),
112 106 array( self::class, 'render_allow_interactions_field' ),
113 107 'activitypub_settings',
114 108 'activitypub_activities'
115 109 );
116 110
117 - \add_settings_field(
118 - 'activitypub_default_quote_policy',
119 - \__( 'Default quote policy', 'activitypub' ),
120 - array( self::class, 'render_default_quote_policy_field' ),
121 - 'activitypub_settings',
122 - 'activitypub_activities',
123 - array( 'label_for' => 'activitypub_default_quote_policy' )
124 - );
125 -
126 - \add_settings_field(
127 - 'activitypub_default_feature_policy',
128 - \__( 'Default Starter Kit policy', 'activitypub' ),
129 - array( self::class, 'render_default_feature_policy_field' ),
130 - 'activitypub_settings',
131 - 'activitypub_activities',
132 - array( 'label_for' => 'activitypub_default_feature_policy' )
133 - );
134 -
135 - \add_settings_field(
111 + add_settings_field(
136 112 'activitypub_use_hashtags',
137 - \__( 'Hashtags', 'activitypub' ),
113 + __( 'Hashtags', 'activitypub' ),
138 114 array( self::class, 'render_use_hashtags_field' ),
139 115 'activitypub_settings',
140 116 'activitypub_activities',
141 117 array( 'label_for' => 'activitypub_use_hashtags' )
@@ -140,11 +116,11 @@
140 116 'activitypub_activities',
141 117 array( 'label_for' => 'activitypub_use_hashtags' )
142 118 );
143 119
144 - \add_settings_field(
120 + add_settings_field(
145 121 'activitypub_use_opengraph',
146 - \__( 'OpenGraph', 'activitypub' ),
122 + __( 'OpenGraph', 'activitypub' ),
147 123 array( self::class, 'render_use_opengraph_field' ),
148 124 'activitypub_settings',
149 125 'activitypub_general',
150 126 array( 'label_for' => 'activitypub_use_opengraph' )
@@ -149,11 +125,11 @@
149 125 'activitypub_general',
150 126 array( 'label_for' => 'activitypub_use_opengraph' )
151 127 );
152 128
153 - \add_settings_field(
129 + add_settings_field(
154 130 'activitypub_attribution_domains',
155 - \__( 'Attribution Domains', 'activitypub' ),
131 + __( 'Attribution Domains', 'activitypub' ),
156 132 array( self::class, 'render_attribution_domains_field' ),
157 133 'activitypub_settings',
158 134 'activitypub_general',
159 135 array( 'label_for' => 'activitypub_attribution_domains' )
@@ -158,11 +134,11 @@
158 134 'activitypub_general',
159 135 array( 'label_for' => 'activitypub_attribution_domains' )
160 136 );
161 137
162 - \add_settings_field(
138 + add_settings_field(
163 139 'activitypub_relays',
164 - \__( 'Relays', 'activitypub' ),
140 + __( 'Relays', 'activitypub' ),
165 141 array( self::class, 'render_relays_field' ),
166 142 'activitypub_settings',
167 143 'activitypub_server',
168 144 array( 'label_for' => 'activitypub_relays' )
@@ -167,9 +143,9 @@
167 143 'activitypub_server',
168 144 array( 'label_for' => 'activitypub_relays' )
169 145 );
170 146
171 - \add_settings_field(
147 + add_settings_field(
172 148 'activitypub_site_blocked_domains',
173 149 \esc_html__( 'Blocked Domains', 'activitypub' ),
174 150 array( self::class, 'render_site_blocked_domains_field' ),
175 151 'activitypub_settings',
@@ -175,9 +151,9 @@
175 151 'activitypub_settings',
176 152 'activitypub_moderation'
177 153 );
178 154
179 - \add_settings_field(
155 + add_settings_field(
180 156 'activitypub_site_blocked_keywords',
181 157 \esc_html__( 'Blocked Keywords', 'activitypub' ),
182 158 array( self::class, 'render_site_blocked_keywords_field' ),
183 159 'activitypub_settings',
@@ -182,16 +158,8 @@
182 158 array( self::class, 'render_site_blocked_keywords_field' ),
183 159 'activitypub_settings',
184 160 'activitypub_moderation'
185 161 );
186 -
187 - \add_settings_field(
188 - 'activitypub_blocklist_subscriptions',
189 - \esc_html__( 'Blocklist Subscriptions', 'activitypub' ),
190 - array( self::class, 'render_blocklist_subscriptions_field' ),
191 - 'activitypub_settings',
192 - 'activitypub_moderation'
193 - );
194 162 }
195 163
196 164 /**
197 165 * Render actor mode field.
@@ -203,54 +171,54 @@
203 171
204 172 if ( $disabled ) :
205 173 ?>
206 174 <p class="description">
207 - <?php \esc_html_e( 'âš  This setting is defined through server configuration by your blog&#8217;s administrator.', 'activitypub' ); ?>
175 + <?php esc_html_e( 'âš  This setting is defined through server configuration by your blog&#8217;s administrator.', 'activitypub' ); ?>
208 176 </p>
209 177 <?php
210 178 return;
211 179 endif;
212 180
213 - $value = \get_option( 'activitypub_actor_mode', ACTIVITYPUB_ACTOR_MODE );
181 + $value = get_option( 'activitypub_actor_mode', ACTIVITYPUB_ACTOR_MODE );
214 182 ?>
215 183 <fieldset class="actor-mode-selection">
216 184 <div class="row">
217 - <input type="radio" id="actor-mode" name="activitypub_actor_mode" value="<?php echo \esc_attr( ACTIVITYPUB_ACTOR_MODE ); ?>" <?php \checked( ACTIVITYPUB_ACTOR_MODE, $value ); ?> />
185 + <input type="radio" id="actor-mode" name="activitypub_actor_mode" value="<?php echo esc_attr( ACTIVITYPUB_ACTOR_MODE ); ?>" <?php checked( ACTIVITYPUB_ACTOR_MODE, $value ); ?> />
218 186 <div>
219 - <label for="actor-mode"><strong><?php \esc_html_e( 'Author Profiles Only', 'activitypub' ); ?></strong></label>
187 + <label for="actor-mode"><strong><?php esc_html_e( 'Author Profiles Only', 'activitypub' ); ?></strong></label>
220 188 <p class="description">
221 - <?php echo \wp_kses( \__( 'Every author on this blog (with the <code>activitypub</code> capability) gets their own ActivityPub profile.', 'activitypub' ), array( 'code' => array() ) ); ?>
189 + <?php echo wp_kses( __( 'Every author on this blog (with the <code>activitypub</code> capability) gets their own ActivityPub profile.', 'activitypub' ), array( 'code' => array() ) ); ?>
222 190 <strong>
223 191 <?php
224 - echo \wp_kses(
225 - \sprintf(
192 + echo wp_kses(
193 + sprintf(
226 194 // translators: %s is a URL.
227 - \__( 'You can add/remove the capability in the <a href="%s">user settings.</a>', 'activitypub' ),
228 - \admin_url( '/users.php' )
195 + __( 'You can add/remove the capability in the <a href="%s">user settings.</a>', 'activitypub' ),
196 + admin_url( '/users.php' )
229 197 ),
230 198 array( 'a' => array( 'href' => array() ) )
231 199 );
232 200 ?>
233 201 </strong>
234 - <?php echo \wp_kses( \__( 'Select all the users you want to update, choose the method from the drop-down list and click on the "Apply" button.', 'activitypub' ), array( 'code' => array() ) ); ?>
202 + <?php echo wp_kses( __( 'Select all the users you want to update, choose the method from the drop-down list and click on the "Apply" button.', 'activitypub' ), array( 'code' => array() ) ); ?>
235 203 </p>
236 204 </div>
237 205 </div>
238 206 <div class="row">
239 - <input type="radio" id="blog-mode" name="activitypub_actor_mode" value="<?php echo \esc_attr( ACTIVITYPUB_BLOG_MODE ); ?>" <?php \checked( ACTIVITYPUB_BLOG_MODE, $value ); ?> />
207 + <input type="radio" id="blog-mode" name="activitypub_actor_mode" value="<?php echo esc_attr( ACTIVITYPUB_BLOG_MODE ); ?>" <?php checked( ACTIVITYPUB_BLOG_MODE, $value ); ?> />
240 208 <div>
241 - <label for="blog-mode"><strong><?php \esc_html_e( 'Blog profile only', 'activitypub' ); ?></strong></label>
209 + <label for="blog-mode"><strong><?php esc_html_e( 'Blog profile only', 'activitypub' ); ?></strong></label>
242 210 <p class="description">
243 - <?php \esc_html_e( 'Your blog becomes a single ActivityPub profile and every post will be published under this profile instead of the individual author profiles.', 'activitypub' ); ?>
211 + <?php esc_html_e( 'Your blog becomes a single ActivityPub profile and every post will be published under this profile instead of the individual author profiles.', 'activitypub' ); ?>
244 212 </p>
245 213 </div>
246 214 </div>
247 215 <div class="row">
248 - <input type="radio" id="actor-blog-mode" name="activitypub_actor_mode" value="<?php echo \esc_attr( ACTIVITYPUB_ACTOR_AND_BLOG_MODE ); ?>" <?php \checked( ACTIVITYPUB_ACTOR_AND_BLOG_MODE, $value ); ?> />
216 + <input type="radio" id="actor-blog-mode" name="activitypub_actor_mode" value="<?php echo esc_attr( ACTIVITYPUB_ACTOR_AND_BLOG_MODE ); ?>" <?php checked( ACTIVITYPUB_ACTOR_AND_BLOG_MODE, $value ); ?> />
249 217 <div>
250 - <label for="actor-blog-mode"><strong><?php \esc_html_e( 'Both author and blog profiles', 'activitypub' ); ?></strong></label>
218 + <label for="actor-blog-mode"><strong><?php esc_html_e( 'Both author and blog profiles', 'activitypub' ); ?></strong></label>
251 219 <p class="description">
252 - <?php \esc_html_e( "This combines both modes. Users can be followed individually, while following the blog will show boosts of individual user's posts.", 'activitypub' ); ?>
220 + <?php esc_html_e( "This combines both modes. Users can be followed individually, while following the blog will show boosts of individual user's posts.", 'activitypub' ); ?>
253 221 </p>
254 222 </div>
255 223 </div>
256 224 </fieldset>
@@ -260,45 +228,24 @@
260 228 /**
261 229 * Render custom post content field.
262 230 */
263 231 public static function render_custom_post_content_field() {
264 - $switch_url = \wp_nonce_url(
265 - \add_query_arg(
266 - array(
267 - 'page' => 'activitypub',
268 - 'tab' => 'settings',
269 - 'activitypub_update_object_type' => '1',
270 - ),
271 - \admin_url( 'options-general.php' )
272 - ),
273 - 'activitypub_switch_object_type'
274 - );
232 + $value = get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
275 233 ?>
276 - <p class="description">
277 - <?php \esc_html_e( 'âš  You are using the legacy template system to format your posts for the fediverse. We recommend switching to automatic mode, which intelligently chooses the best format for each post. Switching will remove this template field from the settings.', 'activitypub' ); ?>
278 - </p>
279 234 <p>
280 - <a href="<?php echo \esc_url( $switch_url ); ?>" class="button">
281 - <?php \esc_html_e( 'Switch to Automatic Mode', 'activitypub' ); ?>
282 - </a>
283 - </p>
284 - <?php
285 - $value = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
286 - ?>
287 - <p>
288 - <textarea id="activitypub_custom_post_content" name="activitypub_custom_post_content" rows="10" cols="50" class="large-text" placeholder="<?php echo \esc_attr( ACTIVITYPUB_CUSTOM_POST_CONTENT ); ?>"><?php echo \esc_textarea( \wp_kses( $value, 'post' ) ); ?></textarea>
235 + <textarea id="activitypub_custom_post_content" name="activitypub_custom_post_content" rows="10" cols="50" class="large-text" placeholder="<?php echo esc_attr( ACTIVITYPUB_CUSTOM_POST_CONTENT ); ?>"><?php echo esc_textarea( wp_kses( $value, 'post' ) ); ?></textarea>
289 236 <details>
290 - <summary><?php \esc_html_e( 'See a list of ActivityPub Template Tags.', 'activitypub' ); ?></summary>
237 + <summary><?php esc_html_e( 'See a list of ActivityPub Template Tags.', 'activitypub' ); ?></summary>
291 238 <div class="description">
292 239 <ul>
293 - <li><code>[ap_title]</code> - <?php \esc_html_e( 'The post&#8217;s title.', 'activitypub' ); ?></li>
294 - <li><code>[ap_content]</code> - <?php \esc_html_e( 'The post&#8217;s content.', 'activitypub' ); ?></li>
295 - <li><code>[ap_excerpt]</code> - <?php \esc_html_e( 'The post&#8217;s excerpt (may be truncated).', 'activitypub' ); ?></li>
296 - <li><code>[ap_permalink]</code> - <?php \esc_html_e( 'The post&#8217;s permalink.', 'activitypub' ); ?></li>
297 - <li><code>[ap_shortlink]</code> - <?php echo \wp_kses( \__( 'The post&#8217;s shortlink. I can recommend <a href="https://wordpress.org/plugins/hum/" target="_blank">Hum</a>.', 'activitypub' ), 'default' ); ?></li>
298 - <li><code>[ap_hashtags]</code> - <?php \esc_html_e( 'The post&#8217;s tags as hashtags.', 'activitypub' ); ?></li>
240 + <li><code>[ap_title]</code> - <?php esc_html_e( 'The post&#8217;s title.', 'activitypub' ); ?></li>
241 + <li><code>[ap_content]</code> - <?php esc_html_e( 'The post&#8217;s content.', 'activitypub' ); ?></li>
242 + <li><code>[ap_excerpt]</code> - <?php esc_html_e( 'The post&#8217;s excerpt (may be truncated).', 'activitypub' ); ?></li>
243 + <li><code>[ap_permalink]</code> - <?php esc_html_e( 'The post&#8217;s permalink.', 'activitypub' ); ?></li>
244 + <li><code>[ap_shortlink]</code> - <?php echo wp_kses( __( 'The post&#8217;s shortlink. I can recommend <a href="https://wordpress.org/plugins/hum/" target="_blank">Hum</a>.', 'activitypub' ), 'default' ); ?></li>
245 + <li><code>[ap_hashtags]</code> - <?php esc_html_e( 'The post&#8217;s tags as hashtags.', 'activitypub' ); ?></li>
299 246 </ul>
300 - <p><?php \esc_html_e( 'You can find the full list with all possible attributes in the help section on the top-right of the screen.', 'activitypub' ); ?></p>
247 + <p><?php esc_html_e( 'You can find the full list with all possible attributes in the help section on the top-right of the screen.', 'activitypub' ); ?></p>
301 248 </div>
302 249 </details>
303 250 </p>
304 251 <?php
@@ -307,18 +254,18 @@
307 254 /**
308 255 * Render max image attachments field.
309 256 */
310 257 public static function render_max_image_attachments_field() {
311 - $value = \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS );
258 + $value = get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS );
312 259 ?>
313 - <input id="activitypub_max_image_attachments" value="<?php echo \esc_attr( $value ); ?>" name="activitypub_max_image_attachments" type="number" min="0" max="10" class="small-text" />
260 + <input id="activitypub_max_image_attachments" value="<?php echo esc_attr( $value ); ?>" name="activitypub_max_image_attachments" type="number" min="0" max="10" class="small-text" />
314 261 <p class="description">
315 262 <?php
316 - echo \wp_kses(
317 - \sprintf(
263 + echo wp_kses(
264 + sprintf(
318 265 // translators: %s is a number.
319 - \__( 'The number of media (images, audio, video) to attach to posts. Default: <code>%s</code>', 'activitypub' ),
320 - \esc_html( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS )
266 + __( 'The number of media (images, audio, video) to attach to posts. Default: <code>%s</code>', 'activitypub' ),
267 + esc_html( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS )
321 268 ),
322 269 'default'
323 270 );
324 271 ?>
@@ -324,9 +271,9 @@
324 271 ?>
325 272 </p>
326 273 <p class="description">
327 274 <em>
328 - <?php \esc_html_e( 'Note: audio and video attachments are only supported from Block Editor.', 'activitypub' ); ?>
275 + <?php esc_html_e( 'Note: audio and video attachments are only supported from Block Editor.', 'activitypub' ); ?>
329 276 </em>
330 277 </p>
331 278 <?php
332 279 }
@@ -338,16 +285,16 @@
338 285 $post_types = \get_post_types( array( 'public' => true ), 'objects' );
339 286 $supported_post_types = \get_option( 'activitypub_support_post_types', array( 'post' ) );
340 287 ?>
341 288 <fieldset>
342 - <?php \esc_html_e( 'Automatically publish items of the selected post types to the fediverse:', 'activitypub' ); ?>
289 + <?php esc_html_e( 'Automatically publish items of the selected post types to the fediverse:', 'activitypub' ); ?>
343 290 <ul>
344 291 <?php foreach ( $post_types as $post_type ) : ?>
345 292 <li>
346 - <input type="checkbox" id="activitypub_support_post_type_<?php echo \esc_attr( $post_type->name ); ?>" name="activitypub_support_post_types[]" value="<?php echo \esc_attr( $post_type->name ); ?>" <?php \checked( \in_array( $post_type->name, $supported_post_types, true ) ); ?> />
347 - <label for="activitypub_support_post_type_<?php echo \esc_attr( $post_type->name ); ?>"><?php echo \esc_html( $post_type->label ); ?></label>
293 + <input type="checkbox" id="activitypub_support_post_type_<?php echo esc_attr( $post_type->name ); ?>" name="activitypub_support_post_types[]" value="<?php echo esc_attr( $post_type->name ); ?>" <?php checked( in_array( $post_type->name, $supported_post_types, true ) ); ?> />
294 + <label for="activitypub_support_post_type_<?php echo esc_attr( $post_type->name ); ?>"><?php echo esc_html( $post_type->label ); ?></label>
348 295 <span class="description">
349 - <?php echo \esc_html( get_post_type_description( $post_type ) ); ?>
296 + <?php echo esc_html( \Activitypub\get_post_type_description( $post_type ) ); ?>
350 297 </span>
351 298 </li>
352 299 <?php endforeach; ?>
353 300 </ul>
@@ -358,35 +305,35 @@
358 305 /**
359 306 * Render allow interactions field.
360 307 */
361 308 public static function render_allow_interactions_field() {
362 - if ( \defined( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS' ) && ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) {
309 + if ( defined( 'ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS' ) && ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) {
363 310 echo '<p class="description">' . \esc_html__( 'âš  This setting is defined through server configuration by your blog&#8217;s administrator.', 'activitypub' ) . '</p>';
364 311 return;
365 312 }
366 313
367 - $allow_likes = \get_option( 'activitypub_allow_likes', '1' );
368 - $allow_reposts = \get_option( 'activitypub_allow_reposts', '1' );
369 - $auto_approve = \get_option( 'activitypub_auto_approve_reactions', '0' );
314 + $allow_likes = get_option( 'activitypub_allow_likes', '1' );
315 + $allow_reposts = get_option( 'activitypub_allow_reposts', '1' );
316 + $auto_approve = get_option( 'activitypub_auto_approve_reactions', '0' );
370 317 ?>
371 318 <fieldset>
372 319 <p>
373 320 <label>
374 - <input type="checkbox" name="activitypub_allow_likes" value="1" <?php \checked( '1', $allow_likes ); ?> />
375 - <?php \esc_html_e( 'Receive likes', 'activitypub' ); ?>
321 + <input type="checkbox" name="activitypub_allow_likes" value="1" <?php checked( '1', $allow_likes ); ?> />
322 + <?php esc_html_e( 'Receive likes', 'activitypub' ); ?>
376 323 </label>
377 324 </p>
378 325 <p>
379 326 <label>
380 - <input type="checkbox" name="activitypub_allow_reposts" value="1" <?php \checked( '1', $allow_reposts ); ?> />
381 - <?php \esc_html_e( 'Receive reblogs (boosts)', 'activitypub' ); ?>
327 + <input type="checkbox" name="activitypub_allow_reposts" value="1" <?php checked( '1', $allow_reposts ); ?> />
328 + <?php esc_html_e( 'Receive reblogs (boosts)', 'activitypub' ); ?>
382 329 </label>
383 330 </p>
384 - <p class="interactions description"><?php \esc_html_e( 'Types of interactions from the Fediverse your blog should accept.', 'activitypub' ); ?></p>
331 + <p class="interactions description"><?php esc_html_e( 'Types of interactions from the Fediverse your blog should accept.', 'activitypub' ); ?></p>
385 332 <p>
386 333 <label>
387 - <input type="checkbox" name="activitypub_auto_approve_reactions" value="1" <?php \checked( '1', $auto_approve ); ?> />
388 - <?php \esc_html_e( 'Auto approve reactions', 'activitypub' ); ?>
334 + <input type="checkbox" name="activitypub_auto_approve_reactions" value="1" <?php checked( '1', $auto_approve ); ?> />
335 + <?php esc_html_e( 'Auto approve reactions', 'activitypub' ); ?>
389 336 </label>
390 337 </p>
391 338 </fieldset>
392 339 <?php
@@ -392,51 +339,17 @@
392 339 <?php
393 340 }
394 341
395 342 /**
396 - * Render default quote policy field.
397 - */
398 - public static function render_default_quote_policy_field() {
399 - $value = \get_option( 'activitypub_default_quote_policy', ACTIVITYPUB_INTERACTION_POLICY_ANYONE );
400 - ?>
401 - <select id="activitypub_default_quote_policy" name="activitypub_default_quote_policy" class="regular-text">
402 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>><?php \esc_html_e( 'Anyone', 'activitypub' ); ?></option>
403 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>><?php \esc_html_e( 'Followers only', 'activitypub' ); ?></option>
404 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>><?php \esc_html_e( 'Just me', 'activitypub' ); ?></option>
405 - </select>
406 - <p class="description">
407 - <?php \esc_html_e( 'Default setting for who can quote new posts. This can be overridden per post.', 'activitypub' ); ?>
408 - </p>
409 - <?php
410 - }
411 -
412 - /**
413 - * Render default feature policy field.
414 - */
415 - public static function render_default_feature_policy_field() {
416 - $value = \get_option( 'activitypub_default_feature_policy', ACTIVITYPUB_INTERACTION_POLICY_ME );
417 - ?>
418 - <select id="activitypub_default_feature_policy" name="activitypub_default_feature_policy" class="regular-text">
419 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>><?php \esc_html_e( 'Anyone', 'activitypub' ); ?></option>
420 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>><?php \esc_html_e( 'Followers only', 'activitypub' ); ?></option>
421 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>" <?php \selected( $value, ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>><?php \esc_html_e( 'Just me', 'activitypub' ); ?></option>
422 - </select>
423 - <p class="description">
424 - <?php \esc_html_e( 'Default setting for who can include this site\'s actors in a Starter Kit (also called a Starter Pack or Featured Collection).', 'activitypub' ); ?>
425 - </p>
426 - <?php
427 - }
428 -
429 - /**
430 343 * Render use hashtags field.
431 344 */
432 345 public static function render_use_hashtags_field() {
433 - $value = \get_option( 'activitypub_use_hashtags', '0' );
346 + $value = get_option( 'activitypub_use_hashtags', '1' );
434 347 ?>
435 348 <p>
436 349 <label>
437 - <input type="checkbox" id="activitypub_use_hashtags" name="activitypub_use_hashtags" value="1" <?php \checked( '1', $value ); ?> />
438 - <?php echo \wp_kses( \__( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag link.', 'activitypub' ), 'default' ); ?>
350 + <input type="checkbox" id="activitypub_use_hashtags" name="activitypub_use_hashtags" value="1" <?php checked( '1', $value ); ?> />
351 + <?php echo wp_kses( __( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag link.', 'activitypub' ), 'default' ); ?>
439 352 </label>
440 353 </p>
441 354 <?php
442 355 }
@@ -444,14 +357,14 @@
444 357 /**
445 358 * Render use OpenGraph field.
446 359 */
447 360 public static function render_use_opengraph_field() {
448 - $value = \get_option( 'activitypub_use_opengraph', '1' );
361 + $value = get_option( 'activitypub_use_opengraph', '1' );
449 362 ?>
450 363 <p>
451 364 <label>
452 - <input type="checkbox" id="activitypub_use_opengraph" name="activitypub_use_opengraph" value="1" <?php \checked( '1', $value ); ?> />
453 - <?php echo \wp_kses( \__( 'Automatically add <code>&lt;meta name="fediverse:creator" /&gt;</code> tags for Authors and the Blog-User. You can read more about the feature on the <a href="https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/" target="_blank">Mastodon Blog</a>.', 'activitypub' ), 'post' ); ?>
365 + <input type="checkbox" id="activitypub_use_opengraph" name="activitypub_use_opengraph" value="1" <?php checked( '1', $value ); ?> />
366 + <?php echo wp_kses( __( 'Automatically add <code>&lt;meta name="fediverse:creator" /&gt;</code> tags for Authors and the Blog-User. You can read more about the feature on the <a href="https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/" target="_blank">Mastodon Blog</a>.', 'activitypub' ), 'post' ); ?>
454 367 </label>
455 368 </p>
456 369 <?php
457 370 }
@@ -459,9 +372,9 @@
459 372 /**
460 373 * Render attribution domains field.
461 374 */
462 375 public static function render_attribution_domains_field() {
463 - $value = \get_option( 'activitypub_attribution_domains', home_host() );
376 + $value = get_option( 'activitypub_attribution_domains', home_host() );
464 377 ?>
465 378 <textarea
466 379 id="activitypub_attribution_domains"
467 380 name="activitypub_attribution_domains"
@@ -466,11 +379,11 @@
466 379 id="activitypub_attribution_domains"
467 380 name="activitypub_attribution_domains"
468 381 class="large-text"
469 382 cols="50" rows="5"
470 - placeholder="<?php echo \esc_attr( home_host() ); ?>"
471 - ><?php echo \esc_textarea( $value ); ?></textarea>
472 - <p class="description"><?php \esc_html_e( 'Websites allowed to credit you, one per line. Protects from false attributions.', 'activitypub' ); ?></p>
383 + placeholder="<?php echo esc_attr( home_host() ); ?>"
384 + ><?php echo esc_textarea( $value ); ?></textarea>
385 + <p class="description"><?php esc_html_e( 'Websites allowed to credit you, one per line. Protects from false attributions.', 'activitypub' ); ?></p>
473 386 <?php
474 387 }
475 388
476 389 /**
@@ -484,9 +397,9 @@
484 397 name="activitypub_relays"
485 398 class="large-text"
486 399 cols="50"
487 400 rows="5"
488 - ><?php echo \esc_textarea( \implode( PHP_EOL, $value ) ); ?></textarea>
401 + ><?php echo \esc_textarea( implode( PHP_EOL, $value ) ); ?></textarea>
489 402 <p class="description">
490 403 <?php echo \wp_kses( \__( 'A <strong>Fediverse-Relay</strong> distributes content across instances, expanding reach, engagement, and discoverability, especially for smaller instances.', 'activitypub' ), 'default' ); ?>
491 404 </p>
492 405 <p class="description">
@@ -515,46 +428,26 @@
515 428 * Render site blocked domains field.
516 429 */
517 430 public static function render_site_blocked_domains_field() {
518 431 $blocked_domains = Moderation::get_site_blocks()['domains'];
519 - $count = \count( $blocked_domains );
520 432 ?>
521 433 <p class="description"><?php \esc_html_e( 'Block entire ActivityPub instances by domain name.', 'activitypub' ); ?></p>
522 434
523 435 <div class="activitypub-site-block-list">
524 - <details class="activitypub-site-block-details" data-type="domain"<?php echo empty( $blocked_domains ) ? ' open' : ''; ?>>
525 - <summary>
526 - <?php if ( $count > 0 ) : ?>
527 - <?php
528 - echo \esc_html(
529 - \sprintf(
530 - /* translators: %s: Number of blocked domains */
531 - \_n( '%s blocked domain', '%s blocked domains', $count, 'activitypub' ),
532 - \number_format_i18n( $count )
533 - )
534 - );
535 - ?>
536 - <?php else : ?>
537 - <?php \esc_html_e( 'No blocked domains', 'activitypub' ); ?>
538 - <?php endif; ?>
539 - </summary>
540 - <?php if ( ! empty( $blocked_domains ) ) : ?>
541 - <table class="widefat striped activitypub-site-blocked-domain" role="presentation">
542 - <tbody>
543 - <?php foreach ( $blocked_domains as $domain ) : ?>
544 - <tr>
545 - <td><?php echo \esc_html( $domain ); ?></td>
546 - <td>
547 - <button type="button" class="button button-small remove-site-block-btn" data-type="domain" data-value="<?php echo \esc_attr( $domain ); ?>">
548 - <?php \esc_html_e( 'Remove', 'activitypub' ); ?>
549 - </button>
550 - </td>
551 - </tr>
552 - <?php endforeach; ?>
553 - </tbody>
554 - </table>
555 - <?php endif; ?>
556 - </details>
436 + <?php if ( ! empty( $blocked_domains ) ) : ?>
437 + <table class="widefat striped activitypub-site-blocked-domain" role="presentation" style="max-width: 500px; margin: 15px 0;">
438 + <?php foreach ( $blocked_domains as $domain ) : ?>
439 + <tr>
440 + <td><?php echo \esc_html( $domain ); ?></td>
441 + <td style="width: 80px;">
442 + <button type="button" class="button button-small remove-site-block-btn" data-type="domain" data-value="<?php echo \esc_attr( $domain ); ?>">
443 + <?php \esc_html_e( 'Remove', 'activitypub' ); ?>
444 + </button>
445 + </td>
446 + </tr>
447 + <?php endforeach; ?>
448 + </table>
449 + <?php endif; ?>
557 450
558 451 <div class="add-site-block-form" style="display: flex; max-width: 500px; gap: 8px;">
559 452 <input type="text" class="regular-text" id="new_site_domain" placeholder="<?php \esc_attr_e( 'example.com', 'activitypub' ); ?>" style="flex: 1; min-width: 0;" />
560 453 <button type="button" class="button add-site-block-btn" data-type="domain" style="flex-shrink: 0; white-space: nowrap;">
@@ -569,114 +462,33 @@
569 462 * Render site blocked keywords field.
570 463 */
571 464 public static function render_site_blocked_keywords_field() {
572 465 $blocked_keywords = Moderation::get_site_blocks()['keywords'];
573 - $count = \count( $blocked_keywords );
574 466 ?>
575 467 <p class="description"><?php \esc_html_e( 'Block ActivityPub content containing specific keywords.', 'activitypub' ); ?></p>
576 468
577 469 <div class="activitypub-site-block-list">
578 - <details class="activitypub-site-block-details" data-type="keyword"<?php echo empty( $blocked_keywords ) ? ' open' : ''; ?>>
579 - <summary>
580 - <?php if ( $count > 0 ) : ?>
581 - <?php
582 - echo \esc_html(
583 - \sprintf(
584 - /* translators: %s: Number of blocked keywords */
585 - \_n( '%s blocked keyword', '%s blocked keywords', $count, 'activitypub' ),
586 - \number_format_i18n( $count )
587 - )
588 - );
589 - ?>
590 - <?php else : ?>
591 - <?php \esc_html_e( 'No blocked keywords', 'activitypub' ); ?>
592 - <?php endif; ?>
593 - </summary>
594 - <?php if ( ! empty( $blocked_keywords ) ) : ?>
595 - <table class="widefat striped activitypub-site-blocked-keyword" role="presentation">
596 - <tbody>
597 - <?php foreach ( $blocked_keywords as $keyword ) : ?>
598 - <tr>
599 - <td><?php echo \esc_html( $keyword ); ?></td>
600 - <td>
601 - <button type="button" class="button button-small remove-site-block-btn" data-type="keyword" data-value="<?php echo \esc_attr( $keyword ); ?>">
602 - <?php \esc_html_e( 'Remove', 'activitypub' ); ?>
603 - </button>
604 - </td>
605 - </tr>
606 - <?php endforeach; ?>
607 - </tbody>
608 - </table>
609 - <?php endif; ?>
610 - </details>
611 -
612 - <div class="add-site-block-form" style="display: flex; max-width: 500px; gap: 8px;">
613 - <input type="text" class="regular-text" id="new_site_keyword" placeholder="<?php \esc_attr_e( 'spam keyword', 'activitypub' ); ?>" style="flex: 1; min-width: 0;" />
614 - <button type="button" class="button add-site-block-btn" data-type="keyword" style="flex-shrink: 0; white-space: nowrap;">
615 - <?php \esc_html_e( 'Add Block', 'activitypub' ); ?>
616 - </button>
617 - </div>
618 - </div>
619 - <?php
620 - }
621 -
622 - /**
623 - * Render blocklist subscriptions field.
624 - */
625 - public static function render_blocklist_subscriptions_field() {
626 - $subscriptions = Blocklist_Subscriptions::get_all();
627 - ?>
628 - <p class="description"><?php \esc_html_e( 'Subscribe to remote blocklists that sync automatically every week.', 'activitypub' ); ?></p>
629 -
630 - <div class="activitypub-blocklist-subscriptions">
631 - <?php if ( ! empty( $subscriptions ) ) : ?>
632 - <table class="widefat striped" role="presentation" style="max-width: 500px; margin: 15px 0;">
633 - <thead>
470 + <?php if ( ! empty( $blocked_keywords ) ) : ?>
471 + <table class="widefat striped activitypub-site-blocked-keyword" role="presentation" style="max-width: 500px; margin: 15px 0;">
472 + <?php foreach ( $blocked_keywords as $keyword ) : ?>
634 473 <tr>
635 - <th style="padding: 10px;"><?php \esc_html_e( 'URL', 'activitypub' ); ?></th>
636 - <th style="padding: 10px;"><?php \esc_html_e( 'Last Synced', 'activitypub' ); ?></th>
637 - <th style="width: 80px;"></th>
638 - </tr>
639 - </thead>
640 - <tbody>
641 - <?php foreach ( $subscriptions as $url => $timestamp ) : ?>
642 - <tr>
643 - <td>
644 - <abbr title="<?php echo \esc_attr( $url ); ?>"><?php echo \esc_html( \wp_parse_url( $url, PHP_URL_HOST ) ); ?></abbr>
645 - </td>
646 - <td>
647 - <?php if ( $timestamp > 0 ) : ?>
648 - <?php echo \esc_html( \human_time_diff( $timestamp, \time() ) . ' ' . \__( 'ago', 'activitypub' ) ); ?>
649 - <?php else : ?>
650 - <em><?php \esc_html_e( 'Never', 'activitypub' ); ?></em>
651 - <?php endif; ?>
652 - </td>
653 - <td>
654 - <button type="button" class="button button-small remove-blocklist-subscription-btn" data-url="<?php echo \esc_attr( $url ); ?>">
474 + <td><?php echo \esc_html( $keyword ); ?></td>
475 + <td style="width: 80px;">
476 + <button type="button" class="button button-small remove-site-block-btn" data-type="keyword" data-value="<?php echo \esc_attr( $keyword ); ?>">
655 477 <?php \esc_html_e( 'Remove', 'activitypub' ); ?>
656 478 </button>
657 479 </td>
658 480 </tr>
659 481 <?php endforeach; ?>
660 - </tbody>
661 482 </table>
662 483 <?php endif; ?>
663 484
664 - <div class="add-blocklist-subscription-form" style="display: flex; max-width: 500px; gap: 8px;">
665 - <input type="url" class="regular-text" id="new_blocklist_subscription_url" placeholder="<?php \esc_attr_e( 'https://example.com/blocklist.csv', 'activitypub' ); ?>" style="flex: 1; min-width: 0;" />
666 - <button type="button" class="button add-blocklist-subscription-btn" style="flex-shrink: 0; white-space: nowrap;">
667 - <?php \esc_html_e( 'Subscribe', 'activitypub' ); ?>
485 + <div class="add-site-block-form" style="display: flex; max-width: 500px; gap: 8px;">
486 + <input type="text" class="regular-text" id="new_site_keyword" placeholder="<?php \esc_attr_e( 'spam keyword', 'activitypub' ); ?>" style="flex: 1; min-width: 0;" />
487 + <button type="button" class="button add-site-block-btn" data-type="keyword" style="flex-shrink: 0; white-space: nowrap;">
488 + <?php \esc_html_e( 'Add Block', 'activitypub' ); ?>
668 489 </button>
669 490 </div>
670 -
671 - <?php if ( ! isset( $subscriptions[ Blocklist_Subscriptions::IFTAS_DNI_URL ] ) ) : ?>
672 - <p class="description" style="margin-top: 10px;">
673 - <button type="button" class="button add-blocklist-subscription-btn" data-url="<?php echo \esc_attr( Blocklist_Subscriptions::IFTAS_DNI_URL ); ?>">
674 - <?php \esc_html_e( 'Subscribe to IFTAS DNI List', 'activitypub' ); ?>
675 - </button>
676 - <?php echo \wp_kses_post( \__( 'Domains <a href="https://about.iftas.org/" target="_blank" rel="noopener">IFTAS</a> recommends not federating with.', 'activitypub' ) ); ?>
677 - </p>
678 - <?php endif; ?>
679 491 </div>
680 492 <?php
681 493 }
682 494 }