From da9e71008d4733556a23cfe324f220be2d8687a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 24 Sep 2024 14:28:06 +0200 Subject: [PATCH] fix edge cases for plugin setup --- includes/class-setup.php | 4 ++-- tests/test-class-plugin-the-events-calendar.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/class-setup.php b/includes/class-setup.php index cbe6106..c3f9a79 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -59,7 +59,7 @@ class Setup { * @since 1.0.0 */ protected function __construct() { - $this->activitypub_plugin_is_active = defined( 'ACTIVITYPUB_PLUGIN_VERSION' ); + $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 ); @@ -206,7 +206,7 @@ class Setup { // The ActivityPub plugin is not active. add_action( 'admin_notices', array( 'Activitypub_Event_Extensions\Admin\General_Admin_Notices', 'activitypub_plugin_not_enabled' ), 10, 1 ); } - if ( version_compare( $this->activitypub_plugin_version, ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { + if ( ! version_compare( $this->activitypub_plugin_version, ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { // The ActivityPub plugin is too old. add_action( 'admin_notices', array( 'Activitypub_Event_Extensions\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 ); } diff --git a/tests/test-class-plugin-the-events-calendar.php b/tests/test-class-plugin-the-events-calendar.php index 44df750..406df03 100644 --- a/tests/test-class-plugin-the-events-calendar.php +++ b/tests/test-class-plugin-the-events-calendar.php @@ -164,6 +164,10 @@ class Test_The_Events_Calendar extends WP_UnitTestCase { ->set( 'category', array( $category_id_theatre ) ) ->create(); + $test1 = wp_set_post_categories( $wp_object->ID, $category_id_theatre ); + $terms = get_the_terms( $wp_object->ID, 'tribe_events_cat' ); + get_the_terms( $post_id, 'tribe_events_cat' ); + // Call the transformer. $event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();