add proof of concept for indicators that activitypub is not enabled for a event plugin
Some checks are pending
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Waiting to run

This commit is contained in:
André Menrath 2024-01-04 11:25:29 +01:00
parent 9a9c316bdd
commit 78d83c859a
4 changed files with 57 additions and 1 deletions

View file

@ -30,7 +30,7 @@ add_filter(
* @see https://wordpress.org/plugins/very-simple-event-list/ * @see https://wordpress.org/plugins/very-simple-event-list/
*/ */
if ( $object->post_type === 'event' ) { 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 new \VS_Event( $object );
} }
// Return the default transformer. // Return the default transformer.
@ -40,6 +40,47 @@ add_filter(
3 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 <a href="%3$s">%1$s settings</a>.',
'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 * Add a filter for http_request_host_is_external
* *

15
readme.txt Normal file
View file

@ -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