From 8fecbe792f5be91cb38d11b1712914b85fdcedce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 24 Sep 2024 16:10:05 +0200 Subject: [PATCH] fix linter issues --- .../transformer/class-the-events-calendar.php | 2 +- includes/class-setup.php | 18 ++++++++++++++++-- .../test-class-plugin-the-events-calendar.php | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index c576754..2c590b8 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -149,7 +149,7 @@ final class The_Events_Calendar extends Event { $venues = $this->wp_object->venues; // Get first venue. We currently only support a single venue. - if ( $venues instanceof \Tribe\Events\Collections\Lazy_Post_Collection ){ + if ( $venues instanceof \Tribe\Events\Collections\Lazy_Post_Collection ) { $venue = $venues->first(); } elseif ( empty( $this->wp_object->venues ) || ! empty( $this->wp_object->venues[0] ) ) { return null; diff --git a/includes/class-setup.php b/includes/class-setup.php index 8f8f773..9e4a1e6 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -59,14 +59,15 @@ class Setup { * @since 1.0.0 */ protected function __construct() { - $this->activitypub_plugin_is_active = defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) || is_plugin_active( 'activitypub/activitypub.php' ); + $this->activitypub_plugin_is_active = defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) || + is_plugin_active( 'activitypub/activitypub.php' ); // BeforeFirstRelease: decide whether we want to do anything at all when ActivityPub plugin is note active. // if ( ! $this->activitypub_plugin_is_active ) { // deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ); // return; // }. $this->active_event_plugins = self::detect_active_event_plugins(); - $this->activitypub_plugin_version = defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ? constant( 'ACTIVITYPUB_PLUGIN_VERSION' ): '0'; + $this->activitypub_plugin_version = self::get_activitypub_plugin_version(); $this->setup_hooks(); } @@ -95,6 +96,19 @@ class Setup { return self::$instance; } + /** + * LooksUp the current version of the ActivityPub. + * + * @return string The semantic Version. + */ + private static function get_activitypub_plugin_version(): string { + if ( defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) { + return constant( 'ACTIVITYPUB_PLUGIN_VERSION' ); + } + $version = get_file_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php', array( 'Version' ) )[0]; + return $version ?? '0.0.0'; + } + /** * Getter function for the active event plugins. * diff --git a/tests/test-class-plugin-the-events-calendar.php b/tests/test-class-plugin-the-events-calendar.php index 4614746..c2c9eb6 100644 --- a/tests/test-class-plugin-the-events-calendar.php +++ b/tests/test-class-plugin-the-events-calendar.php @@ -14,8 +14,8 @@ class Test_The_Events_Calendar extends WP_UnitTestCase { */ public const MOCKUP_VENUS = array( 'minimal_venue' => array( - 'venue' => 'Minimal Venue', - 'status' => 'publish', + 'venue' => 'Minimal Venue', + 'status' => 'publish', ), 'complex_venue' => array( 'venue' => 'Complex Venue',