Skip to content

Commit b651a09

Browse files
authored
Move Activity-Object-Type setting to advanced settings (#2148)
1 parent 9c442e3 commit b651a09

File tree

5 files changed

+89
-75
lines changed

5 files changed

+89
-75
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: deprecated
3+
4+
ActivityPub now defaults to automated object type selection, with the old manual option moved to Advanced settings for compatibility.

includes/class-options.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static function init() {
2626

2727
\add_filter( 'default_option_activitypub_negotiate_content', array( self::class, 'default_option_activitypub_negotiate_content' ) );
2828
\add_filter( 'option_activitypub_max_image_attachments', array( self::class, 'default_max_image_attachments' ) );
29+
\add_filter( 'option_activitypub_object_type', array( self::class, 'default_object_type' ) );
2930
}
3031

3132
/**
@@ -133,21 +134,6 @@ public static function maybe_disable_interactions( $pre ) {
133134
return $pre;
134135
}
135136

136-
/**
137-
* Default max image attachments.
138-
*
139-
* @param string $value The value of the option.
140-
*
141-
* @return string|int The value of the option.
142-
*/
143-
public static function default_max_image_attachments( $value ) {
144-
if ( ! \is_numeric( $value ) ) {
145-
$value = ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS;
146-
}
147-
148-
return $value;
149-
}
150-
151137
/**
152138
* Default option filter for the Content-Negotiation.
153139
*
@@ -174,4 +160,34 @@ public static function default_option_activitypub_negotiate_content( $default_va
174160

175161
return $default_value;
176162
}
163+
164+
/**
165+
* Default max image attachments.
166+
*
167+
* @param string $value The value of the option.
168+
*
169+
* @return string|int The value of the option.
170+
*/
171+
public static function default_max_image_attachments( $value ) {
172+
if ( ! \is_numeric( $value ) ) {
173+
$value = ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS;
174+
}
175+
176+
return $value;
177+
}
178+
179+
/**
180+
* Default object type.
181+
*
182+
* @param string $value The value of the option.
183+
*
184+
* @return string The value of the option.
185+
*/
186+
public static function default_object_type( $value ) {
187+
if ( ! $value ) {
188+
$value = ACTIVITYPUB_DEFAULT_OBJECT_TYPE;
189+
}
190+
191+
return $value;
192+
}
177193
}

includes/wp-admin/class-advanced-settings-fields.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ public static function register_advanced_fields() {
107107
'activitypub_advanced_settings',
108108
array( 'label_for' => 'activitypub_persist_inbox' )
109109
);
110+
111+
\add_settings_field(
112+
'activitypub_object_type',
113+
\__( 'Activity-Object-Type', 'activitypub' ),
114+
array( self::class, 'render_object_type_field' ),
115+
'activitypub_advanced_settings',
116+
'activitypub_advanced_settings',
117+
array( 'label_for' => 'activitypub_object_type' )
118+
);
110119
}
111120

112121
/**
@@ -279,4 +288,22 @@ public static function render_persist_inbox_field() {
279288
</p>
280289
<?php
281290
}
291+
292+
/**
293+
* Render object type field.
294+
*/
295+
public static function render_object_type_field() {
296+
$value = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
297+
?>
298+
<p>
299+
<label>
300+
<input type="checkbox" name="activitypub_object_type" value="note" <?php \checked( 'note', $value ); ?> />
301+
<?php \esc_html_e( 'Use Template Tags instead of letting the plugin choose the best possible format for you.', 'activitypub' ); ?>
302+
</label>
303+
</p>
304+
<p class="description">
305+
<?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' ); ?>
306+
</p>
307+
<?php
308+
}
282309
}

includes/wp-admin/class-settings-fields.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ public static function register_settings_fields() {
7171
'activitypub_profiles'
7272
);
7373

74-
add_settings_field(
75-
'activitypub_object_type',
76-
__( 'Activity-Object-Type', 'activitypub' ),
77-
array( self::class, 'render_object_type_field' ),
78-
'activitypub_settings',
79-
'activitypub_activities'
80-
);
81-
8274
$object_type = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
8375
if ( 'note' === $object_type ) {
8476
add_settings_field(
@@ -233,35 +225,6 @@ public static function render_actor_mode_field() {
233225
<?php
234226
}
235227

236-
/**
237-
* Render object type field.
238-
*/
239-
public static function render_object_type_field() {
240-
$value = get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
241-
?>
242-
<p>
243-
<label>
244-
<input type="radio" name="activitypub_object_type" value="wordpress-post-format" <?php checked( 'wordpress-post-format', $value ); ?> />
245-
<?php esc_html_e( 'Automatic (default)', 'activitypub' ); ?>
246-
-
247-
<span class="description">
248-
<?php esc_html_e( 'Let the plugin choose the best possible format for you.', 'activitypub' ); ?>
249-
</span>
250-
</label>
251-
</p>
252-
<p>
253-
<label>
254-
<input type="radio" name="activitypub_object_type" value="note" <?php checked( 'note', $value ); ?> />
255-
<?php esc_html_e( 'Note', 'activitypub' ); ?>
256-
-
257-
<span class="description">
258-
<?php esc_html_e( 'Should work with most platforms.', 'activitypub' ); ?>
259-
</span>
260-
</label>
261-
</p>
262-
<?php
263-
}
264-
265228
/**
266229
* Render custom post content field.
267230
*/

includes/wp-admin/class-settings.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ public static function register_settings() {
6969
)
7070
);
7171

72-
\register_setting(
73-
'activitypub',
74-
'activitypub_object_type',
75-
array(
76-
'type' => 'string',
77-
'description' => \__( 'The Activity-Object-Type', 'activitypub' ),
78-
'show_in_rest' => array(
79-
'schema' => array(
80-
'enum' => array( 'note', 'wordpress-post-format' ),
81-
),
82-
),
83-
'default' => ACTIVITYPUB_DEFAULT_OBJECT_TYPE,
84-
)
85-
);
86-
8772
\register_setting(
8873
'activitypub',
8974
'activitypub_use_hashtags',
@@ -260,6 +245,21 @@ public static function register_settings() {
260245
)
261246
);
262247

248+
\register_setting(
249+
'activitypub_advanced',
250+
'activitypub_object_type',
251+
array(
252+
'type' => 'string',
253+
'description' => \__( 'The Activity-Object-Type', 'activitypub' ),
254+
'show_in_rest' => array(
255+
'schema' => array(
256+
'enum' => array( 'note', 'wordpress-post-format' ),
257+
),
258+
),
259+
'default' => ACTIVITYPUB_DEFAULT_OBJECT_TYPE,
260+
)
261+
);
262+
263263
// Blog-User Settings.
264264
\register_setting(
265265
'activitypub_blog',
@@ -498,14 +498,18 @@ public static function add_settings_help_tab() {
498498
)
499499
);
500500

501-
// Template Tags.
502-
\get_current_screen()->add_help_tab(
503-
array(
504-
'id' => 'template-tags',
505-
'title' => \__( 'Template Tags', 'activitypub' ),
506-
'content' => self::get_help_tab_template( 'template-tags' ),
507-
)
508-
);
501+
// Show only if templating is enabled.
502+
$object_type = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
503+
if ( 'note' === $object_type ) {
504+
// Template Tags.
505+
\get_current_screen()->add_help_tab(
506+
array(
507+
'id' => 'template-tags',
508+
'title' => \__( 'Template Tags', 'activitypub' ),
509+
'content' => self::get_help_tab_template( 'template-tags' ),
510+
)
511+
);
512+
}
509513

510514
// Recommended Plugins.
511515
if ( ! empty( self::get_recommended_plugins() ) ) {

0 commit comments

Comments
 (0)