diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 5f300c7..afb653e 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -115,11 +115,6 @@ jobs: env: 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: diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e4577..f1b3e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +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). -## Unreleased - -### Added - -* Add custom summary via shortcodes - -## [0.3.2] - 2024-12-12 +## [0.3.3] - 2024-12-19 * Initial release on WordPress.org diff --git a/README.md b/README.md index 83c871f..2f7a674 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **Tags:** events, fediverse, activitypub, calendar **Requires at least:** 6.5 **Tested up to:** 6.7 -**Stable tag:** 0.3.2 +**Stable tag:** 0.3.3 **Requires PHP:** 7.4 **License:** AGPL-3.0-or-later **License URI:** https://www.gnu.org/licenses/agpl-3.0.html @@ -63,7 +63,6 @@ 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 ## @@ -102,7 +101,7 @@ We're always interested in your feedback. Feel free to reach out to us via [E-Ma ## Changelog ## -### [0.3.2] 2024-12-12 ### +### [0.3.3] 2024-12-19 ### * Initial release on https://wordpress.org/ diff --git a/event-bridge-for-activitypub.php b/event-bridge-for-activitypub.php index ac44073..f1ce6b3 100644 --- a/event-bridge-for-activitypub.php +++ b/event-bridge-for-activitypub.php @@ -3,7 +3,7 @@ * Plugin Name: Event Bridge for ActivityPub * Description: Integrating popular event plugins with the ActivityPub plugin. * Plugin URI: https://event-federation.eu/ - * Version: 0.3.2.7 + * Version: 0.3.3 * Author: André Menrath * Author URI: https://graz.social/@linos * Text Domain: event-bridge-for-activitypub diff --git a/includes/activitypub/transformer/class-eventprime.php b/includes/activitypub/transformer/class-eventprime.php deleted file mode 100644 index 68a7f0d..0000000 --- a/includes/activitypub/transformer/class-eventprime.php +++ /dev/null @@ -1,78 +0,0 @@ -wp_object->ID, 'em_end_date', true ); - if ( $timestamp ) { - return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp ); - } else { - return null; - } - } - - /** - * Get the end time from the event object. - */ - public function get_start_time(): string { - $timestamp = get_post_meta( $this->wp_object->ID, 'em_start_date', true ); - if ( $timestamp ) { - return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp ); - } else { - return ''; - } - } - - /** - * Get location from the event object. - */ - public function get_location(): ?Place { - $venue_term_id = get_post_meta( $this->wp_object->ID, 'em_venue', true ); - if ( ! $venue_term_id ) { - return null; - } - - $venue = wp_get_post_terms( $this->wp_object->ID, 'em_venue' ); - - if ( empty( $venue ) ) { - return null; - } else { - $venue = $venue[0]; - } - - $place = new Place(); - - $place->set_name( $venue->name ); - $place->set_content( $venue->description ); - - $address = get_term_meta( $venue->term_id, 'em_address', true ); - $display_address = get_term_meta( $venue->term_id, 'em_display_address_on_frontend', true ); - - if ( $address && $display_address ) { - $place->set_address( get_term_meta( $venue->term_id, 'em_address', true ) ); - } - - return $place; - } -} diff --git a/includes/admin/class-general-admin-notices.php b/includes/admin/class-general-admin-notices.php index a58c2c4..ee7f886 100644 --- a/includes/admin/class-general-admin-notices.php +++ b/includes/admin/class-general-admin-notices.php @@ -29,7 +29,7 @@ class General_Admin_Notices { */ const ACTIVITYPUB_PLUGIN_URL = 'https://wordpress.org/plugins/activitypub'; - const EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub#events-plugin-that-will-be-supported-at-first'; + const EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub#supported-event-plugins'; /** * Allowed HTML for admin notices. @@ -38,8 +38,9 @@ class General_Admin_Notices { */ const ALLOWED_HTML = array( 'a' => array( - 'href' => true, - 'title' => true, + 'href' => true, + 'title' => true, + 'target' => true, ), 'br', 'i', @@ -90,11 +91,11 @@ class General_Admin_Notices { /* translators: 1: An URL to the list of supported event plugins. */ _x( 'The Plugin Event Bridge for ActivityPub is of no use, because you do not have installed and activated a supported Event Plugin. -
For a list of supported Event Plugins see here.', +
For a list of supported Event Plugins see here.', 'admin notice', 'event-bridge-for-activitypub' ), - esc_html( self::EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL ) + esc_url( self::EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL ) ); } diff --git a/includes/admin/class-health-check.php b/includes/admin/class-health-check.php index 8364cac..fec797c 100644 --- a/includes/admin/class-health-check.php +++ b/includes/admin/class-health-check.php @@ -116,7 +116,10 @@ class Health_Check { if ( ! $event_post_type ) { $active_event_plugins = Setup::get_instance()->get_active_event_plugins(); $active_event_plugin = reset( $active_event_plugins ); - $event_post_type = $active_event_plugin->get_post_type(); + if ( ! $active_event_plugin ) { + return false; + } + $event_post_type = $active_event_plugin->get_post_type(); } $args = array( diff --git a/includes/class-setup.php b/includes/class-setup.php index 974ef68..e362a85 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -126,7 +126,6 @@ class Setup { \Event_Bridge_For_ActivityPub\Integrations\WP_Event_Manager::class, \Event_Bridge_For_ActivityPub\Integrations\Eventin::class, \Event_Bridge_For_ActivityPub\Integrations\Modern_Events_Calendar_Lite::class, - \Event_Bridge_For_ActivityPub\Integrations\EventPrime::class, \Event_Bridge_For_ActivityPub\Integrations\Event_Organiser::class, ); diff --git a/includes/integrations/class-eventprime.php b/includes/integrations/class-eventprime.php deleted file mode 100644 index 9c40849..0000000 --- a/includes/integrations/class-eventprime.php +++ /dev/null @@ -1,230 +0,0 @@ -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 && defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) && constant( '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/readme.txt b/readme.txt index 35b33d0..a2aa34b 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: andremenrath Tags: events, fediverse, activitypub, calendar Requires at least: 6.5 Tested up to: 6.7 -Stable tag: 0.3.2 +Stable tag: 0.3.3 Requires PHP: 7.4 License: AGPL-3.0-or-later License URI: https://www.gnu.org/licenses/agpl-3.0.html @@ -57,7 +57,6 @@ 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 == @@ -96,6 +95,6 @@ We're always interested in your feedback. Feel free to reach out to us via [E-Ma == Changelog == -= [0.3.2] 2024-12-12 = += [0.3.3] 2024-12-19 = * Initial release on https://wordpress.org/ diff --git a/templates/welcome.php b/templates/welcome.php index 0a557b1..4276336 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -11,6 +11,7 @@ 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; @@ -43,6 +44,12 @@ WP_Filesystem();

+ ⚠' . \wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ) . '

'; + ?>

get_plugin_name() ); ?>: