From fdfdf6c0b2c56a8f0dba1597c7a207e04ce29d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 19 Oct 2024 13:26:10 +0200 Subject: [PATCH] improve warning notices when event post type is not enabled for activitypub --- includes/class-setup.php | 13 ++++++------- includes/plugins/class-event-plugin.php | 10 +++++----- includes/plugins/class-eventin.php | 8 ++++---- includes/plugins/class-events-manager.php | 8 ++++---- includes/plugins/class-gatherpress.php | 8 ++++---- .../plugins/class-modern-events-calendar-lite.php | 8 ++++---- includes/plugins/class-the-events-calendar.php | 8 ++++---- includes/plugins/class-vs-event-list.php | 8 ++++---- includes/plugins/class-wp-event-manager.php | 8 ++++---- 9 files changed, 39 insertions(+), 40 deletions(-) diff --git a/includes/class-setup.php b/includes/class-setup.php index 057ff3c..bfaef37 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -168,6 +168,12 @@ class Setup { add_action( 'admin_init', array( $this, 'do_admin_notices' ) ); add_action( 'admin_init', array( Settings::class, 'register_settings' ) ); + add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_styles' ) ); + add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) ); + add_filter( + 'plugin_action_links_' . ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_BASENAME, + array( Settings_Page::class, 'settings_link' ) + ); // If we don't have any active event plugins, or the ActivityPub plugin is not enabled, abort here. if ( empty( $this->active_event_plugins ) || ! $this->activitypub_plugin_is_active ) { @@ -175,13 +181,6 @@ class Setup { } add_action( 'init', array( Health_Check::class, 'init' ) ); - add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_styles' ) ); - add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) ); - - add_filter( - 'plugin_action_links_' . ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_BASENAME, - array( Settings_Page::class, 'settings_link' ) - ); // Check if the minimum required version of the ActivityPub plugin is installed. if ( ! version_compare( $this->activitypub_plugin_version, ACTIVITYPUB_EVENT_BRIDGE_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { diff --git a/includes/plugins/class-event-plugin.php b/includes/plugins/class-event-plugin.php index 7374794..f08b5c0 100644 --- a/includes/plugins/class-event-plugin.php +++ b/includes/plugins/class-event-plugin.php @@ -45,12 +45,12 @@ abstract class Event_Plugin { abstract public static function get_event_category_taxonomy(): string; /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The IDs of one or several admin/settings pages. */ - public static function get_settings_page(): string { - return ''; + public static function get_settings_pages(): array { + return array(); } /** @@ -74,7 +74,7 @@ abstract class Event_Plugin { // Check if we are on a edit page for the event, or on the settings page of the event plugin. $is_event_plugins_edit_page = 'edit' === $screen->base && static::get_post_type() === $screen->post_type; - $is_event_plugins_settings_page = static::get_settings_page() === $screen->id; + $is_event_plugins_settings_page = in_array( $screen->id, static::get_settings_pages(), true); return $is_event_plugins_edit_page || $is_event_plugins_settings_page; } diff --git a/includes/plugins/class-eventin.php b/includes/plugins/class-eventin.php index fcab7c8..6584e85 100644 --- a/includes/plugins/class-eventin.php +++ b/includes/plugins/class-eventin.php @@ -41,12 +41,12 @@ final class Eventin extends Event_plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page url. */ - public static function get_settings_page(): string { - return 'eventin'; // Base always is wp-admin/admin.php?page=eventin. + public static function get_settings_pages(): array { + return array( 'eventin' ); // Base always is wp-admin/admin.php?page=eventin. } /** diff --git a/includes/plugins/class-events-manager.php b/includes/plugins/class-events-manager.php index feffcc5..02ca060 100644 --- a/includes/plugins/class-events-manager.php +++ b/includes/plugins/class-events-manager.php @@ -41,12 +41,12 @@ final class Events_Manager extends Event_Plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { - return 'wp-admin/edit.php?post_type=event&page=events-manager-options#general'; + public static function get_settings_page(): array { + return array(); } /** diff --git a/includes/plugins/class-gatherpress.php b/includes/plugins/class-gatherpress.php index dead962..6c6af0f 100644 --- a/includes/plugins/class-gatherpress.php +++ b/includes/plugins/class-gatherpress.php @@ -41,12 +41,12 @@ final class GatherPress extends Event_Plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { - return class_exists( '\GatherPress\Core\Utility' ) ? \GatherPress\Core\Utility::prefix_key( 'general' ) : 'gatherpress_general'; + public static function get_settings_pages(): array { + return array( class_exists( '\GatherPress\Core\Utility' ) ? \GatherPress\Core\Utility::prefix_key( 'general' ) : 'gatherpress_general' ); } /** diff --git a/includes/plugins/class-modern-events-calendar-lite.php b/includes/plugins/class-modern-events-calendar-lite.php index f8f5552..796634d 100644 --- a/includes/plugins/class-modern-events-calendar-lite.php +++ b/includes/plugins/class-modern-events-calendar-lite.php @@ -42,12 +42,12 @@ final class Modern_Events_Calendar_Lite extends Event_plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { - return 'mec-event'; + public static function get_settings_pages(): array { + return array( 'MEC-settings', 'MEC-support', 'MEC-ix', 'MEC-wizard', 'MEC-addons', 'mec-intro' ); } /** diff --git a/includes/plugins/class-the-events-calendar.php b/includes/plugins/class-the-events-calendar.php index ef07590..36ab8e0 100644 --- a/includes/plugins/class-the-events-calendar.php +++ b/includes/plugins/class-the-events-calendar.php @@ -41,17 +41,17 @@ final class The_Events_Calendar extends Event_plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { + public static function get_settings_pages(): array { if ( class_exists( '\Tribe\Events\Admin\Settings' ) ) { $page = \Tribe\Events\Admin\Settings::$settings_page_id; } else { $page = 'tec-events-settings'; } - return sprintf( 'edit.php?post_type=tribe_events&page=%s', $page ); + return array( $page ); } /** diff --git a/includes/plugins/class-vs-event-list.php b/includes/plugins/class-vs-event-list.php index 0e1b0dc..f1bd96b 100644 --- a/includes/plugins/class-vs-event-list.php +++ b/includes/plugins/class-vs-event-list.php @@ -44,12 +44,12 @@ final class VS_Event_List extends Event_Plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { - return 'settings_page_vsel'; + public static function get_settings_pages(): array { + return array( 'settings_page_vsel' ); } /** diff --git a/includes/plugins/class-wp-event-manager.php b/includes/plugins/class-wp-event-manager.php index e3d3493..28a852a 100644 --- a/includes/plugins/class-wp-event-manager.php +++ b/includes/plugins/class-wp-event-manager.php @@ -44,12 +44,12 @@ final class WP_Event_Manager extends Event_Plugin { } /** - * Returns the ID of the main settings page of the plugin. + * Returns the IDs of the admin pages of the plugin. * - * @return string The settings page url. + * @return array The settings page urls. */ - public static function get_settings_page(): string { - return 'event-manager-settings'; + public static function get_settings_pages(): array { + return array( 'event-manager-settings' ); } /**