2024-10-19 16:46:50 +02:00
< ? php
/**
2024-12-16 17:06:57 +01:00
* Status / Welcome page for the Event Bridge for ActivityPub admin interface .
2024-10-19 16:46:50 +02:00
*
2024-12-05 16:16:30 +01:00
* @ package Event_Bridge_For_ActivityPub
2024-12-09 18:16:07 +01:00
* @ since 1.0 . 0
* @ license AGPL - 3.0 - or - later
2024-10-19 16:46:50 +02:00
*/
// Exit if accessed directly.
defined ( 'ABSPATH' ) || exit ; // @codeCoverageIgnore
2024-12-05 16:16:30 +01:00
use Event_Bridge_For_ActivityPub\Setup ;
use Event_Bridge_For_ActivityPub\Admin\Settings_Page ;
use Event_Bridge_For_ActivityPub\Admin\Health_Check ;
2024-10-19 16:46:50 +02:00
\load_template (
__DIR__ . '/admin-header.php' ,
true ,
array (
'welcome' => 'active' ,
)
);
2024-12-05 16:16:30 +01:00
$active_event_plugins = Setup :: get_instance () -> get_active_event_plugins ();
$event_bridge_for_activitypub_status_ok = true ;
$example_event_post = Health_Check :: get_most_recent_event_posts ();
2024-10-22 18:52:57 +02:00
if ( empty ( $example_event_post ) ) {
$example_event_post = 'https://yoursite.com/events/event-name' ;
$example_event_post_is_dummy = true ;
} else {
$example_event_post = \get_permalink ( $example_event_post [ 0 ] );
$example_event_post_is_dummy = false ;
}
2024-10-19 16:46:50 +02:00
global $wp_filesystem ;
WP_Filesystem ();
?>
2024-12-05 16:16:30 +01:00
< div class = " event-bridge-for-activitypub-settings event-bridge-for-activitypub-settings-page hide-if-no-js " >
2024-10-19 16:46:50 +02:00
< div class = " box " >
2024-12-05 16:16:30 +01:00
< h2 >< ? php \esc_html_e ( 'Status' , 'event-bridge-for-activitypub' ); ?> </h2>
< p >< ? php \esc_html_e ( 'The Event Bridge for ActivityPub detected the following (activated) event plugins:' , 'event-bridge-for-activitypub' ); ?> </p>
2024-10-19 16:46:50 +02:00
< ? php foreach ( $active_event_plugins as $active_event_plugin ) { ?>
2024-10-22 18:52:57 +02:00
< h3 >< ? php echo esc_html ( $active_event_plugin -> get_plugin_name () ); ?> :</h3>
2024-12-05 16:16:30 +01:00
< ul class = " event-bridge-for-activitypub-list " >
2024-10-22 18:52:57 +02:00
< li >
< ? php
if ( in_array ( $active_event_plugin :: get_post_type (), get_option ( 'activitypub_support_post_types' , array () ), true ) ) {
echo '✅ ' ;
$status_message_post_type_enabled = sprintf (
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
_x (
'The ActivityPub support for the event post type of the plugin <i>%2$s</i> is enabled in the <a href="%3$s">%1$s settings</a>.' ,
'admin notice' ,
2024-12-05 16:16:30 +01:00
'event-bridge-for-activitypub'
2024-10-22 18:52:57 +02:00
),
esc_html ( get_plugin_data ( ACTIVITYPUB_PLUGIN_FILE )[ 'Name' ] ),
esc_html ( $active_event_plugin -> get_plugin_name () ),
admin_url ( 'options-general.php?page=activitypub&tab=settings' )
);
} else {
2024-12-05 16:16:30 +01:00
$event_bridge_for_activitypub_status_ok = false ;
2024-10-22 18:52:57 +02:00
echo '❌ ' ;
$status_message_post_type_enabled = sprintf (
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
_x (
'The post type for events of the plugin <i>%2$s</i> is <b>not enabled</b> in the <a href="%3$s">%1$s settings</a>.' ,
'admin notice' ,
2024-12-05 16:16:30 +01:00
'event-bridge-for-activitypub'
2024-10-22 18:52:57 +02:00
),
esc_html ( get_plugin_data ( ACTIVITYPUB_PLUGIN_FILE )[ 'Name' ] ),
esc_html ( $active_event_plugin -> get_plugin_name () ),
admin_url ( 'options-general.php?page=activitypub&tab=settings' )
);
}
$allowed_html = array (
'a' => array (
'href' => true ,
'title' => true ,
),
'b' => array (),
'i' => array (),
);
echo \wp_kses ( $status_message_post_type_enabled , $allowed_html );
?>
</ li >
2024-10-19 16:46:50 +02:00
< li >
< ? php
if ( Health_Check :: test_if_event_transformer_is_used ( $active_event_plugin ) ) {
2024-10-22 18:52:57 +02:00
echo '✅ ' ;
2024-12-05 16:16:30 +01:00
esc_html_e ( 'The Event Bridge for ActivityPub successfully registered to the ActivityPub plugin.' , 'event-bridge-for-activitypub' );
2024-10-19 16:46:50 +02:00
} else {
2024-12-05 16:16:30 +01:00
$event_bridge_for_activitypub_status_ok = false ;
2024-10-22 18:52:57 +02:00
echo '❌ ' ;
2024-12-05 16:16:30 +01:00
esc_html_e ( 'The Event Bridge for ActivityPub could not register to the ActivityPub plugin.' , 'event-bridge-for-activitypub' );
2024-10-19 16:46:50 +02:00
}
?>
</ li >
2024-10-22 18:52:57 +02:00
</ ul >
< ? php } ?>
2024-10-19 16:46:50 +02:00
</ div >
2024-12-05 16:16:30 +01:00
< ? php if ( get_option ( 'event_bridge_for_activitypub_initially_activated' , true ) ) : ?>
2024-10-19 16:46:50 +02:00
< a href = " <?php echo esc_url( admin_url( 'options-general.php?page=' . Settings_Page::SETTINGS_SLUG ) . '&tab=settings' ); ?> " role = " button " >
< button class = " button button-primary " >
2024-12-05 16:16:30 +01:00
< strong > → </ strong > < ? php \esc_html_e ( 'Continue your setup' , 'event-bridge-for-activitypub' ); ?>
2024-10-19 16:46:50 +02:00
</ button >
</ a >
< ? php else : ?>
2024-10-22 18:52:57 +02:00
< div class = " box " >
2024-12-05 16:16:30 +01:00
< h2 >< ? php \esc_html_e ( 'How to Check if It\'s Working' , 'event-bridge-for-activitypub' ); ?> </h2>
2024-10-22 18:52:57 +02:00
< ? php
2024-12-05 16:16:30 +01:00
if ( ! $event_bridge_for_activitypub_status_ok ) {
echo '<div class="notice-warning"><p>' . \esc_html__ ( 'Please fix the status issues above first.' , 'event-bridge-for-activitypub' ) . '</p></div>' ;
2024-10-22 18:52:57 +02:00
}
?>
2024-12-05 16:16:30 +01:00
< p >< ? php esc_html_e ( 'Most of the magic happens behind the scenes, but here is how you can verify that your events are ready to be discovered:' , 'event-bridge-for-activitypub' ); ?> </p>
< div class = " event-bridge-for-activitypub-settings-accordion " >
< h4 class = " event-bridge-for-activitypub-settings-accordion-heading " >
< button aria - expanded = " false " class = " event-bridge-for-activitypub-settings-accordion-trigger " aria - controls = " event-bridge-for-activitypub-help-accordion-mastodon " type = " button " >
2024-10-22 18:52:57 +02:00
< span class = " title " >
1.
2024-12-05 16:16:30 +01:00
< img src = " <?php echo esc_url( plugins_url( '/assets/img/mastodon.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?> " alt = " Mastodon Icon " class = " event-bridge-for-activitypub-settings-inline-icon " >
< ? php \esc_html_e ( 'Using Your Mastodon Account' , 'event-bridge-for-activitypub' ); ?>
2024-10-22 18:52:57 +02:00
</ span >
< span class = " icon " ></ span >
</ button >
</ h4 >
2024-12-05 16:16:30 +01:00
< div id = " event-bridge-for-activitypub-help-accordion-mastodon " class = " event-bridge-for-activitypub-settings-accordion-panel " hidden = " hidden " >
< ol class = " event-bridge-for-activitypub-settings-numbered-list " >
< li >< ? php \esc_html_e ( 'Log into your Mastodon account.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
< li >
2024-12-05 16:16:30 +01:00
< ? php \esc_html_e ( 'In the search bar, type or copy the full URL of one of your event pages. For example:' , 'event-bridge-for-activitypub' ); ?>
< code class = " event-bridge-for-activitypub-settings-example-url " >< ? php echo \esc_url ( $example_event_post ); ?> </code>
2024-10-22 18:52:57 +02:00
</ li >
2024-12-05 16:16:30 +01:00
< li >< ? php \esc_html_e ( 'If everything is set up correctly, you\'ll see a post representing your event. It should include the event\'s image, title, and a brief description.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
</ ol >
</ div >
2024-12-05 16:16:30 +01:00
< h4 class = " event-bridge-for-activitypub-settings-accordion-heading " >
< button aria - expanded = " false " class = " event-bridge-for-activitypub-settings-accordion-trigger " aria - controls = " event-bridge-for-activitypub-help-accordion-mobilizon " type = " button " >
2024-10-22 18:52:57 +02:00
< span class = " title " >
2.
2024-12-05 16:16:30 +01:00
< img src = " <?php echo esc_url( plugins_url( '/assets/img/mobilizon.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?> " alt = " Mastodon Icon " class = " event-bridge-for-activitypub-settings-inline-icon " >
< ? php \esc_html_e ( 'Using Your Mobilizon Account' , 'event-bridge-for-activitypub' ); ?>
2024-10-22 18:52:57 +02:00
</ span >
< span class = " icon " ></ span >
</ button >
</ h4 >
2024-12-05 16:16:30 +01:00
< div id = " event-bridge-for-activitypub-help-accordion-mobilizon " class = " event-bridge-for-activitypub-settings-accordion-panel " hidden = " hidden " >
< ol class = " event-bridge-for-activitypub-settings-numbered-list " >
< li >< ? php \esc_html_e ( 'Log into your Mobilizon account.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
< li >
2024-12-05 16:16:30 +01:00
< ? php \esc_html_e ( 'In the search bar, type or copy the full URL of one of your event pages. For example:' , 'event-bridge-for-activitypub' ); ?>
< code class = " event-bridge-for-activitypub-settings-example-url " >< ? php echo \esc_url ( $example_event_post ); ?> </code>
2024-10-22 18:52:57 +02:00
</ li >
2024-12-05 16:16:30 +01:00
< li >< ? php \esc_html_e ( 'If everything is set up correctly, you\'ll see a full representation of your WordPress event. This will include the event\'s banner image, title, complete description, start and end times, categories, tags, and whether it\'s an online event.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
</ ol >
</ div >
2024-12-05 16:16:30 +01:00
< h4 class = " event-bridge-for-activitypub-settings-accordion-heading " >
< button aria - expanded = " false " class = " event-bridge-for-activitypub-settings-accordion-trigger " aria - controls = " event-bridge-for-activitypub-help-accordion-fediverse " type = " button " >
2024-10-22 18:52:57 +02:00
< span class = " title " >
3.
2024-12-05 16:16:30 +01:00
< img src = " <?php echo esc_url( plugins_url( '/assets/img/fediverse.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?> " alt = " Mastodon Icon " class = " event-bridge-for-activitypub-settings-inline-icon " >
< ? php \esc_html_e ( 'Using Any Other Fediverse Application' , 'event-bridge-for-activitypub' ); ?>
2024-10-22 18:52:57 +02:00
</ span >
< span class = " icon " ></ span >
</ button >
</ h4 >
2024-12-05 16:16:30 +01:00
< div id = " event-bridge-for-activitypub-help-accordion-fediverse " class = " event-bridge-for-activitypub-settings-accordion-panel " hidden = " hidden " >
< p >< ? php \esc_html_e ( 'Of course any other application in the Fediverse should work as well. Most applications support importing external content via searching for the contents full URL.' , 'event-bridge-for-activitypub' ); ?> </p>
< ol class = " event-bridge-for-activitypub-settings-numbered-list " >
< li >< ? php \esc_html_e ( 'Log into your account on any Fediverse app.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
< li >
2024-12-05 16:16:30 +01:00
< ? php \esc_html_e ( 'In the search bar, type or copy the full URL of one of your event pages. For example:' , 'event-bridge-for-activitypub' ); ?>
< code class = " event-bridge-for-activitypub-settings-example-url " >< ? php echo \esc_url ( $example_event_post ); ?> </code>
2024-10-22 18:52:57 +02:00
</ li >
2024-12-05 16:16:30 +01:00
< li >< ? php \esc_html_e ( 'If the application which your are using natively supports ActivityPub events, you should see a representation of your WordPress event. If your application is supports receiving ActivityPub events you will get a post which summarizes the event. Keep in mind that some apps may not support events at all.' , 'event-bridge-for-activitypub' ); ?> </li>
2024-10-22 18:52:57 +02:00
</ ol >
</ div >
2024-12-05 16:16:30 +01:00
< h4 class = " event-bridge-for-activitypub-settings-accordion-heading " >
< button aria - expanded = " false " class = " event-bridge-for-activitypub-settings-accordion-trigger " aria - controls = " event-bridge-for-activitypub-help-accordion-advanced " type = " button " >
2024-10-22 18:52:57 +02:00
< span class = " title " >
4.
2024-12-05 16:16:30 +01:00
< img src = " <?php echo esc_url( plugins_url( '/assets/img/activitypub.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?> " alt = " Mastodon Icon " class = " event-bridge-for-activitypub-settings-inline-icon " >
< ? php \esc_html_e ( 'Advanced: Verifying the ActivityStreams JSON' , 'event-bridge-for-activitypub' ); ?> </span>
2024-10-22 18:52:57 +02:00
< span class = " icon " ></ span >
</ button >
</ h4 >
2024-12-05 16:16:30 +01:00
< div id = " event-bridge-for-activitypub-help-accordion-advanced " class = " event-bridge-for-activitypub-settings-accordion-panel " hidden = " hidden " >
2024-10-22 18:52:57 +02:00
< p >
< ? php
// Assume $event_url contains the dynamic URL, and '?activitypub' is appended to it.
$activitypub_url = esc_url ( $example_event_post . '?activitypub' );
// Prepare the activitypub part wrapped in a <code> element.
$activitypub_query = '<nobr><code>' . esc_html ( '?activitypub' ) . '</code></nobr>' ;
$activitypub_url_html = '<a href="' . esc_url ( $activitypub_url ) . '" target="_blank">' . esc_html ( $activitypub_url ) . '</a>' ;
// Translator comment to explain the placeholder.
/* translators: %1$s is the <code>?activitypub</code> string, and %2$s is the full URL of an example event */
2024-12-05 16:16:30 +01:00
$raw_string = sprintf ( __ ( 'For more technical users, you can inspect how your event is converted into an ActivityPub object. Simply append %1$s to the end of any single event pages URL to view the raw ActivityStreams JSON data (e.g., %2$s).' , 'event-bridge-for-activitypub' ), $activitypub_query , $activitypub_url_html );
2024-10-22 18:52:57 +02:00
// Allowed HTML tags in the string (only <code> and <a>).
$allowed_html = array (
'a' => array (
'href' => array (),
'target' => array (),
),
'nobr' => array (),
'code' => array (),
);
// Output the formatted string with the allowed HTML elements.
echo wp_kses ( $raw_string , $allowed_html );
?>
</ p >
</ div >
</ div >
</ div >
2024-10-19 16:46:50 +02:00
< div class = " box " >
2024-12-05 16:16:30 +01:00
< h2 >< ? php \esc_html_e ( 'Changelog' , 'event-bridge-for-activitypub' ); ?> </h2>
2024-10-19 16:46:50 +02:00
< pre >
< ? php
2024-12-05 16:16:30 +01:00
$changelog = $wp_filesystem -> get_contents ( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/CHANGELOG.md' );
2024-10-19 16:46:50 +02:00
echo esc_html ( substr ( $changelog , strpos ( $changelog , " \n " , 180 ) + 1 ) );
?>
</ pre >
</ div >
< ? php endif ; ?>
</ div >