installed plugin Event Bridge for ActivityPub version 1.1.0

This commit is contained in:
2025-04-29 21:32:06 +00:00
committed by Gitium
parent fc3d7ab181
commit cf022e2628
93 changed files with 14432 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,45 @@
<?php
/**
* Template for the header and navigation of the admin pages.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
/* @var array $args Template arguments. */
$args = wp_parse_args(
$args,
array(
'welcome' => '',
'settings' => '',
'event-sources' => '',
)
);
?>
<div class="event-bridge-for-activitypub-settings-header">
<!-- <div class="event-bridge-for-activitypub-settings-title-section">
<h1><?php \esc_html_e( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ); ?></h1>
</div> -->
<nav class="event-bridge-for-activitypub-settings-tabs-wrapper" aria-label="<?php \esc_attr_e( 'Tertiary menu', 'event-bridge-for-activitypub' ); ?>">
<a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=event-bridge-for-activitypub' ) ); ?>" class="event-bridge-for-activitypub-settings-tab <?php echo \esc_attr( $args['welcome'] ); ?>">
<?php \esc_html_e( 'Overview & Status', 'event-bridge-for-activitypub' ); ?>
</a>
<a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=event-bridge-for-activitypub&subpage=settings' ) ); ?>" class="event-bridge-for-activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>">
<?php \esc_html_e( 'Event Bridge Settings', 'event-bridge-for-activitypub' ); ?>
</a>
<a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=event-bridge-for-activitypub&subpage=event-sources' ) ); ?>" class="event-bridge-for-activitypub-settings-tab <?php echo \esc_attr( $args['event-sources'] ); ?>">
<?php \esc_html_e( 'Federated Event Sources', 'event-bridge-for-activitypub' ); ?>
</a>
</nav>
</div>
<?php
\Event_Bridge_For_ActivityPub\Admin\Settings_Page::do_settings_page();

View File

@ -0,0 +1,236 @@
<?php
/**
* Event Sources management page for the ActivityPub Event Bridge.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Event_Bridge_For_ActivityPub\Setup;
\load_template(
__DIR__ . '/../menu.php',
true,
array(
'event-sources' => 'active',
)
);
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$activitypub_plugin_is_active = Setup::get_instance()->is_activitypub_plugin_active();
\get_option( 'event_bridge_for_activitypub_event_sources_active', false );
if ( ! isset( $args ) || ! array_key_exists( 'supports_event_sources', $args ) ) {
return;
}
$event_plugins_supporting_event_sources = $args['supports_event_sources'];
$event_sources_active = \get_option( 'event_bridge_for_activitypub_event_sources_active', false );
$cache_retention_period = \get_option( 'event_bridge_for_activitypub_event_source_cache_retention', DAY_IN_SECONDS );
?>
<?php if ( $activitypub_plugin_is_active ) { ?>
<div class="activitypub-settings hide-if-no-js">
<form method="post" action="options.php">
<?php \settings_fields( 'event-bridge-for-activitypub_event-sources' ); ?>
<div class="box">
<h2><?php \esc_html_e( 'Event Sources', 'event-bridge-for-activitypub' ); ?></h2>
<p id="event-sources-description"><?php esc_html_e( 'This feature allows your WordPress site to retrieve and display events from external sources via ActivityPub. Once enabled, you can add any ActivityPub account as a source of events by following that profile. These events will be cached on your site and seamlessly integrated into your existing event calendar, creating a unified view of events from both internal and external sources.', 'event-bridge-for-activitypub' ); ?></p>
<?php
if ( ! \Activitypub\is_user_type_disabled( 'blog' ) && count( $event_plugins_supporting_event_sources ) ) {
?>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_event_sources_active"><?php \esc_html_e( 'Enable External Event Sources', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<input
type="checkbox"
name="event_bridge_for_activitypub_event_sources_active"
id="event_bridge_for_activitypub_event_sources_active"
aria-describedby="event-sources-description"
value="1"
<?php echo \checked( $event_sources_active ); ?>
>
</td>
</tr>
<?php
if ( $event_sources_active ) {
?>
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_integration_used_for_event_sources_feature"><?php \esc_html_e( 'Event Plugin', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<select
name="event_bridge_for_activitypub_integration_used_for_event_sources_feature"
id="event_bridge_for_activitypub_integration_used_for_event_sources_feature"
value="gatherpress"
aria-describedby="event-sources-used-plugin-description"
>
<?php
foreach ( $event_plugins_supporting_event_sources as $event_plugin_class_name => $event_plugin_name ) {
echo '<option value="' . esc_attr( $event_plugin_class_name ) . '" ' . selected( $event_plugin_class_name, Setup::get_event_plugin_integration_used_for_event_sources_feature(), true ) . '>' . esc_attr( $event_plugin_name ) . '</option>';
}
?>
</select>
<p id="event-sources-used-plugin-description"><?php esc_html_e( 'In case you have multiple event plugins installed you might choose which event plugin is utilized.', 'event-bridge-for-activitypub' ); ?></p>
</td>
<tr>
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_event_source_cache"><?php \esc_html_e( 'Retention Period for External Events', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<select
name="event_bridge_for_activitypub_event_source_cache_retention"
id="event_bridge_for_activitypub_event_source_cache_retention"
value="0"
aria-describedby="event_bridge_for_activitypub_event-sources-cache-clear-time-frame"
>
<?php
$choices = array(
0 => __( 'Immediately', 'event-bridge-for-activitypub' ),
DAY_IN_SECONDS => __( 'One Day', 'event-bridge-for-activitypub' ),
WEEK_IN_SECONDS => __( 'One Week', 'event-bridge-for-activitypub' ),
MONTH_IN_SECONDS => __( 'One Month', 'event-bridge-for-activitypub' ),
YEAR_IN_SECONDS => __( 'One Year', 'event-bridge-for-activitypub' ),
);
foreach ( $choices as $time => $string ) {
echo '<option value="' . \esc_attr( $time ) . '" ' . \selected( $cache_retention_period, $time, true ) . '>' . \esc_attr( $string ) . '</option>';
}
?>
</select>
<p id="event_bridge_for_activitypub_event-sources-cache-clear-time-frame"><?php esc_html_e( 'External events from your event sources will be automatically removed from your site after the selected time period has passed since the event ended. Choose a time frame that works best for your needs.', 'event-bridge-for-activitypub' ); ?></p>
</td>
<tr>
<?php
}
?>
<tbody>
</table>
<?php
} elseif ( ! \Activitypub\is_user_type_disabled( 'blog' ) ) {
?>
<div class="notice-warning"><p><?php esc_html_e( 'You do not have an Event Plugin installed that supports this feature.', 'event-bridge-for-activitypub' ); ?></p></div>
<p><?php \esc_html_e( 'The following Event Plugins are supported:', 'event-bridge-for-activitypub' ); ?></p>
<?php
$plugins_supporting_event_sources = Setup::detect_event_plugins_supporting_event_sources();
echo '<ul class="event_bridge_for_activitypub-list">';
foreach ( $plugins_supporting_event_sources as $event_plugin ) {
echo '<li>' . esc_attr( $event_plugin->get_plugin_name() ) . '</li>';
}
echo '</ul>';
} else {
$activitypub_plugin_data = \get_plugin_data( ACTIVITYPUB_PLUGIN_FILE );
$notice = sprintf(
/* translators: 1: The name of the ActivityPub plugin. */
_x(
'In order to use this feature your have to enable the Blog-Actor in the the <a href="%1$s">%2$s settings</a>.',
'admin notice',
'event-bridge-for-activitypub'
),
\admin_url( 'options-general.php?page=activitypub&tab=event-bridge-for-activitypub&subpage=settings' ),
\esc_html( $activitypub_plugin_data['Name'] )
);
$allowed_html = array(
'a' => array(
'href' => true,
'title' => true,
),
);
echo '<div class="notice-warning"><p>' . \wp_kses( $notice, $allowed_html ) . '</p></div>';
}
?>
</div>
<?php \submit_button(); ?>
</form>
</div>
<div class="wrap event_bridge_for_activitypub-admin-table-container">
<br>
<?php
if ( \get_option( 'event_bridge_for_activitypub_event_sources_active', false ) ) {
?>
<!-- ThickBox content (hidden initially) -->
<div id="Event_Bridge_For_ActivityPub_add_new_source" style="display:none;">
<h2><?php \esc_html_e( 'Add a Trusted Event Source', 'event-bridge-for-activitypub' ); ?></h2>
<ul class="event-bridge-for-activitypub-syntax-list" id="event_bridge_for_activitypub_add_event_source_description">
<?php \esc_html_e( 'Use one of the following syntax:', 'event-bridge-for-activitypub' ); ?>
<li>
<?php \esc_html_e( 'Enter a Fediverse user handle', 'event-bridge-for-activitypub' ); ?> ( <?php esc_html_e( 'e.g.', 'event-bridge-for-activitypub' ); ?> <code>@username@example.social</code>)
</li>
<li>
<?php \esc_html_e( 'ActivityPub account URL or ID', 'event-bridge-for-activitypub' ); ?> ( <?php esc_html_e( 'e.g.', 'event-bridge-for-activitypub' ); ?> <code>https://example.social/user/username</code>)
</li>
<li>
<?php \esc_html_e( 'The domain or URL of a Gancio instance', 'event-bridge-for-activitypub' ); ?> ( <?php esc_html_e( 'e.g.', 'event-bridge-for-activitypub' ); ?> <code>https://demo.gancio.org</code>)
</li>
</ul>
<div class="notice notice-info inline">
<p>
<?php
$number_of_imports = \Event_Bridge_For_ActivityPub\Outbox_Parser::MAX_EVENTS_TO_IMPORT;
$notice = sprintf(
/* translators: 1: The maximum number of imported events. */
__( 'To ensure a smooth start, up to %d upcoming events from this source will be automatically imported soon after adding it.', 'event-bridge-for-activitypub' ),
$number_of_imports
);
echo esc_html( $notice );
?>
</p>
</div>
<form method="post" action="options.php">
<?php \settings_fields( 'event-bridge-for-activitypub_add-event-source' ); ?>
<label for="event_bridge_for_activitypub_add_event_source">
<p>
<?php \esc_html_e( 'Event Source (handle, URL, or instance)', 'event-bridge-for-activitypub' ); ?>:
</p>
</label>
<input
type="text"
style="width: 100%"
name="event_bridge_for_activitypub_add_event_source"
id="event_bridge_for_activitypub_add_event_source"
aria-describedby="event_bridge_for_activitypub_add_event_source_description"
placeholder="@username@example.social or https://example.social/user/username">
<?php \submit_button( __( 'Follow Event Source', 'event-bridge-for-activitypub' ) ); ?>
</form>
</div>
<div class="wrap activitypub-followers-page">
<!-- Table title with add new button like on post edit pages -->
<div class="event_bridge_for_activitypub-admin-table-top">
<h2 class="wp-heading-inline"> <?php esc_html_e( 'Manage Event Sources', 'event-bridge-for-activitypub' ); ?> </h2>
<!-- Button that triggers ThickBox -->
<a href="#TB_inline?width=600&height=400&inlineId=Event_Bridge_For_ActivityPub_add_new_source" class="thickbox page-title-action">
<?php \esc_html_e( 'Add Event Source', 'event-bridge-for-activitypub' ); ?>
</a>
</div>
<form method="get">
<input type="hidden" name="page" value="activitypub" />
<input type="hidden" name="tab" value="event-bridge-for-activitypub" />
<input type="hidden" name="subpage" value="event-sources" />
<?php
$table = new \Event_Bridge_For_ActivityPub\Table\Event_Sources();
$table->prepare_items();
$table->search_box( 'Search', 'search' );
$table->display();
?>
</form>
</div>
<?php } ?>
</div>
<?php } ?>

View File

@ -0,0 +1,229 @@
<?php
/**
* Template for Event Bridge for ActivityPub settings page.
*
* This template is used to display and manage settings for the Event Bridge for ActivityPub plugin.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later
*
* @param array $args An array of arguments for the settings page.
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub\Activity\Extended_Object\Event;
use Event_Bridge_For_ActivityPub\Setup;
\load_template(
__DIR__ . '/../menu.php',
true,
array(
'settings' => 'active',
)
);
$activitypub_plugin_is_active = Setup::get_instance()->is_activitypub_plugin_active();
if ( ! isset( $args ) || ! array_key_exists( 'event_terms', $args ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$event_terms = $args['event_terms'];
require_once EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/event-categories.php';
$selected_default_event_category = \get_option( 'event_bridge_for_activitypub_default_event_category', 'MEETING' );
$current_category_mapping = \get_option( 'event_bridge_for_activitypub_event_category_mappings', array() );
$reminder_time_gap = \get_option( 'event_bridge_for_activitypub_reminder_time_gap', 0 );
$reminder_time_gap_choices = array(
0 => __( 'Disabled', 'event-bridge-for-activitypub' ),
HOUR_IN_SECONDS * 6 => __( '6 hours', 'event-bridge-for-activitypub' ),
DAY_IN_SECONDS => __( '1 day', 'event-bridge-for-activitypub' ),
DAY_IN_SECONDS * 3 => __( '3 days', 'event-bridge-for-activitypub' ),
WEEK_IN_SECONDS => __( '1 week', 'event-bridge-for-activitypub' ),
);
if ( \get_option( 'event_bridge_for_activitypub_initially_activated' ) ) {
\update_option( 'event_bridge_for_activitypub_initially_activated', '' );
}
?>
<div class="activitypub-settings hide-if-no-js">
<form method="post" action="options.php">
<?php \settings_fields( 'event-bridge-for-activitypub' ); ?>
<div class="box">
<h2> <?php esc_html_e( 'Event Summary', 'event-bridge-for-activitypub' ); ?> </h2>
<p><?php esc_html_e( 'Many Fediverse applications (e.g., Mastodon) don\'t fully support events, instead they will show a summary text along with the events title and the URL to your Website.', 'event-bridge-for-activitypub' ); ?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_summary_format_type"> <?php esc_html_e( 'Event Summary Text', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<p>
<label for="event_bridge_for_activitypub_summary_type_preset">
<input type="radio" name="event_bridge_for_activitypub_summary_type" id="event_bridge_for_activitypub_summary_type_preset" value="preset" <?php echo \checked( 'preset', \get_option( 'event_bridge_for_activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
<?php \esc_html_e( 'Automatic (default)', 'event-bridge-for-activitypub' ); ?>
-
<span class="description">
<?php \esc_html_e( 'Let the plugin compose a summary for you. ', 'event-bridge-for-activitypub' ); ?>
</span>
</label>
</p>
<p>
<label for="event_bridge_for_activitypub_summary_type_custom">
<input type="radio" name="event_bridge_for_activitypub_summary_type" id="event_bridge_for_activitypub_summary_type_custom" value="custom" <?php echo \checked( 'custom', \get_option( 'event_bridge_for_activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
<?php \esc_html_e( 'Custom', 'event-bridge-for-activitypub' ); ?>
-
<span class="description">
<?php \esc_html_e( 'For advanced users: compose your custom summary via shortcodes.', 'event-bridge-for-activitypub' ); ?>
</span>
</label>
</p>
<div id="event_bridge_for_activitypub_summary_type_custom-details">
<textarea name="event_bridge_for_activitypub_custom_summary" id="event_bridge_for_activitypub_custom_summary" rows="10" cols="50" class="large-text"><?php echo esc_textarea( wp_kses( \get_option( 'event_bridge_for_activitypub_custom_summary', EVENT_BRIDGE_FOR_ACTIVITYPUB_SUMMARY_TEMPLATE ), 'post' ) ); ?></textarea>
<details>
<summary><?php esc_html_e( 'See a list Template Tags available for the summary.', 'event-bridge-for-activitypub' ); ?></summary>
<div class="description">
<dl>
<dt><code>[ap_start_time icon="true" label="true"]</code><dt>
<dd><?php \esc_html_e( 'The events title.', 'event-bridge-for-activitypub' ); ?></dd>
<dt><code>[ap_end_time icon="true" label="true"]</code><dt>
<dd><?php \esc_html_e( 'The events content.', 'event-bridge-for-activitypub' ); ?></dd>
<dt><code>[ap_location icon="true" label="true"]</code><dt>
<dd><?php \esc_html_e( 'The events location.', 'event-bridge-for-activitypub' ); ?></dd>
<dt><code>[ap_hashtags]</code><dt>
<dd><?php \esc_html_e( 'The events tags as hashtags.', 'event-bridge-for-activitypub' ); ?></dd>
<dt><code>[ap_excerpt]</code><dt>
<dd><?php \esc_html_e( 'The events excerpt (may be truncated).', 'event-bridge-for-activitypub' ); ?></dd>
<dt><code>[ap_content]</code><dt>
<dd><?php \esc_html_e( 'The events description.', 'event-bridge-for-activitypub' ); ?></dd>
</dl>
</div>
</details>
</div>
</td>
</tr>
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_summary_format"> <?php esc_html_e( 'Enforce plain text in summary', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<p>
<input type="checkbox" aria-describedby="event_bridge_for_activitypub_summary_format_description" name="event_bridge_for_activitypub_summary_format" id="event_bridge_for_activitypub_summary_format" value="plain" <?php echo \checked( 'plain', \get_option( 'event_bridge_for_activitypub_summary_format', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
<span id="event_bridge_for_activitypub_summary_format_description">
<?php
$allowed_html = array(
'code' => array(),
);
echo \wp_kses( __( 'Many Fediverse applications, including Mastodon before version 4.3.0, do not render summaries as HTML. Enable this option to send the summary as plain text for better compatibility (e.g., <code>&lt;ul&gt;&lt;li&gt;Item 1&lt;/li&gt;&lt;/ul&gt;</code> will be sent as \'Item 1\' without formatting).', 'event-bridge-for-activitypub' ), $allowed_html );
?>
</span>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="box">
<h2> <?php esc_html_e( 'ActivityPub Event Category', 'event-bridge-for-activitypub' ); ?> </h2>
<p id="event_bridge_for_activitypub_default_event_category_desc"> <?php esc_html_e( 'To help visitors find events more easily, the community created a set of basic event categories. Please select the category that best matches the majority of the events you organize.', 'event-bridge-for-activitypub' ); ?> </p>
<table class="form-table">
<tr>
<th scope="row">
<label for="event_bridge_for_activitypub_default_event_category"> <?php esc_html_e( 'Default Federated Event Category', 'event-bridge-for-activitypub' ); ?></label>
</th>
<td>
<select aria-describedby="event_bridge_for_activitypub_default_event_category_desc" id="event_bridge_for_activitypub_default_event_category" name="event_bridge_for_activitypub_default_event_category">';
<?php
foreach ( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $selected_default_event_category, $value, false ) . '>' . esc_html( $label ) . '</option>';
}
?>
</select>
</td>
</tr>
</table>
<?php if ( ! empty( $event_terms ) ) : ?>
<h3> <?php esc_html_e( 'Fine-grained Event Category Settings', 'event-bridge-for-activitypub' ); ?> </h3>
<p id="event_bridge_for_activitypub_event_category_mapping_desc"> <?php esc_html_e( 'For any event category you have created on your WordPress site you can choose an event category which will be used in federation. This option lets you override the default selection above. ', 'event-bridge-for-activitypub' ); ?> </p>
<table class="form-table">
<tr>
<th> <?php esc_html_e( 'Event category on your site', 'event-bridge-for-activitypub' ); ?> </th>
<th> <?php esc_html_e( 'Fediverse event category', 'event-bridge-for-activitypub' ); ?> </th>
</tr>
<?php foreach ( $event_terms as $event_term ) { ?>
<tr>
<td scope="row">
<label for="event_bridge_for_activitypub_event_category_mapping_<?php echo esc_attr( $event_term->slug ); ?>"">
<?php echo esc_html( $event_term->name ); ?> </td>
</label>
<td class="select-cell">
<select aria-describedby="event_bridge_for_activitypub_event_category_mapping_desc" id="event_bridge_for_activitypub_event_category_mapping_<?php echo esc_attr( $event_term->slug ); ?>" name="event_bridge_for_activitypub_event_category_mappings[<?php echo esc_attr( $event_term->slug ); ?>]">
<?php
$current_mapping_is_set = false;
if ( ! empty( $current_category_mapping ) ) {
$current_mapping_is_set = array_key_exists( $event_term->slug, $current_category_mapping );
}
if ( $current_mapping_is_set ) {
$mapping = $current_category_mapping[ $event_term->slug ];
} else {
$mapping = 'DEFAULT';
}
if ( 'DEFAULT' === $mapping ) {
echo '<option value="' . esc_attr( $mapping ) . '"> -- ' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $mapping ] ) . ' -- </option>';
} else {
echo '<option value="' . esc_attr( $mapping ) . '">' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $mapping ] ) . '</option>';
}
echo '<option value="DEFAULT" ' . selected( $selected_default_event_category, 'DEFAULT', false ) . '> -- ' . esc_html__( 'Default', 'event-bridge-for-activitypub' ) . ' -- </option>';
foreach ( Event::DEFAULT_EVENT_CATEGORIES as $event_category ) {
echo '<option value="' . esc_attr( $event_category ) . '" ' . selected( $mappings[ $event_term->slug ] ?? '', $event_category, false ) . '>' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $event_category ] ) . '</option>';
}
?>
</select>
</td>
</tr>
<?php } ?>
</table>
<?php endif; ?>
</div>
<div class="box">
<h2> <?php esc_html_e( 'Send reminder before event starts', 'event-bridge-for-activitypub' ); ?> </h2>
<p> <?php esc_html_e( 'Specify a time interval before the event starts to trigger a reminder. This reminder automatically boosts the event, making it reappear in users\' timelines at the defined time before the event to increase visibility just before the event begins.', 'event-bridge-for-activitypub' ); ?> </p>
<table class="form-table">
<tr>
<label for="event_bridge_for_activitypub_reminder_time_gap">
<th scope="row"> <?php esc_html_e( 'Default Time Gap for Reminders', 'event-bridge-for-activitypub' ); ?> </th>
</label>
<td>
<select id="event_bridge_for_activitypub_reminder_time_gap" name="event_bridge_for_activitypub_reminder_time_gap">';
<?php
foreach ( $reminder_time_gap_choices as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $reminder_time_gap, $value, false ) . '>' . esc_html( $label ) . '</option>';
}
?>
</select>
<br><br>
<?php esc_html_e( 'This default value can be overridden for each event. Note that override is only available in the User Interface if you use the Gutenberg editor.', 'event-bridge-for-activitypub' ); ?>
</td>
</tr>
</table>
</div>
<!-- This disables the setup wizard. -->
<div class="hidden" aria-hidden="true">
<input type="checkbox" id="event_bridge_for_activitypub_initially_activated" name="event_bridge_for_activitypub_initially_activated"/>
</div>
<?php \submit_button(); ?>
</form>
</div>

View File

@ -0,0 +1,250 @@
<?php
/**
* Status/Welcome page for the Event Bridge for ActivityPub admin interface.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Event_Bridge_For_ActivityPub\Setup;
use Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices;
use Event_Bridge_For_ActivityPub\Admin\Settings_Page;
use Event_Bridge_For_ActivityPub\Admin\Health_Check;
\load_template(
__DIR__ . '/../menu.php',
true,
array(
'welcome' => 'active',
)
);
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
$activitypub_plugin_is_active = Setup::get_instance()->is_activitypub_plugin_active();
$event_bridge_for_activitypub_status_ok = true;
$example_event_post = Health_Check::get_most_recent_event_posts();
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;
}
global $wp_filesystem;
WP_Filesystem();
?>
<div class="activitypub-settings event-bridge-for-activitypub-settings event-bridge-for-activitypub-settings-page hide-if-no-js">
<div class="box">
<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>
<?php
if ( ! $activitypub_plugin_is_active ) {
$notice = General_Admin_Notices::get_admin_notice_activitypub_plugin_not_enabled();
echo '<p>⚠' . \wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ) . '</p>';
} elseif ( empty( $active_event_plugins ) ) {
$notice = General_Admin_Notices::get_admin_notice_no_supported_event_plugin_active();
echo '<p>⚠' . \wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ) . '</p>';
}
?>
<?php foreach ( $active_event_plugins as $active_event_plugin ) { ?>
<h3><?php echo esc_html( $active_event_plugin->get_plugin_name() ); ?>:</h3>
<ul class="event-bridge-for-activitypub-list">
<li>
<?php
if ( in_array( $active_event_plugin::get_post_type(), get_option( 'activitypub_support_post_types', array() ), true ) ) {
echo '&#9989 ';
$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',
'event-bridge-for-activitypub'
),
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=event-bridge-for-activitypub&subpage=settings' )
);
} else {
$event_bridge_for_activitypub_status_ok = false;
echo '&#10060 ';
$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',
'event-bridge-for-activitypub'
),
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=event-bridge-for-activitypub&subpage=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>
<li>
<?php
if ( Health_Check::test_if_event_transformer_is_used( $active_event_plugin ) ) {
echo '&#9989 ';
esc_html_e( 'The Event Bridge for ActivityPub successfully registered to the ActivityPub plugin.', 'event-bridge-for-activitypub' );
} else {
$event_bridge_for_activitypub_status_ok = false;
echo '&#10060 ';
esc_html_e( 'The Event Bridge for ActivityPub could not register to the ActivityPub plugin.', 'event-bridge-for-activitypub' );
}
?>
</li>
</ul>
<?php } ?>
</div>
<?php if ( get_option( 'event_bridge_for_activitypub_initially_activated', true ) ) : ?>
<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">
<strong>→</strong> <?php \esc_html_e( 'Continue your setup', 'event-bridge-for-activitypub' ); ?>
</button>
</a>
<?php else : ?>
<div class="box">
<h2><?php \esc_html_e( 'How to Check if It\'s Working', 'event-bridge-for-activitypub' ); ?></h2>
<?php
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>';
}
?>
<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">
<span class="title">
1.
<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' ); ?>
</span>
<span class="icon"></span>
</button>
</h4>
<div id="event-bridge-for-activitypub-help-accordion-mastodon" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
<div class="notice notice-warning inline"><p> <?php \esc_html_e( 'Note that Mastodon can receive ActivityPub Event objects but does not yet support updating them. This means that if Mastodon has already received an event, it will always display the first version it encountered.', 'event-bridge-for-activitypub' ); ?> <?php esc_html_e( 'See the related tracking issue:', 'event-bridge-for-activitypub' ); ?> <a href="https://github.com/mastodon/mastodon/issues/31114" target="_blank">https://github.com/mastodon/mastodon/issues/31114</a></p></div>
<ol class="event-bridge-for-activitypub-settings-numbered-list">
<li><?php \esc_html_e( 'Log into your Mastodon account.', 'event-bridge-for-activitypub' ); ?></li>
<li>
<?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>
</li>
<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>
</ol>
</div>
<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">
<span class="title">
2.
<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' ); ?>
</span>
<span class="icon"></span>
</button>
</h4>
<div id="event-bridge-for-activitypub-help-accordion-mobilizon" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
<div class="notice notice-error inline"><p>⚠️ <?php \esc_html_e( 'Note that Mobilizon has significant interoperability issues (at least up to version 5.1).', 'event-bridge-for-activitypub' ); ?> <?php esc_html_e( 'See the related tracking issue:', 'event-bridge-for-activitypub' ); ?> <a href="https://framagit.org/framasoft/mobilizon/-/issues/1669" target="_blank">https://framagit.org/framasoft/mobilizon/-/issues/1669</a></p></div>
<!-- <ol class="event-bridge-for-activitypub-settings-numbered-list">
<li><?php \esc_html_e( 'Log into your Mobilizon account.', 'event-bridge-for-activitypub' ); ?></li>
<li>
<?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>
</li>
<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>
</ol> -->
</div>
<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">
<span class="title">
3.
<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' ); ?>
</span>
<span class="icon"></span>
</button>
</h4>
<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>
<li>
<?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>
</li>
<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>
</ol>
</div>
<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">
<span class="title">
4.
<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>
<span class="icon"></span>
</button>
</h4>
<div id="event-bridge-for-activitypub-help-accordion-advanced" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
<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 */
$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 );
// 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>
<div class="box">
<h2><?php \esc_html_e( 'Acknowledgement', 'event-bridge-for-activitypub' ); ?></h2>
<p><a href="https://NLnet.nl"><img src="<?php echo esc_url( plugins_url( '/assets/img/acknowledgement-NLnet.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Logo NLnet: abstract logo of four people seen from above" class="logo-center"></a> <a href="https://NLnet.nl/NGI0"><img src="<?php echo esc_url( plugins_url( '/assets/img/acknowledgement-NGI0Entrust.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Logo NGI Zero: letterlogo shaped like a tag" class="logo-center"> </a></p>
<p>The development of this plugin was funded through the <a href="https://NLnet.nl/entrust">NGI0 Entrust</a> Fund, a fund established by <a href="https://nlnet.nl">NLnet</a> with financial support from the European Commission's <a href="https://ngi.eu">Next Generation Internet</a> programme, under the aegis of <a href="https://commission.europa.eu/about-european-commission/departments-and-executive-agencies/communications-networks-content-and-technology_en">DG Communications Networks, Content and Technology</a> under grant agreement N<sup>o</sup> 101069594.</p>
</div>
<?php endif; ?>
</div>

View File

@ -0,0 +1,13 @@
<?php
/**
* Template for the header and navigation of the admin pages.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
\Event_Bridge_For_ActivityPub\Admin\Settings_Page::do_settings_page();