From 4721ab58f8e29349d2dea47bb723b51b2a9ad972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 10 Sep 2024 18:39:26 +0200 Subject: [PATCH] refactoring setup class --- includes/class-setup.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/includes/class-setup.php b/includes/class-setup.php index d62b396..47552b8 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -228,6 +228,24 @@ class Setup { return $transformer; } + /** + * Activates ActivityPub support for all active event plugins event post-types. + * + * @since 1.0.0 + * + * @return void + */ + public function activate_activitypub_support_for_active_event_plugins(): void { + // If someone installs this plugin, we simply enable ActivityPub support for all currently active event post types. + $activitypub_supported_post_types = get_option( 'activitypub_support_post_types', array() ); + foreach ( $this->active_event_plugins as $event_plugin ) { + if ( ! in_array( $event_plugin['post_type'], $activitypub_supported_post_types, true ) ) { + $activitypub_supported_post_types[] = $event_plugin['post_type']; + } + } + update_option( 'activitypub_support_post_types', $activitypub_supported_post_types ); + } + /** * Activates the ActivityPub Event Extensions plugin. * @@ -258,13 +276,7 @@ class Setup { array( 'back_link' => true ), ); } - // If someone installs this plugin, we simply enable ActivityPub support for all currently active event post types. - $activitypub_supported_post_types = get_option( 'activitypub_support_post_types', array() ); - foreach ( $this->active_event_plugins as $event_plugin ) { - if ( ! in_array( $event_plugin['post_type'], $activitypub_supported_post_types, true ) ) { - $activitypub_supported_post_types[] = $event_plugin['post_type']; - } - } - update_option( 'activitypub_support_post_types', $activitypub_supported_post_types ); + + self::activate_activitypub_support_for_active_event_plugins(); } }