diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 5fc523b..a5589f9 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -21,7 +21,7 @@ jobs: MYSQL_ROOT_PASSWORD: root strategy: matrix: - php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] wordpress-version: ['6.7'] name: PHPUnit β PHP ${{ matrix.php-version }} env: @@ -38,7 +38,7 @@ jobs: path: | ${{ env.WP_CORE_DIR }} ${{ env.WP_TESTS_DIR }} - key: cache-wordpress-67-2 + key: cache-wordpress-67-4 - name: Cache Composer id: cache-composer-phpunit @@ -82,36 +82,46 @@ jobs: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for The Events Calendar - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=the_events_calendar + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=the_events_calendar env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for VS Event List - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=vs_event_list + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=vs_event_list env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for GatherPress - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=gatherpress + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=gatherpress env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for Events Manager - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=events_manager + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=events_manager env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for WP Event Manager - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=wp_event_manager + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=wp_event_manager env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for Eventin (WP Event Solution) - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=eventin + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=eventin env: PHP_VERSION: ${{ matrix.php-version }} - name: Run Integration tests for Modern Events Calendar Lite - run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=modern_events_calendar_lite + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=modern_events_calendar_lite env: - PHP_VERSION: ${{ matrix.php-version }} \ No newline at end of file + PHP_VERSION: ${{ matrix.php-version }} + + - name: Run Integration tests for EventPrime + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=eventprime + env: + PHP_VERSION: ${{ matrix.php-version }} + + - name: Run Integration tests for Event Organiser + run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=event_organiser + env: + PHP_VERSION: ${{ matrix.php-version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index b1f6405..dd83e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,18 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.2.1] - 2024-11-16 - -### Added +## [0.3.1] - 2024-11-16 * Initial release on WordPress.org -### Fixed - -* Applied some WordPress best practices - -## [0.2.0] - 2024-10-20 - -### Added - -* Initial submission to WordPress.org diff --git a/Gruntfile.js b/Gruntfile.js index df4eb26..4b2c893 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,7 +4,7 @@ module.exports = function (grunt) { { checktextdomain: { options:{ - text_domain: 'activitypub-event-bridge', + text_domain: 'event-bridge-for-activitypub', keywords: [ '__:1,2d', '_e:1,2d', diff --git a/README.md b/README.md index 023e5c2..e52e4a8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# ActivityPub Event Bridge # +# Event Bridge for ActivityPub # **Contributors:** [andremenrath](https://profiles.wordpress.org/andremenrath/) **Tags:** events, fediverse, activitypub, calendar **Requires at least:** 6.5 **Tested up to:** 6.7 -**Stable tag:** 0.2.1 +**Stable tag:** 0.3.1 **Requires PHP:** 7.4 **License:** AGPL-3.0-or-later **License URI:** https://www.gnu.org/licenses/agpl-3.0.html @@ -14,7 +14,7 @@ Integrating popular event plugins with the ActivityPub plugin. ## Description ## Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and be a part of the growing decentralized web (the Fediverse). -With the ActivityPub Event Bridge Plugin for WordPress, your events can be automatically followed, aggregated and displayed across decentralized platforms like [Mastodon](https://joinmastodon.org) or [Gancio](https://gancio.org), without any extra work. +With the Event Bridge for ActivityPub Plugin for WordPress, your events can be automatically followed, aggregated and displayed across decentralized platforms like [Mastodon](https://joinmastodon.org) or [Gancio](https://gancio.org), without any extra work. Forget the hassle of managing multiple social media accounts just to keep your audience informed. This plugin is not an event managing plugin but an add-on to popular event plugins. It extends their functionality to fully support the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). @@ -23,7 +23,7 @@ You retain full ownership of your content. By integrating into your existing set ### How It Works ### -With the ActivityPub Event Bridge WordPress plugin, sharing your events is effortless and automatic! +With the Event Bridge for ActivityPub WordPress plugin, sharing your events is effortless and automatic! Once you create an event on your WordPress site, it is seamlessly shared across the decentralized web using the ActivityPub protocol.
@@ -63,6 +63,8 @@ This plugin depends on the [ActivityPub plugin](https://wordpress.org/plugins/ac * [Eventin](https://de.wordpress.org/plugins/wp-event-solution/) * [Modern Events Calendar Lite](https://webnus.net/modern-events-calendar/) * [GatherPress](https://gatherpress.org/) +* [EventPrime β Events Calendar, Bookings and Tickets](https://wordpress.org/plugins/eventprime-event-calendar-management/) +* [Event Organiser](https://wordpress.org/plugins/event-organiser/) ## Configuration ## @@ -92,18 +94,16 @@ No, the Event Federation Plugin depends on the [ActivityPub plugin](https://word ### My event plugin is not supported, what can I do? ### -If you know about coding have a look at the documentation of how to add your plugin or open an [issue](https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge/issues), if we can spare some free hours we might add it. +If you know about coding have a look at the documentation of how to add your plugin or open an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues), if we can spare some free hours we might add it. ### What if I experience problems? ### -We're always interested in your feedback. Feel free to reach out to us via [E-Mail](https://event-federation.eu/contact/) or create an [issue](https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge/issues). +We're always interested in your feedback. Feel free to reach out to us via [E-Mail](https://event-federation.eu/contact/) or create an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues). ## Changelog ## -### [0.2.1] 2024-11-16 ### +### [0.3.1] 2024-12-05 ### * Initial release on https://wordpress.org/ -### [0.2.0] 2024-10-29 ### -* Initial submission to https://wordpress.org/ diff --git a/activitypub-event-bridge.php b/activitypub-event-bridge.php deleted file mode 100644 index 0276072..0000000 --- a/activitypub-event-bridge.php +++ /dev/null @@ -1,38 +0,0 @@ -= 3.2.2. ActivityPub plugin tested up to: 4.2.0. - * - * @package ActivityPub_Event_Bridge - * @license AGPL-3.0-or-later - */ - -// Exit if accessed directly. -defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore - -define( 'ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_VERSION', current( get_file_data( __FILE__, array( 'Version' ), 'plugin' ) ) ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_DOMAIN', 'activitypub-event-bridge' ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_ACTIVITYPUB_PLUGIN_MIN_VERSION', '3.2.2' ); -define( 'ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY', "
%s
', - \__( 'The transformation of your most recent events was successful.', 'activitypub-event-bridge' ) + \__( 'The transformation of your most recent events was successful.', 'event-bridge-for-activitypub' ) ), 'actions' => '', 'test' => 'test_event_transformation', @@ -68,7 +68,7 @@ class Health_Check { } $result['status'] = 'critical'; - $result['label'] = \__( 'One or more of your most recent events failed to transform to ActivityPub', 'activitypub-event-bridge' ); + $result['label'] = \__( 'One or more of your most recent events failed to transform to ActivityPub', 'event-bridge-for-activitypub' ); $result['badge']['color'] = 'red'; $result['description'] = \sprintf( '%s
', @@ -168,12 +168,12 @@ class Health_Check { * @return array The extended information. */ public static function add_debug_information( $info ) { - $info['activitypub_event_bridge'] = array( - 'label' => __( 'ActivityPub Event Bridge', 'activitypub-event-bridge' ), + $info['event_bridge_for_activitypub'] = array( + 'label' => __( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ), 'fields' => array( 'plugin_version' => array( - 'label' => __( 'Plugin Version', 'activitypub-event-bridge' ), - 'value' => ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_VERSION, + 'label' => __( 'Plugin Version', 'event-bridge-for-activitypub' ), + 'value' => EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION, 'private' => true, ), 'active_event_plugins' => self::get_info_about_active_event_plugins(), diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index b2dbb3e..3a3903f 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -3,32 +3,32 @@ * General settings class. * * This file contains the General class definition, which handles the "General" settings - * page for the Activitypub Event Bridge Plugin, providing options for configuring various general settings. + * page for the Event Bridge for ActivityPub Plugin, providing options for configuring various general settings. * - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Admin; +namespace Event_Bridge_For_ActivityPub\Admin; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore -use ActivityPub_Event_Bridge\Plugins\Event_Plugin; -use ActivityPub_Event_Bridge\Setup; +use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin; +use Event_Bridge_For_ActivityPub\Setup; /** - * Class responsible for the Activitypub Event Bridge related Settings. + * Class responsible for the Event Bridge for ActivityPub related Settings. * - * Class which handles the "General" settings page for the Activitypub Event Bridge Plugin, + * Class which handles the "General" settings page for the Event Bridge for ActivityPub Plugin, * providing options for configuring various general settings. * * @since 1.0.0 */ class Settings_Page { - const STATIC = 'ActivityPub_Event_Bridge\Admin\Settings_Page'; + const STATIC = 'Event_Bridge_For_ActivityPub\Admin\Settings_Page'; - const SETTINGS_SLUG = 'activitypub-event-bridge'; + const SETTINGS_SLUG = 'event-bridge-for-activitypub'; /** * Warning if the plugin is Active and the ActivityPub plugin is not. * @@ -36,8 +36,8 @@ class Settings_Page { */ public static function admin_menu(): void { \add_options_page( - 'Activitypub Event Bridge', - __( 'ActivityPub Event Bridge', 'activitypub-event-bridge' ), + 'Event Bridge for ActivityPub', + __( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ), 'manage_options', self::SETTINGS_SLUG, array( self::STATIC, 'settings_page' ), @@ -114,7 +114,7 @@ class Settings_Page { 'event_terms' => $event_terms, ); - \load_template( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . 'templates/settings.php', true, $args ); + \load_template( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . 'templates/settings.php', true, $args ); break; case 'welcome': default: @@ -122,7 +122,7 @@ class Settings_Page { add_thickbox(); wp_enqueue_script( 'updates' ); - \load_template( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . 'templates/welcome.php', true ); + \load_template( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . 'templates/welcome.php', true ); break; } } diff --git a/includes/class-autoloader.php b/includes/class-autoloader.php index e0315d8..40f99cd 100644 --- a/includes/class-autoloader.php +++ b/includes/class-autoloader.php @@ -1,17 +1,17 @@ 'string', - 'description' => \__( 'Define your own custom post template', 'activitypub-event-bridge' ), + 'description' => \__( 'Define your own custom post template', 'event-bridge-for-activitypub' ), 'show_in_rest' => true, 'default' => self::DEFAULT_EVENT_CATEGORY, 'sanitize_callback' => array( self::class, 'sanitize_mapped_event_category' ), @@ -52,22 +52,22 @@ class Settings { ); \register_setting( - 'activitypub-event-bridge', - 'activitypub_event_bridge_event_category_mappings', + 'event-bridge-for-activitypub', + 'event_bridge_for_activitypub_event_category_mappings', array( 'type' => 'array', - 'description' => \__( 'Define your own custom post template', 'activitypub-event-bridge' ), + 'description' => \__( 'Define your own custom post template', 'event-bridge-for-activitypub' ), 'default' => array(), 'sanitize_callback' => array( self::class, 'sanitize_event_category_mappings' ), ) ); \register_setting( - 'activitypub-event-bridge', - 'activitypub_event_bridge_initially_activated', + 'event-bridge-for-activitypub', + 'event_bridge_for_activitypub_initially_activated', array( 'type' => 'boolean', - 'description' => \__( 'Whether the plugin just got activated for the first time.', 'activitypub-event-bridge' ), + 'description' => \__( 'Whether the plugin just got activated for the first time.', 'event-bridge-for-activitypub' ), 'default' => 1, ) ); diff --git a/includes/class-setup.php b/includes/class-setup.php index 2912002..ce6afc4 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -1,32 +1,32 @@ activitypub_plugin_is_active ) { - // deactivate_plugins( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ); + // deactivate_plugins( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ); // return; // }. $this->active_event_plugins = self::detect_active_event_plugins(); @@ -125,13 +125,15 @@ class Setup { * @var array */ private const EVENT_PLUGIN_CLASSES = array( - '\ActivityPub_Event_Bridge\Plugins\Events_Manager', - '\ActivityPub_Event_Bridge\Plugins\GatherPress', - '\ActivityPub_Event_Bridge\Plugins\The_Events_Calendar', - '\ActivityPub_Event_Bridge\Plugins\VS_Event_List', - '\ActivityPub_Event_Bridge\Plugins\WP_Event_Manager', - '\ActivityPub_Event_Bridge\Plugins\Eventin', - '\ActivityPub_Event_Bridge\Plugins\Modern_Events_Calendar_Lite', + '\Event_Bridge_For_ActivityPub\Integrations\Events_Manager', + '\Event_Bridge_For_ActivityPub\Integrations\GatherPress', + '\Event_Bridge_For_ActivityPub\Integrations\The_Events_Calendar', + '\Event_Bridge_For_ActivityPub\Integrations\VS_Event_List', + '\Event_Bridge_For_ActivityPub\Integrations\WP_Event_Manager', + '\Event_Bridge_For_ActivityPub\Integrations\Eventin', + '\Event_Bridge_For_ActivityPub\Integrations\Modern_Events_Calendar_Lite', + '\Event_Bridge_For_ActivityPub\Integrations\EventPrime', + '\Event_Bridge_For_ActivityPub\Integrations\Event_Organiser', ); /** @@ -164,14 +166,14 @@ class Setup { * @return void */ protected function setup_hooks(): void { - register_activation_hook( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE, array( $this, 'activate' ) ); + register_activation_hook( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE, array( $this, 'activate' ) ); 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, + 'plugin_action_links_' . EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_BASENAME, array( Settings_Page::class, 'settings_link' ) ); @@ -183,7 +185,7 @@ class Setup { add_action( 'init', array( Health_Check::class, 'init' ) ); // 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 ) ) { + if ( ! version_compare( $this->activitypub_plugin_version, EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { return; } @@ -198,24 +200,24 @@ class Setup { * @return void */ public static function enqueue_styles( $hook_suffix ): void { - if ( false !== strpos( $hook_suffix, 'activitypub-event-bridge' ) ) { + if ( false !== strpos( $hook_suffix, 'event-bridge-for-activitypub' ) ) { wp_enqueue_style( - 'activitypub-event-bridge-admin-styles', + 'event-bridge-for-activitypub-admin-styles', plugins_url( - 'assets/css/activitypub-event-bridge-admin.css', - ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE + 'assets/css/event-bridge-for-activitypub-admin.css', + EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ), array(), - ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_VERSION + EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION ); wp_enqueue_script( - 'activitypub-event-bridge-admin-script', + 'event-bridge-for-activitypub-admin-script', plugins_url( - 'assets/js/activitypub-event-bridge-admin.js', - ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE + 'assets/js/event-bridge-for-activitypub-admin.js', + EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), - ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_VERSION, + EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION, false ); } @@ -231,15 +233,15 @@ class Setup { // Check if any general admin notices are needed and add actions to insert the needed admin notices. if ( ! $this->activitypub_plugin_is_active ) { // The ActivityPub plugin is not active. - add_action( 'admin_notices', array( 'ActivityPub_Event_Bridge\Admin\General_Admin_Notices', 'activitypub_plugin_not_enabled' ), 10, 1 ); + add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'activitypub_plugin_not_enabled' ), 10, 1 ); } - if ( ! version_compare( $this->activitypub_plugin_version, ACTIVITYPUB_EVENT_BRIDGE_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { + if ( ! version_compare( $this->activitypub_plugin_version, EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) { // The ActivityPub plugin is too old. - add_action( 'admin_notices', array( 'ActivityPub_Event_Bridge\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 ); + add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 ); } if ( empty( $this->active_event_plugins ) ) { // No supported Event Plugin is active. - add_action( 'admin_notices', array( 'ActivityPub_Event_Bridge\Admin\General_Admin_Notices', 'no_supported_event_plugin_active' ), 10, 1 ); + add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'no_supported_event_plugin_active' ), 10, 1 ); } } @@ -252,7 +254,7 @@ class Setup { * * @return \Activitypub\Transformer\Base|null */ - public function register_activitypub_event_transformer( $transformer, $wp_object, $object_class ): \Activitypub\Transformer\Base { + public function register_activitypub_event_transformer( $transformer, $wp_object, $object_class ): ?\Activitypub\Transformer\Base { // If the current WordPress object is not a post (e.g., a WP_Comment), don't change the transformer. if ( 'WP_Post' !== $object_class ) { return $transformer; @@ -292,9 +294,9 @@ class Setup { } /** - * Activates the ActivityPub Event Bridge plugin. + * Activates the Event Bridge for ActivityPub plugin. * - * This method handles the activation of the ActivityPub Event Bridge plugin. + * This method handles the activation of the Event Bridge for ActivityPub plugin. * * @since 1.0.0 * @see register_activation_hook() @@ -303,7 +305,7 @@ class Setup { public function activate(): void { // Don't allow plugin activation, when the ActivityPub plugin is not activated yet. if ( ! $this->activitypub_plugin_is_active ) { - deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ) ); + deactivate_plugins( plugin_basename( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); $notice = General_Admin_Notices::get_admin_notice_activitypub_plugin_not_enabled(); wp_die( wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ), @@ -313,7 +315,7 @@ class Setup { } if ( empty( $this->active_event_plugins ) ) { - deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ) ); + deactivate_plugins( plugin_basename( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); $notice = General_Admin_Notices::get_admin_notice_no_supported_event_plugin_active(); wp_die( wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ), diff --git a/includes/event-categories.php b/includes/event-categories.php index 6350a52..15fbdcf 100644 --- a/includes/event-categories.php +++ b/includes/event-categories.php @@ -2,46 +2,46 @@ /** * File responsible for defining the event category strings. * - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 * @license AGPL-3.0-or-later */ -namespace ActivityPub_Event_Bridge; +namespace Event_Bridge_For_ActivityPub; define( - 'ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES', + 'EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES', array( - 'ARTS' => __( 'Arts', 'activitypub-event-bridge' ), - 'BOOK_CLUBS' => __( 'Book clubs', 'activitypub-event-bridge' ), - 'BUSINESS' => __( 'Business', 'activitypub-event-bridge' ), - 'CAUSES' => __( 'Causes', 'activitypub-event-bridge' ), - 'COMEDY' => __( 'Comedy', 'activitypub-event-bridge' ), - 'CRAFTS' => __( 'Crafts', 'activitypub-event-bridge' ), - 'FOOD_DRINK' => __( 'Food & Drink', 'activitypub-event-bridge' ), - 'HEALTH' => __( 'Health', 'activitypub-event-bridge' ), - 'MUSIC' => __( 'Music', 'activitypub-event-bridge' ), - 'AUTO_BOAT_AIR' => __( 'Auto, boat and air', 'activitypub-event-bridge' ), - 'COMMUNITY' => __( 'Community', 'activitypub-event-bridge' ), - 'FAMILY_EDUCATION' => __( 'Family & Education', 'activitypub-event-bridge' ), - 'FASHION_BEAUTY' => __( 'Fashion & Beauty', 'activitypub-event-bridge' ), - 'FILM_MEDIA' => __( 'Film & Media', 'activitypub-event-bridge' ), - 'GAMES' => __( 'Games', 'activitypub-event-bridge' ), - 'LANGUAGE_CULTURE' => __( 'Language & Culture', 'activitypub-event-bridge' ), - 'LEARNING' => __( 'Learning', 'activitypub-event-bridge' ), - 'LGBTQ' => __( 'LGBTQ', 'activitypub-event-bridge' ), - 'MOVEMENTS_POLITICS' => __( 'Movements and politics', 'activitypub-event-bridge' ), - 'NETWORKING' => __( 'Networking', 'activitypub-event-bridge' ), - 'PARTY' => __( 'Party', 'activitypub-event-bridge' ), - 'PERFORMING_VISUAL_ARTS' => __( 'Performing & Visual Arts', 'activitypub-event-bridge' ), - 'PETS' => __( 'Pets', 'activitypub-event-bridge' ), - 'PHOTOGRAPHY' => __( 'Photography', 'activitypub-event-bridge' ), - 'OUTDOORS_ADVENTURE' => __( 'Outdoors & Adventure', 'activitypub-event-bridge' ), - 'SPIRITUALITY_RELIGION_BELIEFS' => __( 'Spirituality, Religion & Beliefs', 'activitypub-event-bridge' ), - 'SCIENCE_TECH' => __( 'Science & Tech', 'activitypub-event-bridge' ), - 'SPORTS' => __( 'Sports', 'activitypub-event-bridge' ), - 'THEATRE' => __( 'Theatre', 'activitypub-event-bridge' ), - 'MEETING' => __( 'Meeting', 'activitypub-event-bridge' ), // Default value in federation. - 'DEFAULT' => __( 'Default', 'activitypub-event-bridge' ), // Internal default for overrides. + 'ARTS' => __( 'Arts', 'event-bridge-for-activitypub' ), + 'BOOK_CLUBS' => __( 'Book clubs', 'event-bridge-for-activitypub' ), + 'BUSINESS' => __( 'Business', 'event-bridge-for-activitypub' ), + 'CAUSES' => __( 'Causes', 'event-bridge-for-activitypub' ), + 'COMEDY' => __( 'Comedy', 'event-bridge-for-activitypub' ), + 'CRAFTS' => __( 'Crafts', 'event-bridge-for-activitypub' ), + 'FOOD_DRINK' => __( 'Food & Drink', 'event-bridge-for-activitypub' ), + 'HEALTH' => __( 'Health', 'event-bridge-for-activitypub' ), + 'MUSIC' => __( 'Music', 'event-bridge-for-activitypub' ), + 'AUTO_BOAT_AIR' => __( 'Auto, boat and air', 'event-bridge-for-activitypub' ), + 'COMMUNITY' => __( 'Community', 'event-bridge-for-activitypub' ), + 'FAMILY_EDUCATION' => __( 'Family & Education', 'event-bridge-for-activitypub' ), + 'FASHION_BEAUTY' => __( 'Fashion & Beauty', 'event-bridge-for-activitypub' ), + 'FILM_MEDIA' => __( 'Film & Media', 'event-bridge-for-activitypub' ), + 'GAMES' => __( 'Games', 'event-bridge-for-activitypub' ), + 'LANGUAGE_CULTURE' => __( 'Language & Culture', 'event-bridge-for-activitypub' ), + 'LEARNING' => __( 'Learning', 'event-bridge-for-activitypub' ), + 'LGBTQ' => __( 'LGBTQ', 'event-bridge-for-activitypub' ), + 'MOVEMENTS_POLITICS' => __( 'Movements and politics', 'event-bridge-for-activitypub' ), + 'NETWORKING' => __( 'Networking', 'event-bridge-for-activitypub' ), + 'PARTY' => __( 'Party', 'event-bridge-for-activitypub' ), + 'PERFORMING_VISUAL_ARTS' => __( 'Performing & Visual Arts', 'event-bridge-for-activitypub' ), + 'PETS' => __( 'Pets', 'event-bridge-for-activitypub' ), + 'PHOTOGRAPHY' => __( 'Photography', 'event-bridge-for-activitypub' ), + 'OUTDOORS_ADVENTURE' => __( 'Outdoors & Adventure', 'event-bridge-for-activitypub' ), + 'SPIRITUALITY_RELIGION_BELIEFS' => __( 'Spirituality, Religion & Beliefs', 'event-bridge-for-activitypub' ), + 'SCIENCE_TECH' => __( 'Science & Tech', 'event-bridge-for-activitypub' ), + 'SPORTS' => __( 'Sports', 'event-bridge-for-activitypub' ), + 'THEATRE' => __( 'Theatre', 'event-bridge-for-activitypub' ), + 'MEETING' => __( 'Meeting', 'event-bridge-for-activitypub' ), // Default value in federation. + 'DEFAULT' => __( 'Default', 'event-bridge-for-activitypub' ), // Internal default for overrides. ), ); diff --git a/includes/integrations/class-event-organiser.php b/includes/integrations/class-event-organiser.php new file mode 100644 index 0000000..9278f43 --- /dev/null +++ b/includes/integrations/class-event-organiser.php @@ -0,0 +1,69 @@ +post_content && '[em_events]' !== $queried_object->post_content ) { + return false; + } + } + + // Check if header already sent. + if ( ! \headers_sent() && ACTIVITYPUB_SEND_VARY_HEADER ) { + // Send Vary header for Accept header. + \header( 'Vary: Accept' ); + } + + // One can trigger an ActivityPub request by adding ?activitypub to the URL. + if ( isset( $wp_query->query_vars['activitypub'] ) ) { + return true; + } + + /* + * The other (more common) option to make an ActivityPub request + * is to send an Accept header. + */ + if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { + $accept = sanitize_text_field( wp_unslash( $_SERVER['HTTP_ACCEPT'] ) ); + + /* + * $accept can be a single value, or a comma separated list of values. + * We want to support both scenarios, + * and return true when the header includes at least one of the following: + * - application/activity+json + * - application/ld+json + * - application/json + */ + if ( preg_match( '/(application\/(ld\+json|activity\+json|json))/i', $accept ) ) { + return true; + } + } + + return false; + } + + /** + * Extract the post id of the event for an EventPrime event query. + * + * @return bool|int The post ID if an event could be identified, false otherwise. + */ + private static function get_eventprime_post_id() { + $event = get_query_var( 'event' ); + if ( ! $event ) { + if ( ! empty( filter_input( INPUT_GET, 'event', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ) ) { + $event = rtrim( filter_input( INPUT_GET, 'event', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), '/\\' ); + } + } + + if ( $event ) { + $ep_basic_functions = new Eventprime_Basic_Functions(); + return $ep_basic_functions->ep_get_id_by_slug( $event, 'em_event' ); + } + + return false; + } + + /** + * Add the ActivityPub template for EventPrime. + * + * @param string $template The path to the template object. + * @return string The new path to the JSON template. + */ + public static function render_activitypub_template( $template ) { + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { + return $template; + } + + // Check if the request is a page with (solely) the eventprime shortcode in it. + if ( ! self::is_eventprime_activitypub_request() ) { + return $template; + } + + if ( ! \is_singular() ) { + return $template; + } + + $post_id = self::get_eventprime_post_id(); + + if ( $post_id ) { + $preview = \get_query_var( 'preview' ); + if ( $preview ) { + $activitypub_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/post-preview.php'; + } else { + $activitypub_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/post-json.php'; + } + } + + /* + * Check if the request is authorized. + * + * @see https://www.w3.org/wiki/SocialCG/ActivityPub/Primer/Authentication_Authorization#Authorized_fetch + * @see https://swicg.github.io/activitypub-http-signature/#authorized-fetch + */ + if ( $activitypub_template && ACTIVITYPUB_AUTHORIZED_FETCH ) { + $verification = Signature::verify_http_signature( $_SERVER ); + if ( \is_wp_error( $verification ) ) { + header( 'HTTP/1.1 401 Unauthorized' ); + + // Fallback as template_loader can't return http headers. + return $template; + } + } + + if ( $activitypub_template ) { + global $post; + + $post = get_post( $post_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + + // Ensure WordPress functions use the new post data. + setup_postdata( $post ); + // Return the default ActivityPub template. + return $activitypub_template; + } + + return $template; + } +} diff --git a/includes/plugins/class-events-manager.php b/includes/integrations/class-events-manager.php similarity index 93% rename from includes/plugins/class-events-manager.php rename to includes/integrations/class-events-manager.php index 02ca060..2f22620 100644 --- a/includes/plugins/class-events-manager.php +++ b/includes/integrations/class-events-manager.php @@ -5,11 +5,11 @@ * Defines all the necessary meta information for the Events Manager WordPress Plugin. * * @link https://wordpress.org/plugins/events-manager/ - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/includes/plugins/class-gatherpress.php b/includes/integrations/class-gatherpress.php similarity index 94% rename from includes/plugins/class-gatherpress.php rename to includes/integrations/class-gatherpress.php index 6c6af0f..57cd222 100644 --- a/includes/plugins/class-gatherpress.php +++ b/includes/integrations/class-gatherpress.php @@ -5,11 +5,11 @@ * Defines all the necessary meta information for the GatherPress plugin. * * @link https://wordpress.org/plugins/gatherpress/ - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/includes/plugins/class-modern-events-calendar-lite.php b/includes/integrations/class-modern-events-calendar-lite.php similarity index 93% rename from includes/plugins/class-modern-events-calendar-lite.php rename to includes/integrations/class-modern-events-calendar-lite.php index 45f060f..02329ae 100644 --- a/includes/plugins/class-modern-events-calendar-lite.php +++ b/includes/integrations/class-modern-events-calendar-lite.php @@ -5,11 +5,11 @@ * Defines all the necessary meta information for the Modern Events Calendar (Lite). * * @link https://webnus.net/modern-events-calendar/ - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/includes/plugins/class-the-events-calendar.php b/includes/integrations/class-the-events-calendar.php similarity index 94% rename from includes/plugins/class-the-events-calendar.php rename to includes/integrations/class-the-events-calendar.php index 36ab8e0..42d295e 100644 --- a/includes/plugins/class-the-events-calendar.php +++ b/includes/integrations/class-the-events-calendar.php @@ -5,11 +5,11 @@ * Defines all the necessary meta information for the events calendar. * * @link https://wordpress.org/plugins/the-events-calendar/ - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/includes/plugins/class-vs-event-list.php b/includes/integrations/class-vs-event-list.php similarity index 90% rename from includes/plugins/class-vs-event-list.php rename to includes/integrations/class-vs-event-list.php index f1bd96b..6ce4ba6 100644 --- a/includes/plugins/class-vs-event-list.php +++ b/includes/integrations/class-vs-event-list.php @@ -6,13 +6,13 @@ * "Very Simple Events List". * * @link https://de.wordpress.org/plugins/very-simple-event-list/ - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; -use ActivityPub_Event_Bridge\Event_Plugins; +use Event_Bridge_For_ActivityPub\Event_Plugins; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/includes/plugins/class-wp-event-manager.php b/includes/integrations/class-wp-event-manager.php similarity index 90% rename from includes/plugins/class-wp-event-manager.php rename to includes/integrations/class-wp-event-manager.php index 28a852a..18c217d 100644 --- a/includes/plugins/class-wp-event-manager.php +++ b/includes/integrations/class-wp-event-manager.php @@ -6,13 +6,13 @@ * "WP Event Manager" * * @link https://de.wordpress.org/plugins/wp-event-manager - * @package ActivityPub_Event_Bridge + * @package Event_Bridge_For_ActivityPub * @since 1.0.0 */ -namespace ActivityPub_Event_Bridge\Plugins; +namespace Event_Bridge_For_ActivityPub\Integrations; -use ActivityPub_Event_Bridge\Plugins\Event_Plugin; +use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore diff --git a/package.json b/package.json index 4db7d96..68b7757 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "activitypub-event-bridge", + "name": "event-bridge-for-activitypub", "version": "0.1.0", "author": { "name": "AndrΓ© Menrath", @@ -15,7 +15,7 @@ }, "license": "AGPL-3.0", "bugs": { - "url": "https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge/issues" + "url": "https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues" }, "devDependencies": { "@wordpress/env": "^10.10.0", diff --git a/phpcs.xml b/phpcs.xml index e1ef42c..7839664 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -108,7 +108,7 @@