From 78d83c859a8eeaaf135fc2cff97455d5e98eb563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Thu, 4 Jan 2024 11:25:29 +0100 Subject: [PATCH] add proof of concept for indicators that activitypub is not enabled for a event plugin --- activitypub-event-transformers.php | 43 ++++++++++++++++++- .../activitypub}/transformer/class-tribe.php | 0 .../transformer/class-vs-event.php | 0 readme.txt | 15 +++++++ 4 files changed, 57 insertions(+), 1 deletion(-) rename {activitypub => includes/activitypub}/transformer/class-tribe.php (100%) rename {activitypub => includes/activitypub}/transformer/class-vs-event.php (100%) create mode 100644 readme.txt diff --git a/activitypub-event-transformers.php b/activitypub-event-transformers.php index 406f069..63e8c91 100644 --- a/activitypub-event-transformers.php +++ b/activitypub-event-transformers.php @@ -30,7 +30,7 @@ add_filter( * @see https://wordpress.org/plugins/very-simple-event-list/ */ if ( $object->post_type === 'event' ) { - require_once __DIR__ . '/activitypub/transformer/class-vs-event.php'; + require_once __DIR__ . '/includes/activitypub/transformer/class-vs-event.php'; return new \VS_Event( $object ); } // Return the default transformer. @@ -40,6 +40,47 @@ add_filter( 3 ); +/** + * Add admin notices for improved usability. + */ +function check_some_other_plugin() { + if ( is_plugin_active('activitypub/activitypub.php') ) { + if ( is_plugin_active('very-simple-event-list/vsel.php') ) { + add_action( 'admin_notices', 'vsel_admin_notices' ); + } + } +} + +add_action( 'admin_init', 'check_some_other_plugin' ); + +function vsel_admin_notices() { + $is_vsel_edit_page = isset($_GET['post_type']) && $_GET['post_type'] === 'event'; + $is_vsel_settings_page = strpos($_SERVER['REQUEST_URI'], '/wp-admin/options-general.php?page=vsel') !== false ; + $is_vsel_page = $is_vsel_edit_page || $is_vsel_settings_page; + $vsel_post_type_is_activitypub_enabeld = in_array( 'event', get_option( 'activitypub_support_post_types') ); + if ( $is_vsel_page && ! $vsel_post_type_is_activitypub_enabeld ) { + $vsel_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/very-simple-event-list/vsel.php' ); + $activitypub_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php' ); + $notice = sprintf( + _x( + 'You have installed the %1$s plugin, but the event post type of %2$s is not enabled in the %1$s settings.', + 'admin notice', + 'your-text-domain' + ), + $activitypub_plugin_data['Name'], + $vsel_plugin_data['Name'], + admin_url('options-general.php?page=activitypub&tab=settings') + ); + wp_admin_notice( + $notice, + array( + 'type' => 'warning', + 'dismissible' => true, + ) + ); + } +} + /** * Add a filter for http_request_host_is_external * diff --git a/activitypub/transformer/class-tribe.php b/includes/activitypub/transformer/class-tribe.php similarity index 100% rename from activitypub/transformer/class-tribe.php rename to includes/activitypub/transformer/class-tribe.php diff --git a/activitypub/transformer/class-vs-event.php b/includes/activitypub/transformer/class-vs-event.php similarity index 100% rename from activitypub/transformer/class-vs-event.php rename to includes/activitypub/transformer/class-vs-event.php diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..b58aed0 --- /dev/null +++ b/readme.txt @@ -0,0 +1,15 @@ +=== ActivityPub Event Plugin === +Contributors: menrath +Tags: events, fediverse, activitypub, activitystream +Requires at least: 6.4 +Tested up to: 6.4 +Stable tag: 1.0.0 +Requires PHP: 5.6 +License: AGPL-3.0-or-later +License URI: http://opensource.org/licenses/MIT + +The ActivityPub Event Plugin is... + +== Description == + +TODO