@@ -49,15 +49,9 @@ public static function init() {
4949
5050 \add_action ( 'updated_postmeta ' , array ( self ::class, 'updated_postmeta ' ), 10 , 4 );
5151 \add_action ( 'added_post_meta ' , array ( self ::class, 'updated_postmeta ' ), 10 , 4 );
52- \add_filter ( 'pre_option_activitypub_actor_mode ' , array ( self ::class, 'pre_option_activitypub_actor_mode ' ) );
53- \add_filter ( 'pre_option_activitypub_authorized_fetch ' , array ( self ::class, 'pre_option_activitypub_authorized_fetch ' ) );
54- \add_filter ( 'pre_option_activitypub_shared_inbox ' , array ( self ::class, 'pre_option_activitypub_shared_inbox ' ) );
5552
5653 \add_action ( 'init ' , array ( self ::class, 'register_user_meta ' ), 11 );
5754
58- \add_filter ( 'pre_option_activitypub_allow_likes ' , array ( self ::class, 'maybe_disable_interactions ' ) );
59- \add_filter ( 'pre_option_activitypub_allow_replies ' , array ( self ::class, 'maybe_disable_interactions ' ) );
60-
6155 // Register several post_types.
6256 self ::register_post_types ();
6357
@@ -96,37 +90,38 @@ public static function uninstall() {
9690 \remove_filter ( 'pre_wp_update_comment_count_now ' , array ( Comment::class, 'pre_wp_update_comment_count_now ' ) );
9791 Migration::update_comment_counts ( 2000 );
9892
99- delete_option ( 'activitypub_actor_mode ' );
100- delete_option ( 'activitypub_allow_likes ' );
101- delete_option ( 'activitypub_allow_replies ' );
102- delete_option ( 'activitypub_attribution_domains ' );
103- delete_option ( 'activitypub_authorized_fetch ' );
104- delete_option ( 'activitypub_application_user_private_key ' );
105- delete_option ( 'activitypub_application_user_public_key ' );
106- delete_option ( 'activitypub_blog_user_also_known_as ' );
107- delete_option ( 'activitypub_blog_user_moved_to ' );
108- delete_option ( 'activitypub_blog_user_private_key ' );
109- delete_option ( 'activitypub_blog_user_public_key ' );
110- delete_option ( 'activitypub_blog_description ' );
111- delete_option ( 'activitypub_blog_identifier ' );
112- delete_option ( 'activitypub_custom_post_content ' );
113- delete_option ( 'activitypub_db_version ' );
114- delete_option ( 'activitypub_default_extra_fields ' );
115- delete_option ( 'activitypub_enable_blog_user ' );
116- delete_option ( 'activitypub_enable_users ' );
117- delete_option ( 'activitypub_header_image ' );
118- delete_option ( 'activitypub_last_post_with_permalink_as_id ' );
119- delete_option ( 'activitypub_mailer_new_follower ' );
120- delete_option ( 'activitypub_mailer_new_dm ' );
121- delete_option ( 'activitypub_max_image_attachments ' );
122- delete_option ( 'activitypub_migration_lock ' );
123- delete_option ( 'activitypub_object_type ' );
124- delete_option ( 'activitypub_outbox_purge_days ' );
125- delete_option ( 'activitypub_shared_inbox ' );
126- delete_option ( 'activitypub_support_post_types ' );
127- delete_option ( 'activitypub_use_hashtags ' );
128- delete_option ( 'activitypub_use_opengraph ' );
129- delete_option ( 'activitypub_use_permalink_as_id_for_blog ' );
93+ \delete_option ( 'activitypub_actor_mode ' );
94+ \delete_option ( 'activitypub_allow_likes ' );
95+ \delete_option ( 'activitypub_allow_replies ' );
96+ \delete_option ( 'activitypub_attribution_domains ' );
97+ \delete_option ( 'activitypub_authorized_fetch ' );
98+ \delete_option ( 'activitypub_application_user_private_key ' );
99+ \delete_option ( 'activitypub_application_user_public_key ' );
100+ \delete_option ( 'activitypub_blog_user_also_known_as ' );
101+ \delete_option ( 'activitypub_blog_user_moved_to ' );
102+ \delete_option ( 'activitypub_blog_user_private_key ' );
103+ \delete_option ( 'activitypub_blog_user_public_key ' );
104+ \delete_option ( 'activitypub_blog_description ' );
105+ \delete_option ( 'activitypub_blog_identifier ' );
106+ \delete_option ( 'activitypub_custom_post_content ' );
107+ \delete_option ( 'activitypub_db_version ' );
108+ \delete_option ( 'activitypub_default_extra_fields ' );
109+ \delete_option ( 'activitypub_enable_blog_user ' );
110+ \delete_option ( 'activitypub_enable_users ' );
111+ \delete_option ( 'activitypub_header_image ' );
112+ \delete_option ( 'activitypub_last_post_with_permalink_as_id ' );
113+ \delete_option ( 'activitypub_mailer_new_follower ' );
114+ \delete_option ( 'activitypub_mailer_new_dm ' );
115+ \delete_option ( 'activitypub_max_image_attachments ' );
116+ \delete_option ( 'activitypub_migration_lock ' );
117+ \delete_option ( 'activitypub_object_type ' );
118+ \delete_option ( 'activitypub_outbox_purge_days ' );
119+ \delete_option ( 'activitypub_shared_inbox ' );
120+ \delete_option ( 'activitypub_support_post_types ' );
121+ \delete_option ( 'activitypub_use_hashtags ' );
122+ \delete_option ( 'activitypub_use_opengraph ' );
123+ \delete_option ( 'activitypub_use_permalink_as_id_for_blog ' );
124+ \delete_option ( 'activitypub_vary_header ' );
130125 }
131126
132127 /**
@@ -209,7 +204,7 @@ public static function add_headers() {
209204 if ( ! headers_sent () ) {
210205 \header ( 'Link: < ' . esc_url ( $ id ) . '>; title="ActivityPub (JSON)"; rel="alternate"; type="application/activity+json" ' , false );
211206
212- if ( ACTIVITYPUB_SEND_VARY_HEADER ) {
207+ if ( \get_option ( ' activitypub_vary_header ' ) ) {
213208 // Send Vary header for Accept header.
214209 \header ( 'Vary: Accept ' , false );
215210 }
@@ -396,68 +391,6 @@ public static function pre_get_avatar_data( $args, $id_or_email ) {
396391 return $ args ;
397392 }
398393
399- /**
400- * Pre-get option filter for the Actor-Mode.
401- *
402- * @param string|false $pre The pre-get option value.
403- *
404- * @return string|false The actor mode or false if it should not be filtered.
405- */
406- public static function pre_option_activitypub_actor_mode ( $ pre ) {
407- if ( \defined ( 'ACTIVITYPUB_SINGLE_USER_MODE ' ) && ACTIVITYPUB_SINGLE_USER_MODE ) {
408- return ACTIVITYPUB_BLOG_MODE ;
409- }
410-
411- if ( \defined ( 'ACTIVITYPUB_DISABLE_USER ' ) && ACTIVITYPUB_DISABLE_USER ) {
412- return ACTIVITYPUB_BLOG_MODE ;
413- }
414-
415- if ( \defined ( 'ACTIVITYPUB_DISABLE_BLOG_USER ' ) && ACTIVITYPUB_DISABLE_BLOG_USER ) {
416- return ACTIVITYPUB_ACTOR_MODE ;
417- }
418-
419- return $ pre ;
420- }
421-
422- /**
423- * Pre-get option filter for the Authorized Fetch.
424- *
425- * @param string $pre The pre-get option value.
426- *
427- * @return string If the constant is defined, return the value, otherwise return the pre-get option value.
428- */
429- public static function pre_option_activitypub_authorized_fetch ( $ pre ) {
430- if ( ! \defined ( 'ACTIVITYPUB_AUTHORIZED_FETCH ' ) ) {
431- return $ pre ;
432- }
433-
434- if ( ACTIVITYPUB_AUTHORIZED_FETCH ) {
435- return '1 ' ;
436- }
437-
438- return '0 ' ;
439- }
440-
441- /**
442- * Pre-get option filter for the Shared Inbox.
443- *
444- * @param string $pre The pre-get option value.
445- *
446- * @return string If the constant is defined, return the value, otherwise return the pre-get option value.
447- */
448- public static function pre_option_activitypub_shared_inbox ( $ pre ) {
449- if ( ! \defined ( 'ACTIVITYPUB_SHARED_INBOX_FEATURE ' ) ) {
450- return $ pre ;
451- }
452-
453- if ( ACTIVITYPUB_SHARED_INBOX_FEATURE ) {
454- return '1 ' ;
455- }
456-
457- return '0 ' ;
458- }
459-
460-
461394 /**
462395 * Store permalink in meta, to send delete Activity.
463396 *
@@ -902,18 +835,4 @@ public static function register_user_meta() {
902835 )
903836 );
904837 }
905-
906- /**
907- * Disallow interactions if the constant is set.
908- *
909- * @param bool $pre_option The value of the option.
910- * @return bool|string The value of the option.
911- */
912- public static function maybe_disable_interactions ( $ pre_option ) {
913- if ( ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) {
914- return '0 ' ;
915- }
916-
917- return $ pre_option ;
918- }
919838}
0 commit comments