Compare commits

..

14 commits

Author SHA1 Message Date
736dd36133 change readme short desc
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 35s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 59s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 58s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m6s
2024-09-28 11:40:40 +02:00
e8b2dbba15 update readme description text 2024-09-28 11:38:34 +02:00
d7244b1896 test 2024-09-28 11:34:57 +02:00
2004edb444 set image size in readme 2024-09-28 11:33:58 +02:00
bd4717fc37 update readme.txt 2024-09-28 11:31:00 +02:00
aba6ca7f8e update readme 2024-09-28 11:30:36 +02:00
d1aa4290ff fix images in readme 2024-09-28 11:29:53 +02:00
04743abd12 test gifs 2024-09-28 11:29:40 +02:00
8364c3b1d8 readme: small improvements 2024-09-28 11:28:06 +02:00
078557825d fix image links in readme 2024-09-28 11:24:20 +02:00
10ae5d0234 fix md 2024-09-28 11:21:19 +02:00
51981b3e27 fix image links in readme 2024-09-28 11:17:32 +02:00
eca96b4f4c draft of new readme 2024-09-28 11:16:16 +02:00
388f189eb3 add wip icon 2024-09-27 17:50:43 +02:00
34 changed files with 584 additions and 671 deletions

View file

@ -75,21 +75,21 @@ jobs:
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 false true true true run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 false true true true
- name: Run Integration tests for The Events Calendar - 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-activitypub-event-extensions/ && ./vendor/bin/phpunit --filter=the_events_calendar
env: env:
PHP_VERSION: ${{ matrix.php-version }} PHP_VERSION: ${{ matrix.php-version }}
- name: Run Integration tests for VS Event List - 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-activitypub-event-extensions/ && ./vendor/bin/phpunit --filter=vs_event_list
env: env:
PHP_VERSION: ${{ matrix.php-version }} PHP_VERSION: ${{ matrix.php-version }}
- name: Run Integration tests for GatherPress - 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-activitypub-event-extensions/ && ./vendor/bin/phpunit --filter=gatherpress
env: env:
PHP_VERSION: ${{ matrix.php-version }} PHP_VERSION: ${{ matrix.php-version }}
- name: Run Integration tests for Events Manager - 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-activitypub-event-extensions/ && ./vendor/bin/phpunit --filter=events_manager
env: env:
PHP_VERSION: ${{ matrix.php-version }} PHP_VERSION: ${{ matrix.php-version }}

3
.gitignore vendored
View file

@ -1,4 +1,3 @@
vendor/ vendor
composer.lock composer.lock
.phpunit.result.cache .phpunit.result.cache
node_modules/

View file

@ -1,7 +1,7 @@
# ActivityPub Event Bridge # ActivityPub Event Extensions
Contributors: andremenrath Contributors: andremenrath
Tags: events, fediverse, activitypub, calendar Tags: events, fediverse, activitypub,, calendar
Requires at least: 6.5 Requires at least: 6.5
Tested up to: 6.6 Tested up to: 6.6
Stable tag: 0.1.0 Stable tag: 0.1.0
@ -15,17 +15,17 @@ Integrating popular event plugins with the ActivityPub plugin.
## Description ## 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). Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and part of the growing decentralized web.
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 ActivityPub Event Extensions Plugin for WordPress, your events can be automatically 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. 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/). 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/).
With the ActivityPub plugin people can follow your website directly and engage with your events just as they would on social media: liking, boosting and even commenting if you enable it. With the ActivityPub plugin people can follow your website directly and engage with your events just as they would on social media - liking, boosting and even commenting if you enable it.
You retain full ownership of your content. By integrating into your existing setup, it ensures no extra work is needed while enhancing your events' visibility across the web. You retain full ownership of your content. By integrating into your existing setup, it ensures no extra work is needed while enhancing your events' visibility across the Fediverse.
### How It Works ### How It Works
With the ActivityPub Event Bridge WordPress plugin, sharing your events is effortless and automatic! With the Event Federation Plugin for WordPress, 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. Once you create an event on your WordPress site, it is seamlessly shared across the decentralized web using the ActivityPub protocol.
<p align="center"> <p align="center">
@ -33,20 +33,20 @@ Once you create an event on your WordPress site, it is seamlessly shared across
</p> </p>
Your events can be automatically delivered to platforms that fully support events, such as [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Your events can be automatically delivered to platforms that fully support events, such as [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/).
These platforms create public event calendars by pulling in events from various sources, including your website. Any updates you make to your events are synced across these platforms—so you only need to manage your events on your own site, with no extra work required. These platforms build public event calendars utilizing multiple event sources, including your site. Updates are also handled automatically whenever you make changes — no extra work for you than managing the event on your own website.
<p align="center"> <p align="center">
<img src="./.wordpress-org/decentralized-event-calenders.gif" alt="Logo" width="250" /> <img src="./.wordpress-org/decentralized-event-calenders.gif" alt="Logo" width="250" />
</p> </p>
Even platforms that dont yet fully support events, like [Mastodon](https://joinmastodon.org), will still receive a detailed, well-composed summary of your event. Even platforms that dont yet fully support events, like [Mastodon](https://joinmastodon.org), will still receive a detailed, well-composed summary of your event.
The Event Federation plugin ensures that users from those platforms are provided with all important information about an event. The Event Federation Plugin ensures that users from those platforms are provided with all important information about an event.
## Installation ## Installation
This plugin depends on the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). Additionally, you need to use one of the supported event plugins. See below. This plugin depends on the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). Additionally, you need to use one of the supported Event Plugins. See below.
### Supported Event plugins ### Supported Event Plugins
* [The Events Calendar](https://de.wordpress.org/plugins/the-events-calendar/) * [The Events Calendar](https://de.wordpress.org/plugins/the-events-calendar/)
* [VS Event List](https://de.wordpress.org/plugins/very-simple-event-list/) * [VS Event List](https://de.wordpress.org/plugins/very-simple-event-list/)
@ -58,12 +58,12 @@ If youre new to the [ActivityPub plugin](https://wordpress.org/plugins/activi
## Frequently Asked Questions ## Frequently Asked Questions
### Do I need to install another event plugin to use the Event Federation plugin? ### Do I need to install another event plugin to use the Event Federation Plugin?
Yes, this plugin works as an add-on and requires both the ActivityPub plugin and a supported event plugin such as The Events Calendar, VS Event List, or Events Manager to manage your events. It just fills the missing gap between event plugins and the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). Yes, this plugin works needs a supported event plugin such as The Events Calendar, VS Event List, or Events Manager to manage your events. It just fills the missing gap between event plugins and the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/).
### What platforms can follow my events? ### What platforms can follow my events?
Your events can be followed on platforms that support ActivityPub like [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Even other applications like [Mastodon](https://joinmastodon.org), which dont fully support events yet, will display all important information about the events. Your events can be followed on platforms that support ActivityPub like [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Even other applications like [Mastodon](https://joinmastodon.org), which dont fully support events yet, will display a all important information about the events.
### How much extra work is required to maintain my events across the decentralized Web? ### How much extra work is required to maintain my events across the decentralized Web?
@ -75,15 +75,15 @@ Yes, you can still use traditional social media if you wish. However, this plugi
### Will this plugin work if I don't use the ActivityPub plugin? ### Will this plugin work if I don't use the ActivityPub plugin?
No, the Event Federation plugin depends on the ActivityPub plugin to deliver your events across decentralized platforms, so it's essential to have it installed and configured. No, the Event Federation Plugin depends on the ActivityPub plugin to deliver your events across decentralized platforms, so it's essential to have it installed and configured.
### My event plugin is not supported, what can I do? ### 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-activitypub-event-extensions/issues), if we can spare some free hours we might add it.
### What if I experience problems? ### 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-activitypub-event-extensions/issues).
## Changelog ## Changelog

View file

@ -1,36 +0,0 @@
<?php
/**
* Plugin Name: ActivityPub Event Bridge
* Description: Integrating popular event plugins with the ActivityPub plugin.
* Plugin URI: https://event-federation.eu/
* Version: 0.1.0
* Author: André Menrath
* Author URI: https://graz.social/@linos
* Text Domain: activitypub-event-bridge
* License: AGPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/agpl-3.0.de.html
* Requires PHP: 8.1
*
* Requires at least ActivityPub plugin with version >= 3.2.2. ActivityPub plugin tested up to: 3.2.2.
*
* @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' );
// Include and register the autoloader class for automatic loading of plugin classes.
require_once ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . '/includes/class-autoloader.php';
ActivityPub_Event_Bridge\Autoloader::register();
// Initialize the plugin.
ActivityPub_Event_Bridge\Setup::get_instance();

View file

@ -0,0 +1,72 @@
<?php
/**
* Plugin Name: ActivityPub Event Extensions
* Description: Custom ActivityPub Transformers and Integrations for common Event Plugins.
* Plugin URI: https://event-federation.eu/
* Version: 0.1.0
* Author: André Menrath
* Author URI: https://graz.social/@linos
* Text Domain: activitypub-event-extensions
* License: AGPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/agpl-3.0.de.html
* Requires PHP: 8.1
*
* Requires at least ActivityPub plugin with version >= 3.2.2. ActivityPub plugin tested up to: 3.2.2.
*
* @package activitypub-event-extensions
* @license AGPL-3.0-or-later
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_VERSION', current( get_file_data( __FILE__, array( 'Version' ), 'plugin' ) ) );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_DOMAIN', 'activitypub-event-extensions' );
define( 'ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION', '3.2.2' );
// Include and register the autoloader class for automatic loading of plugin classes.
require_once ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . '/includes/class-autoloader.php';
Activitypub_Event_Extensions\Autoloader::register();
// Initialize the plugin.
Activitypub_Event_Extensions\Setup::get_instance();
// BeforeFirstRelease: Remove everything after this after here.
/**
* Add a filter for http_request_host_is_external
*
* BeforeFirstRelease: Remove this for release.
*/
add_filter( 'http_request_host_is_external', 'activitypub_event_extensions_custom_http_request_host_is_external', 10, 3 );
/**
* Add a filter for http_request_host_is_external
*
* BeforeFirstRelease: Remove this for release.
*
* @param bool $is_external Whether the request is external.
*/
function activitypub_event_extensions_custom_http_request_host_is_external( $is_external ) {
$is_external = true;
return $is_external;
}
/**
* Don't verify ssl certs for testing.
*
* BeforeFirstRelease: Remove this for release.
*/
add_filter( 'https_ssl_verify', 'activitypub_event_extensions_dont_verify_local_dev_https', 10, 3 );
/**
* BeforeFirstRelease: remove it.
*/
function activitypub_event_extensions_dont_verify_local_dev_https() {
return false;
}

View file

@ -1,4 +1,4 @@
.activitypub-event-bridge-settings-page .box { .activitypub-event-extensions-settings-page .box {
border: 1px solid #c3c4c7; border: 1px solid #c3c4c7;
background-color: #fff; background-color: #fff;
padding: 1em 1.5em; padding: 1em 1.5em;

View file

@ -1,6 +1,6 @@
{ {
"name": "menrath/wordpress-activitypub-event-bridge", "name": "menrath/wordpress-activitypub-event-extensions",
"description": "The ActivityPub Event Bridge help for event custom post types to federate properly.", "description": "The ActivityPub Event Extensions help for event custom post types to federate properly.",
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"php": ">=8.1.0", "php": ">=8.1.0",
@ -32,7 +32,7 @@
} }
], ],
"extra": { "extra": {
"installer-name": "activitypub-event-bridge" "installer-name": "activitypub-event-extensions"
}, },
"scripts": { "scripts": {
"lint": [ "lint": [
@ -54,7 +54,7 @@
], ],
"test-debug": [ "test-debug": [
"@prepare-test", "@prepare-test",
"@test-gatherpress" "@test-vs-event-list"
], ],
"test-vs-event-list": "phpunit --filter=vs_event_list", "test-vs-event-list": "phpunit --filter=vs_event_list",
"test-the-events-calendar": "phpunit --filter=the_events_calendar", "test-the-events-calendar": "phpunit --filter=the_events_calendar",

View file

@ -13,7 +13,7 @@ version: '3'
# "request": "launch", # "request": "launch",
# "port": 9003, # "port": 9003,
# "pathMappings": { # "pathMappings": {
# "/app/": "${workspaceRoot}/wp-content/plugins/activitypub-event-bridge/", # "/app/": "${workspaceRoot}/wp-content/plugins/activitypub-event-extensions/",
# "/tmp/wordpress/": "${workspaceRoot}/" # "/tmp/wordpress/": "${workspaceRoot}/"
# }, # },
# }, # },

View file

@ -10,48 +10,34 @@ To make the WordPress ActivityPub plugin use a custom transformer simply add a f
## Add your event plugin ## Add your event plugin
First you need to add some basic information about your event plugin. Just create a new file in `./includes/plugins/my-event-plugin.php`. Implement at least all abstract functions of the `Event_Plugin` class. First you need to add some basic information about your event plugin in the constant `SUPPORTED_EVENT_PLUGIN` in the file `includes/class-setup.php`:
```php ```php
namespace ActivityPub_Event_Bridge\Plugins; // Example from the Events Manager plugin.
'events_manager' => array( // Choose any key you like.
// Exit if accessed directly. 'plugin_file' => 'events-manager/events-manager.php',
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore 'post_type' => 'event',
'settings_page' => 'options-general.php?page=vsel',
/** 'transformer_class' => 'Events_Manager', // Points to the class in the file `includes/activitypub/transformer/class-events-manager.php`.
* Integration information for My Event Plugin ),
*
* This class defines necessary meta information is for the integration of My Event Plugin with the ActivityPub plugin.
*
* @since 1.0.0
*/
final class My_Event_Plugin extends Event_Plugin {
``` ```
The ActivityPub Event Bridge then takes care of applying the transformer, so you can jump right into implementing it. The Plugin takes care of applying the transformer, so you can jump right into implementing it.
## Writing an event transformer class ## Writing an event transformer class
Within WordPress most content types are stored as a custom post type in the posts table. The ActivityPub plugin offers a basic support for all post types out of the box. So-called transformers take care of converting WordPress WP_Post objects to ActivityStreams JSON. The ActivityPub plugin offers a generic transformer for all post types. Additionally, custom transformers can be implemented to better fit a custom post type, and they can be easily registered with the ActivityPub plugin. If you are writing a transformer for a custom post type it is recommended to start by extending the provided [event transformer](./includes/activitypub/transformer/class-event.php). It is an extension of the default generic post transformer and inherits useful default implementations for generating the [attachments](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment), rendering a proper [content](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content) in HTML from either blocks or the classic editor, extracting [tags](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag) and more.
If you are writing a transformer for your event post type we recommend to start by extending the provided [event transformer](./includes/activitypub/transformer/class-event.php). It is an extension of the default generic post transformer and inherits useful default implementations for generating the [attachments](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment), rendering a proper [content](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content) in HTML from either blocks or the classic editor, extracting [tags](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag) and more. Furthermore, it offers functions which are likely to be shared by multiple event plugins, so you do not need to reimplement those, or you can fork and extend them to your needs.
So create a new file at `./includes/activitypub/transformer/my-event-plugin.php`.
```php ```php
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer;
/** /**
* ActivityPub Transformer for My Event Plugin' event post type. * ActivityPub Transformer for my_event_post_type.
*/ */
class My_Event_Plugin extends Event_Transformer; { class My_Event_Post_Type_Transformer extends Event; {
``` ```
The main function which controls the transformation is `to_object`. This one is called by the ActivityPub plugin to get the resulting ActivityStreams represented by a PHP-object (`\Activitypub\Activity\Object\Extended_Object\Event`). The conversion to the actual JSON-LD takes place later, and you don't need to cover that (> `to_array` > associative array > `to_json` > JSON). The main function which controls the transformation is `to_object`. This one is called by the ActivityPub plugin to get the resulting ActivityPub representation as an PHP-array. The conversion to JSON-LD takes place later, and you don't need to cover that. You might just want to start by applying the parent function, but the chances are high, you don't even need to extend this functions functionality.
The chances are good that you will not need to override that function.
```php ```php
/** /**
@ -66,16 +52,7 @@ public function to_object() {
} }
``` ```
We also recommend extending the constructor of the transformer class and set a specialized API object of the event, if it is available. For instance: The ActivityPub object classes contain dynamic getter and setter functions: `set_<property-name>` and `get_<property-name>`. Of course, the property with `property-name` must exist for these to work. The function `transform_object_properties` tries to set all properties known to the ActivityPub object where a function called `get_<property-name>` exists in the current transformer class.
```php
public function __construct( $wp_object, $wp_taxonomy ) {
parent::__construct( $wp_object, $wp_taxonomy );
$this->event_api = new My_Event_Object_API( $wp_object );
}
```
The ActivityPub object classes contain dynamic getter and setter functions: `set_<property>()` and `get_<property>()`. The function `transform_object_properties()` usually called by `to_object()` tries to set all properties known to the target ActivityPub object where a function called `get_<property>` exists in the current transformer class.
### How to add new properties ### How to add new properties
@ -88,7 +65,7 @@ Adding new properties is not encouraged to do at the transformer level. It's rec
You can find all available event related properties in the [event class](https://github.com/Automattic/wordpress-activitypub/blob/master/includes/activity/extended-object/class-event.php) along documentation and with links to the specifications. You can find all available event related properties in the [event class](https://github.com/Automattic/wordpress-activitypub/blob/master/includes/activity/extended-object/class-event.php) along documentation and with links to the specifications.
#### Mandatory fields #### Mandatory Properties for an Event
In order to ensure your events are compatible with other ActivityPub Event implementations there are several required properties that must be set by your transformer. In order to ensure your events are compatible with other ActivityPub Event implementations there are several required properties that must be set by your transformer.
@ -98,12 +75,8 @@ In order to ensure your events are compatible with other ActivityPub Event imple
* **[`name`](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name)**: the title of the event * **[`name`](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name)**: the title of the event
#### Checklist for properties you SHOULD at least consider writing a getter functions for #### Recommended properties for an Event in order to achieve good interoperability with other ActivityPub platforms
* **`endTime`** * **[summary](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary)**: Other ActivityPub platforms that don't natively support event should use the summary (and the `name`) to display it as a converted object type. For example Mastodon converts an `Event` object to a `Note`. It is recommended to write the summary as text-centered with minimal HTML markup and that it contains the most important event details like place, time, etc.
* **`location`** Note: the `address` within can be both a `string` or a `PostalAddress`.
* **`isOnline`** * **`isOnline`**:
* **`status`**
* **`get_tag`**
* **`timezone`**
* **`commentsEnabled`**

View file

@ -2,32 +2,22 @@
/** /**
* Replace the default ActivityPub Transformer * Replace the default ActivityPub Transformer
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub\Activity\Extended_Object\Event as Event_Object; use Activitypub\Activity\Extended_Object\Event as Event_Object;
use Activitypub\Activity\Extended_Object\Place;
use Activitypub\Transformer\Post; use Activitypub\Transformer\Post;
use DateTime;
/** /**
* Base transformer for WordPress event post types to ActivityPub events. * Base transformer for WordPress event post types to ActivityPub events.
* *
* Everything that transforming several WordPress post types that represent events * Everything that transforming several WordPress post types that represent events
* have in common, as well as sane defaults for events should be defined here. * have in common, as well as sane defaults for events should be defined here.
*
* BeforeFirstRelease:
* [ ] remove link at the end of the content.
* [ ] add organizer.
* [ ] do add Cancelled reason in the content.
*/ */
abstract class Event extends Post { class Event extends Post {
/** /**
* The WordPress event taxonomy. * The WordPress event taxonomy.
@ -36,6 +26,17 @@ abstract class Event extends Post {
*/ */
protected $wp_taxonomy; protected $wp_taxonomy;
/**
* Returns the User-URL of the Author of the Post.
*
* If `single_user` mode is enabled, the URL of the Blog-User is returned.
*
* @return string The User-URL.
*/
protected function get_actor(): ?string {
return $this->get_attributed_to();
}
/** /**
* Returns the ActivityStreams 2.0 Object-Type for an Event. * Returns the ActivityStreams 2.0 Object-Type for an Event.
* *
@ -54,16 +55,6 @@ abstract class Event extends Post {
return comments_open( $this->wp_object ); return comments_open( $this->wp_object );
} }
/**
* Set a hardcoded template for the content.
*
* This actually disabled templates for the content.
* Maybe this independent templates for events will be added later.
*/
protected function get_post_content_template(): string {
return '[ap_content]';
}
/** /**
* Returns the title of the event. * Returns the title of the event.
* *
@ -81,7 +72,7 @@ abstract class Event extends Post {
* @param WP_Post $wp_object The WordPress post object (event). * @param WP_Post $wp_object The WordPress post object (event).
* @param string $wp_taxonomy The taxonomy slug of the event post type. * @param string $wp_taxonomy The taxonomy slug of the event post type.
*/ */
public function __construct( $wp_object, $wp_taxonomy = 'category' ) { public function __construct( $wp_object, $wp_taxonomy ) {
parent::__construct( $wp_object ); parent::__construct( $wp_object );
$this->wp_taxonomy = $wp_taxonomy; $this->wp_taxonomy = $wp_taxonomy;
} }
@ -111,14 +102,9 @@ abstract class Event extends Post {
/** /**
* Set the event category, via the mapping setting. * Set the event category, via the mapping setting.
*
* @return ?string
*/ */
public function get_category(): ?string { public function get_category(): ?string {
if ( is_null( $this->wp_taxonomy ) ) { $current_category_mapping = \get_option( 'activitypub_event_extensions_event_category_mappings', array() );
return null;
}
$current_category_mapping = \get_option( 'activitypub_event_bridge_event_category_mappings', array() );
$terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy ); $terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy );
// Check if the event has a category set and if that category has a specific mapping return that one. // Check if the event has a category set and if that category has a specific mapping return that one.
@ -126,220 +112,10 @@ abstract class Event extends Post {
return sanitize_text_field( $current_category_mapping[ $terms[0]->slug ] ); return sanitize_text_field( $current_category_mapping[ $terms[0]->slug ] );
} else { } else {
// Return the default event category. // Return the default event category.
return sanitize_text_field( \get_option( 'activitypub_event_bridge_default_event_category', 'MEETING' ) ); return sanitize_text_field( \get_option( 'activitypub_event_extensions_default_event_category', 'MEETING' ) );
} }
} }
/**
* Retrieves the excerpt text (may be HTML). Used for constructing the summary.
*
* @return ?string
*/
protected function retrieve_excerpt(): ?string {
if ( $this->wp_object->post_excerpt ) {
return $this->wp_object->post_excerpt;
} else {
return null;
}
}
/**
* Get the start time.
*
* This is mandatory and must be implemented in the final event transformer class.
*/
abstract protected function get_start_time(): string;
/**
* Get the end time.
*
* This is not mandatory and therefore just return null by default.
*/
protected function get_end_time(): ?string {
return null;
}
/**
* Get a default for the location.
*
* This should be overridden in the actual event transformer.
*/
protected function get_location(): ?Place {
return null;
}
/**
* Default value for the event status.
*/
protected function get_status(): ?string {
return 'CONFIRMED';
}
/**
* Compose a human readable formatted start time.
*/
protected function format_start_time(): string {
return $this->format_time( $this->get_start_time() );
}
/**
* Compose a human readable formatted end time.
*/
protected function format_end_time(): string {
return $this->format_time( $this->get_end_time() );
}
/**
* Compose a human readable formatted time.
*
* @param ?string $time The time which needs to be formatted.
*/
private static function format_time( $time ) {
if ( is_null( $time ) ) {
return '';
}
$start_datetime = new DateTime( $time );
$start_timestamp = $start_datetime->getTimestamp();
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
return wp_date( $datetime_format, $start_timestamp );
}
/**
* Format a human readable address.
*/
protected function format_address(): string {
$location = $this->get_location();
if ( is_null( $location ) ) {
return '';
}
$address = $location->get_address();
if ( ! $address ) {
return $location->get_name();
}
if ( is_string( $address ) ) {
return $address;
}
if ( ! is_array( $address ) ) {
return '';
}
return isset( $address['locality'] ) ? $address['locality'] : '';
}
/**
* Format the category using the translation.
*/
protected function format_categories(): string {
if ( is_null( $this->wp_taxonomy ) ) {
return '';
}
$categories = array();
// Add the federated category string.
require_once ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . '/includes/event-categories.php';
$federated_category = $this->get_category();
if ( array_key_exists( $federated_category, ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES ) ) {
$categories[] = ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES[ $federated_category ];
}
// Add all category terms.
$terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy );
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$categories[] = $term->name;
}
}
if ( ! empty( $categories ) ) {
return implode( ' · ', array_unique( $categories ) );
}
return '';
}
/**
* Create a custom summary.
*
* It contains also the most important meta-information. The summary is often used when the
* ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
*
* @return string $summary The custom event summary.
*/
public function get_summary(): ?string {
add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2, 2 );
$excerpt = $this->retrieve_excerpt();
// BeforeFirstRelease: decide whether this should be a admin setting.
$fallback_to_content = true;
if ( is_null( $excerpt ) && $fallback_to_content ) {
$excerpt = parent::get_content();
}
remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) );
$category = $this->format_categories();
$start_time = $this->format_start_time();
$end_time = $this->format_end_time();
$address = $this->format_address();
$formatted_items = array();
if ( ! empty( $category ) ) {
$formatted_items[] = '🏷️ ' . __( 'Category', 'activitypub-event-bridge' ) . ': ' . $category;
}
if ( ! empty( $start_time ) ) {
$formatted_items[] = '🗓️ ' . __( 'Start', 'activitypub-event-bridge' ) . ': ' . $start_time;
}
if ( ! empty( $end_time ) ) {
$formatted_items[] = '⏳ ' . __( 'End', 'activitypub-event-bridge' ) . ': ' . $end_time;
}
if ( ! empty( $address ) ) {
$formatted_items[] = '📍 ' . __( 'Address', 'activitypub-event-bridge' ) . ': ' . $address;
}
// Compose the summary based on the number of meta items.
if ( count( $formatted_items ) > 1 ) {
$summary = '<ul><li>' . implode( '</li><li>', $formatted_items ) . '</li></ul>';
} elseif ( 1 === count( $formatted_items ) ) {
$summary = $formatted_items[0]; // Just the one item without <ul><li>.
} else {
$summary = ''; // No items, so no output.
}
$summary .= $excerpt;
return $summary;
}
/**
* By default set the timezone of the WordPress site.
*
* This is likely to be overwritten by the actual transformer.
*
* @return string The timezone string of the site.
*/
public function get_timezone(): string {
return wp_timezone_string();
}
/**
* Remove the permalink shortcode from a WordPress template.
*
* This used for the summary template, because the summary usually gets,
* used when converting a object, where the URL is usually appended anyway.
*
* @param string $template The template string.
* @param WP_Post|WP_Comment $wp_object The wp_object which was used to select the template.
*/
public static function remove_ap_permalink_from_template( $template, $wp_object ) {
// we could override the template here, to get out custom template from an option.
if ( 'event' === $wp_object->post_type ) {
$template = str_replace( '[ap_permalink]', '', $template );
$template = str_replace( '[ap_permalink type="html"]', '', $template );
}
return $template;
}
/** /**
* Generic function that converts an WP-Event object to an ActivityPub-Event object. * Generic function that converts an WP-Event object to an ActivityPub-Event object.
* *
@ -349,8 +125,6 @@ abstract class Event extends Post {
$activitypub_object = new Event_Object(); $activitypub_object = new Event_Object();
$activitypub_object = $this->transform_object_properties( $activitypub_object ); $activitypub_object = $this->transform_object_properties( $activitypub_object );
// maybe move the following logic (till end of the function) into getter functions.
$published = \strtotime( $this->wp_object->post_date_gmt ); $published = \strtotime( $this->wp_object->post_date_gmt );
$activitypub_object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) ); $activitypub_object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
@ -370,7 +144,7 @@ abstract class Event extends Post {
$activitypub_object->set_to( $activitypub_object->set_to(
array( array(
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
$this->get_actor_object()->get_followers(), // this fails on my machine. $this->get_actor_object()->get_followers(),
) )
); );

View file

@ -2,24 +2,24 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
// Exit if accessed directly. use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer;
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub\Activity\Extended_Object\Event;
use Activitypub\Activity\Extended_Object\Place;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
use EM_Event; use EM_Event;
use Activitypub\Activity\Extended_Object\Event;
use Activitypub\Activity\Extended_Object\Place;
use function Activitypub\esc_hashtag; use function Activitypub\esc_hashtag;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/** /**
* ActivityPub Transformer for events from the WordPress plugin 'Events Manager' * ActivityPub Transformer for events from the WordPress plugin 'Events Manager'
* *
@ -37,17 +37,42 @@ final class Events_Manager extends Event_Transformer {
protected $em_event; protected $em_event;
/** /**
* Extend the constructor, to also set the Eventsmanager objects. * Get transformer name.
* *
* This is a special class object form The Events Calendar which * Retrieve the transformers name.
* has a lot of useful functions, we make use of our getter functions.
* *
* @param WP_Post $wp_object The WordPress object. * @since 1.0.0
* @param string $wp_taxonomy The taxonomy slug of the event post type. * @access public
* @return string Widget name.
*/ */
public function __construct( $wp_object, $wp_taxonomy ) { public function get_transformer_name() {
parent::__construct( $wp_object, $wp_taxonomy ); return 'activitypub-event-transformers/events-manager';
$this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' ); }
/**
* Get transformer title.
*
* Retrieve the transformers label.
*
* @since 1.0.0
* @access public
* @return string Widget title.
*/
public function get_transformer_label() {
return 'Events Manager';
}
/**
* Get supported post types.
*
* Retrieve the list of supported WordPress post types this transformer widget can handle.
*
* @since 1.0.0
* @access public
* @return array Widget categories.
*/
public static function get_supported_post_types() {
return array();
} }
/** /**
@ -64,7 +89,7 @@ final class Events_Manager extends Event_Transformer {
* *
* @return array The Place. * @return array The Place.
*/ */
public function get_location(): ?Place { public function get_location() {
if ( 'url' === $this->em_event->event_location_type ) { if ( 'url' === $this->em_event->event_location_type ) {
return null; return null;
} }
@ -89,6 +114,9 @@ final class Events_Manager extends Event_Transformer {
if ( $em_location->location_state ) { if ( $em_location->location_state ) {
$address['addressRegion'] = $em_location->location_state; $address['addressRegion'] = $em_location->location_state;
} }
if ( $em_location->location_postcode ) {
$address['postalCode'] = $em_location->location_postcode;
}
$location->set_address( $address ); $location->set_address( $address );
return $location; return $location;
@ -97,14 +125,14 @@ final class Events_Manager extends Event_Transformer {
/** /**
* Get the end time from the events metadata. * Get the end time from the events metadata.
*/ */
public function get_end_time(): ?string { public function get_end_time() {
return null; return null;
} }
/** /**
* Get the end time from the events metadata. * Get the end time from the events metadata.
*/ */
public function get_start_time(): string { public function get_start_time() {
$date_string = $this->em_event->event_start_date; $date_string = $this->em_event->event_start_date;
$time_string = $this->em_event->event_start_time; $time_string = $this->em_event->event_start_time;
$timezone_string = $this->em_event->event_timezone; $timezone_string = $this->em_event->event_timezone;
@ -135,8 +163,8 @@ final class Events_Manager extends Event_Transformer {
* @return int * @return int
*/ */
public function get_remaining_attendee_capacity() { public function get_remaining_attendee_capacity() {
$em_bookings_count = $this->get_participant_count(); $em_bookings = $this->em_event->get_bookings()->get_bookings();
$remaining_attendee_capacity = $this->em_event->event_spaces - $em_bookings_count; $remaining_attendee_capacity = $this->em_event->event_spaces - count( $em_bookings->bookings );
return $remaining_attendee_capacity; return $remaining_attendee_capacity;
} }
@ -150,6 +178,23 @@ final class Events_Manager extends Event_Transformer {
return count( $em_bookings->bookings ); return count( $em_bookings->bookings );
} }
/**
* Hardcoded function for generating a summary.
*/
public function get_summary() {
if ( $this->em_event->post_excerpt ) {
$excerpt = $this->em_event->post_excerpt;
} else {
$excerpt = $this->get_content();
}
$address = $this->em_event->get_location()->location_name;
$start_time = strtotime( $this->get_start_time() );
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$start_time_string = wp_date( $datetime_format, $start_time );
$summary = "📍 {$address}\n📅 {$start_time_string}\n\n{$excerpt}";
return $summary;
}
/** /**
* Get the event link as an ActivityPub Link object, but as an associative array. * Get the event link as an ActivityPub Link object, but as an associative array.
* *
@ -215,4 +260,20 @@ final class Events_Manager extends Event_Transformer {
protected function get_name(): string { protected function get_name(): string {
return $this->em_event->event_name; return $this->em_event->event_name;
} }
/**
* Transform the WordPress Object into an ActivityPub Object.
*
* @return Activitypub\Activity\Event
*/
public function to_object(): Event {
$this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' );
$activitypub_object = new Event();
$activitypub_object = $this->transform_object_properties( $activitypub_object );
$activitypub_object->set_external_participation_url( $this->get_url() );
return $activitypub_object;
}
} }

View file

@ -2,21 +2,24 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub_Event_Extensions\Activitypub\Transformer\Event;
use Activitypub\Model\Blog;
use Activitypub\Activity\Extended_Object\Event as Event_Object; use Activitypub\Activity\Extended_Object\Event as Event_Object;
use Activitypub\Activity\Extended_Object\Place; use Activitypub\Activity\Extended_Object\Place;
use Activitypub\Model\Blog;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event;
use GatherPress\Core\Event as GatherPress_Event; use GatherPress\Core\Event as GatherPress_Event;
use function Activitypub\get_rest_url_by_path;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/** /**
* ActivityPub Transformer for VS Event * ActivityPub Transformer for VS Event
* *
@ -24,6 +27,13 @@ use GatherPress\Core\Event as GatherPress_Event;
*/ */
final class GatherPress extends Event { final class GatherPress extends Event {
/**
* The target ActivityPub Event object of the transformer.
*
* @var Event
*/
protected $ap_object;
/** /**
* The current GatherPress Event object. * The current GatherPress Event object.
* *
@ -53,12 +63,25 @@ final class GatherPress extends Event {
$this->gp_venue = $this->gp_event->get_venue_information(); $this->gp_venue = $this->gp_event->get_venue_information();
} }
/**
* Get supported post types.
*
* Retrieve the list of supported WordPress post types this transformer widget can handle.
*
* @since 1.0.0
* @access public
* @return array Widget categories.
*/
public static function get_supported_post_types() {
return array( GatherPress_Event::POST_TYPE );
}
/** /**
* Get the event location. * Get the event location.
* *
* @return Place|null The place objector null if not place set. * @return Place|null The place objector null if not place set.
*/ */
public function get_location(): ?Place { public function get_location(): Place|null {
$address = $this->gp_venue['full_address']; $address = $this->gp_venue['full_address'];
if ( $address ) { if ( $address ) {
$place = new Place(); $place = new Place();
@ -74,14 +97,14 @@ final class GatherPress extends Event {
/** /**
* Get the end time from the event object. * Get the end time from the event object.
*/ */
protected function get_end_time(): ?string { protected function get_end_time() {
return $this->gp_event->get_datetime_end( 'Y-m-d\TH:i:s\Z' ); return $this->gp_event->get_datetime_end( 'Y-m-d\TH:i:s\Z' );
} }
/** /**
* Get the end time from the event object. * Get the end time from the event object.
*/ */
protected function get_start_time(): string { protected function get_start_time() {
return $this->gp_event->get_datetime_start( 'Y-m-d\TH:i:s\Z' ); return $this->gp_event->get_datetime_start( 'Y-m-d\TH:i:s\Z' );
} }
@ -118,30 +141,47 @@ final class GatherPress extends Event {
} }
/** /**
* Prevents gatherpress blocks from being rendered for the content. * Returns the User-URL of the Author of the Post.
* *
* @param mixed $block_content The blocks content. * If `single_user` mode is enabled, the URL of the Blog-User is returned.
* @param mixed $block The block. *
* @return string The User-URL.
*/ */
public static function filter_gatherpress_blocks( $block_content, $block ) { protected function get_attributed_to(): string {
// Check if the block name starts with 'gatherpress'. $user = new Blog();
if ( strpos( $block['blockName'], 'gatherpress/' ) === 0 ) { return $user->get_url();
return ''; // Skip rendering this block.
}
return $block_content; // Return the content for other blocks.
} }
/** /**
* Apply the filter for preventing the rendering off gatherpress blocks just in time. * Create a custom summary.
* *
* @return Event_Object * It contains also the most important meta-information. The summary is often used when the
* ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
*
* @return string $summary The custom event summary.
*/ */
public function to_object(): Event_Object { public function get_summary(): string {
add_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ), 10, 2 ); if ( $this->wp_object->excerpt ) {
$activitypub_object = parent::to_object(); $excerpt = $this->wp_object->post_excerpt;
remove_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ) ); } elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
return $activitypub_object; $excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
} else {
$excerpt = $this->get_content();
}
$address = get_post_meta( $this->wp_object->ID, 'event-location', true );
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$start_time_string = wp_date( $datetime_format, $start_time );
$summary = "📍 {$address}\n📅 {$start_time_string}\n\n{$excerpt}";
return $summary;
}
/**
* Get the content.
*/
public function get_content(): string {
return $this->wp_object->post_content;
} }
/** /**
@ -152,4 +192,16 @@ final class GatherPress extends Event {
public function get_is_online(): bool { public function get_is_online(): bool {
return $this->gp_event->maybe_get_online_event_link() ? true : false; return $this->gp_event->maybe_get_online_event_link() ? true : false;
} }
/**
* Transform the WordPress Object into an ActivityPub Object.
*
* @return Activitypub\Activity\Event
*/
public function to_object(): Event_Object {
$activitypub_object = parent::to_object();
return $activitypub_object;
}
} }

View file

@ -2,22 +2,22 @@
/** /**
* ActivityPub Tribe Transformer * ActivityPub Tribe Transformer
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
// Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) {
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore exit; // Exit if accessed directly.
}
use Activitypub\Activity\Extended_Object\Event as Event_Object; use Activitypub_Event_Extensions\Activitypub\Transformer\Event;
use Activitypub\Activity\Extended_Object\Place; use Activitypub\Activity\Extended_Object\Place;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event; use Activitypub\Activity\Extended_Object\Event as Event_Object;
use WP_Error;
use WP_Post; use WP_Post;
use function Activitypub\esc_hashtag;
/** /**
* ActivityPub Tribe Transformer * ActivityPub Tribe Transformer
* *
@ -47,36 +47,24 @@ final class The_Events_Calendar extends Event {
} }
/** /**
* Get the tags, including also the set categories from The Events Calendar. * Get tribe category of wp_post
* *
* @return ?array The array if tags, * @return string|null tribe category if it exists
*/ */
public function get_tag(): ?array { public function get_tribe_category() {
$tags = array(); $categories = tribe_get_event_cat_slugs( $this->wp_object->ID );
$category_ids = tribe_get_event_cat_ids();
if ( $category_ids ) {
foreach ( $category_ids as $category_id ) {
$term = \get_term( $category_id );
$tag = array(
'type' => 'Hashtag',
'href' => \esc_url( \get_term_link( $term ) ),
'name' => esc_hashtag( $term->name ),
);
$tags[] = $tag;
}
}
$tags = array_merge( $tags, parent::get_tag() );
return $tags; if ( count( $categories ) === 0 ) {
return null;
}
return $categories[0];
} }
/** /**
* Get the end time from the event object. * Get the end time from the event object.
*/ */
protected function get_end_time(): ?string { protected function get_end_time() {
if ( empty( $this->tribe_event->end_date ) ) {
return null;
}
$date = date_create( $this->tribe_event->end_date, wp_timezone() ); $date = date_create( $this->tribe_event->end_date, wp_timezone() );
return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() );
} }
@ -84,7 +72,7 @@ final class The_Events_Calendar extends Event {
/** /**
* Get the end time from the event object. * Get the end time from the event object.
*/ */
protected function get_start_time(): string { protected function get_start_time() {
$date = date_create( $this->tribe_event->start_date, wp_timezone() ); $date = date_create( $this->tribe_event->start_date, wp_timezone() );
return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() );
} }
@ -94,16 +82,20 @@ final class The_Events_Calendar extends Event {
* *
* @return string status of the event * @return string status of the event
*/ */
public function get_status(): ?string { public function get_tribe_status() {
if ( 'canceled' === $this->tribe_event->event_status ) { if ( 'canceled' === $this->tribe_event->event_status ) {
return 'CANCELLED'; return 'CANCELLED';
} }
if ( 'postponed' === $this->tribe_event->event_status ) { if ( 'postponed' === $this->tribe_event->event_status ) {
return 'CANCELLED'; // This will be reflected in the cancelled reason. return 'CANCELLED'; // This will be reflected in the cancelled reason.
} }
if ( '' === $this->tribe_event->event_status ) {
return 'CONFIRMED'; return 'CONFIRMED';
} }
return new WP_Error( 'invalid event_status value', __( 'invalid event_status', 'activitypub' ), array( 'status' => 404 ) );
}
/** /**
* Check if the comments are enabled for the current event. * Check if the comments are enabled for the current event.
@ -119,6 +111,24 @@ final class The_Events_Calendar extends Event {
return false; return false;
} }
/**
* Returns the content for the ActivityPub Item with
*
* The content will be generated based on the user settings.
*
* @return string The content.
*/
protected function get_content() {
$content = parent::get_content();
// /BeforeFirstRelease:
// * remove link at the end of the content.
// * add organizer.
// * do add Cancelled reason in the content.s
return $content;
}
/** /**
* Get the event location. * Get the event location.
* *
@ -126,7 +136,7 @@ final class The_Events_Calendar extends Event {
*/ */
public function get_location(): Place|null { public function get_location(): Place|null {
// Get short handle for the venues. // Get short handle for the venues.
$venues = $this->tribe_event->venues; $venues = $this->wp_object->venues;
// Get first venue. We currently only support a single venue. // Get first venue. We currently only support a single venue.
if ( $venues instanceof \Tribe\Events\Collections\Lazy_Post_Collection ) { if ( $venues instanceof \Tribe\Events\Collections\Lazy_Post_Collection ) {
@ -171,8 +181,6 @@ final class The_Events_Calendar extends Event {
$location = new Place(); $location = new Place();
if ( count( $address ) > 1 ) { if ( count( $address ) > 1 ) {
$location->set_address( $address ); $location->set_address( $address );
} else {
$location->set_address( $venue->post_title );
} }
$location->set_id( $venue->permalink ); $location->set_id( $venue->permalink );
$location->set_name( $venue->post_title ); $location->set_name( $venue->post_title );
@ -181,11 +189,15 @@ final class The_Events_Calendar extends Event {
} }
/** /**
* Get the timezone of the event. * Extend the default event transformers to_object function.
* *
* @return string The timezone string of the site. * This is the heart of the ActivityPub transformer.
*
* @return Event_Object
*/ */
public function get_timezone(): string { public function to_object(): Event_Object {
return $this->tribe_event->timezone; $activitypub_object = parent::to_object();
return $activitypub_object;
} }
} }

View file

@ -2,18 +2,22 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Activitypub\Transformer; namespace Activitypub_Event_Extensions\Activitypub\Transformer;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer;
use Activitypub\Activity\Extended_Object\Event; use Activitypub\Activity\Extended_Object\Event;
use Activitypub\Activity\Extended_Object\Place; use Activitypub\Activity\Extended_Object\Place;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer;
use WP_Error;
use function Activitypub\get_rest_url_by_path;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/** /**
* ActivityPub Transformer for VS Event. * ActivityPub Transformer for VS Event.
@ -23,6 +27,23 @@ use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer;
* @since 1.0.0 * @since 1.0.0
*/ */
final class VS_Event_List extends Event_Transformer { final class VS_Event_List extends Event_Transformer {
/**
* The target transformer ActivityPub Event object.
*
* @var Event
*/
protected $ap_object;
/**
* Returns the ActivityStreams 2.0 Object-Type for an Event.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event
* @since 1.0.0
* @return string The Event Object-Type.
*/
protected function get_type(): string {
return 'Event';
}
/** /**
* Get the event location. * Get the event location.
@ -50,9 +71,6 @@ final class VS_Event_List extends Event_Transformer {
return null; return null;
} }
$end_time = get_post_meta( $this->wp_object->ID, 'event-date', true ); $end_time = get_post_meta( $this->wp_object->ID, 'event-date', true );
if ( is_null( $end_time ) || empty( $end_time ) || 'no' === $end_time ) {
return null;
}
return $end_time ? \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ) : null; return $end_time ? \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ) : null;
} }
@ -61,7 +79,7 @@ final class VS_Event_List extends Event_Transformer {
*/ */
protected function get_start_time(): string { protected function get_start_time(): string {
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true ); $start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );
return \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ); return $start_time ? \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ) : null;
} }
/** /**
@ -100,15 +118,27 @@ final class VS_Event_List extends Event_Transformer {
} }
/** /**
* Retrieves the excerpt text (may be HTML). Used for constructing the summary. * Create a custom summary.
* *
* @return ?string * It contains also the most important meta-information. The summary is often used when the
* ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
*
* @return string $summary The custom event summary.
*/ */
protected function retrieve_excerpt(): ?string { public function get_summary(): ?string {
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) { if ( $this->wp_object->excerpt ) {
return get_post_meta( $this->wp_object->ID, 'event-summary', true ); $excerpt = $this->wp_object->post_excerpt;
} elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
$excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
} else { } else {
return parent::retrieve_excerpt(); $excerpt = $this->get_content();
} }
$address = get_post_meta( $this->wp_object->ID, 'event-location', true );
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$start_time_string = wp_date( $datetime_format, $start_time );
$summary = "📍 {$address}\n📅 {$start_time_string}\n\n{$excerpt}";
return $summary;
} }
} }

View file

@ -4,17 +4,14 @@
* *
* Notices for guiding to proper configuration of ActivityPub with event plugins. * Notices for guiding to proper configuration of ActivityPub with event plugins.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Admin; namespace Activitypub_Event_Extensions\Admin;
// Exit if accessed directly. use Activitypub_Event_Extensions\Plugins\Event_Plugin;
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use ActivityPub_Event_Bridge\Plugins\Event_Plugin;
/** /**
* Class responsible for Event Plugin related admin notices. * Class responsible for Event Plugin related admin notices.
@ -76,7 +73,7 @@ class Event_Plugin_Admin_Notices {
_x( _x(
'You have installed the <i>%1$s</i> plugin, but the event post type of the plugin <i>%2$s</i> is <b>not enabled</b> in the <a href="%3$s">%1$s settings</a>.', 'You have installed the <i>%1$s</i> plugin, but the event post type of the plugin <i>%2$s</i> is <b>not enabled</b> in the <a href="%3$s">%1$s settings</a>.',
'admin notice', 'admin notice',
'activitypub-event-bridge' 'activitypub-event-extensions'
), ),
esc_html( $activitypub_plugin_data['Name'] ), esc_html( $activitypub_plugin_data['Name'] ),
esc_html( $event_plugin_data['Name'] ), esc_html( $event_plugin_data['Name'] ),

View file

@ -4,15 +4,12 @@
* *
* Notices for guiding to proper configuration of this plugin. * Notices for guiding to proper configuration of this plugin.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge\Admin; namespace Activitypub_Event_Extensions\Admin;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
/** /**
* Class responsible for general admin notices. * Class responsible for general admin notices.
@ -29,7 +26,7 @@ class General_Admin_Notices {
*/ */
const ACTIVITYPUB_PLUGIN_URL = 'https://wordpress.org/plugins/activitypub'; const ACTIVITYPUB_PLUGIN_URL = 'https://wordpress.org/plugins/activitypub';
const ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge#events-plugin-that-will-be-supported-at-first'; const ACTIVITYPUB_EVENT_EXTENSIONS_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-extensions#events-plugin-that-will-be-supported-at-first';
/** /**
* Allowed HTML for admin notices. * Allowed HTML for admin notices.
@ -54,9 +51,9 @@ class General_Admin_Notices {
return sprintf( return sprintf(
/* translators: 1: An URL that points to the ActivityPub plugin. */ /* translators: 1: An URL that points to the ActivityPub plugin. */
_x( _x(
'For the ActivityPub Event Bridge to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.', 'For the ActivityPub Event Extensions to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.',
'admin notice', 'admin notice',
'activitypub-event-bridge' 'activitypub-event-extensions'
), ),
esc_html( self::ACTIVITYPUB_PLUGIN_URL ) esc_html( self::ACTIVITYPUB_PLUGIN_URL )
); );
@ -71,12 +68,12 @@ class General_Admin_Notices {
return sprintf( return sprintf(
/* translators: 1: The name of the ActivityPub plugin. 2: The minimum required version number of the ActivityPub plugin. */ /* translators: 1: The name of the ActivityPub plugin. 2: The minimum required version number of the ActivityPub plugin. */
_x( _x(
'Please upgrade your <a href="%1$s">ActivityPub</a> plugin. At least version %2$s is required for the ActivityPub Event Bridge to work.', 'Please upgrade your <a href="%1$s">ActivityPub</a> plugin. At least version %2$s is required for the ActivityPub event extensions to work.',
'admin notice', 'admin notice',
'activitypub-event-bridge' 'activitypub-event-extensions'
), ),
esc_html( self::ACTIVITYPUB_PLUGIN_URL ), esc_html( self::ACTIVITYPUB_PLUGIN_URL ),
esc_html( ACTIVITYPUB_EVENT_BRIDGE_ACTIVITYPUB_PLUGIN_MIN_VERSION ) esc_html( ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION )
); );
} }
@ -89,12 +86,12 @@ class General_Admin_Notices {
return sprintf( return sprintf(
/* translators: 1: An URL to the list of supported event plugins. */ /* translators: 1: An URL to the list of supported event plugins. */
_x( _x(
'The Plugin <i>ActivityPub Event Bridge</i> is of no use, because you do not have installed and activated a supported Event Plugin. 'The Plugin <i>ActivityPub Event Extensions</i> is of no use, because you do not have installed and activated a supported Event Plugin.
<br> For a list of supported Event Plugins see <a href="%1$s">here</a>.', <br> For a list of supported Event Plugins see <a href="%1$s">here</a>.',
'admin notice', 'admin notice',
'activitypub-event-bridge' 'activitypub-event-extensions'
), ),
esc_html( self::ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL ) esc_html( self::ACTIVITYPUB_EVENT_EXTENSIONS_SUPPORTED_EVENT_PLUGINS_URL )
); );
} }

View file

@ -5,18 +5,18 @@
* This file contains the General class definition, which handles the "General" settings * This file contains the General class definition, which handles the "General" settings
* page for the ActivityPub Event Extension Plugin, providing options for configuring various general settings. * page for the ActivityPub Event Extension Plugin, providing options for configuring various general settings.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Admin; namespace Activitypub_Event_Extensions\Admin;
use Activitypub_Event_Extensions\Setup;
use Activitypub_Event_Extensions\Plugins\Event_Plugin;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use ActivityPub_Event_Bridge\Plugins\Event_Plugin;
use ActivityPub_Event_Bridge\Setup;
/** /**
* Class responsible for the ActivityPub Event Extension related Settings. * Class responsible for the ActivityPub Event Extension related Settings.
* *
@ -26,9 +26,9 @@ use ActivityPub_Event_Bridge\Setup;
* @since 1.0.0 * @since 1.0.0
*/ */
class Settings_Page { class Settings_Page {
const STATIC = 'ActivityPub_Event_Bridge\Admin\Settings_Page'; const STATIC = 'Activitypub_Event_Extensions\Admin\Settings_Page';
const SETTINGS_SLUG = 'activitypub-event-bridge'; const SETTINGS_SLUG = 'activitypub-event-extensions';
/** /**
* Warning if the plugin is Active and the ActivityPub plugin is not. * Warning if the plugin is Active and the ActivityPub plugin is not.
* *
@ -37,7 +37,7 @@ class Settings_Page {
public static function admin_menu(): void { public static function admin_menu(): void {
\add_options_page( \add_options_page(
'Activitypub Event Extension', 'Activitypub Event Extension',
__( 'ActivityPub Events', 'activitypub-event-bridge' ), __( 'ActivityPub Events', 'activitypub-event-extensions' ),
'manage_options', 'manage_options',
self::SETTINGS_SLUG, self::SETTINGS_SLUG,
array( self::STATIC, 'settings_page' ) array( self::STATIC, 'settings_page' )
@ -104,6 +104,6 @@ class Settings_Page {
'event_terms' => $event_terms, 'event_terms' => $event_terms,
); );
\load_template( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . 'templates/settings.php', true, $args ); \load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings.php', true, $args );
} }
} }

View file

@ -1,17 +1,17 @@
<?php <?php
/** /**
* Class responsible for autoloading ActivityPub Event Bridge class files. * Class responsible for autoloading ActivityPub Event Extensions class files.
* *
* The Autoloader class is responsible for automatically loading class files as needed * The Autoloader class is responsible for automatically loading class files as needed
* to ensure a clean and organized codebase. It maps class names to their corresponding * to ensure a clean and organized codebase. It maps class names to their corresponding
* file locations within the GatherPress plugin. * file locations within the GatherPress plugin.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge; namespace Activitypub_Event_Extensions;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
@ -34,8 +34,8 @@ class Autoloader {
public static function register(): void { public static function register(): void {
spl_autoload_register( spl_autoload_register(
function ( $full_class ) { function ( $full_class ) {
$base_dir = ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . '/includes/'; $base_dir = ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . '/includes/';
$base = 'ActivityPub_Event_Bridge\\'; $base = 'Activitypub_Event_Extensions\\';
if ( strncmp( $full_class, $base, strlen( $base ) ) === 0 ) { if ( strncmp( $full_class, $base, strlen( $base ) ) === 0 ) {
$maybe_uppercase = str_replace( $base, '', $full_class ); $maybe_uppercase = str_replace( $base, '', $full_class );

View file

@ -5,17 +5,17 @@
* This file contains the General class definition, which handles the "General" settings * This file contains the General class definition, which handles the "General" settings
* page for the ActivityPub Event Extension Plugin, providing options for configuring various general settings. * page for the ActivityPub Event Extension Plugin, providing options for configuring various general settings.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge; namespace Activitypub_Event_Extensions;
use Activitypub\Activity\Extended_Object\Event;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub\Activity\Extended_Object\Event;
/** /**
* Class responsible for the ActivityPui Event Extension related Settings. * Class responsible for the ActivityPui Event Extension related Settings.
* *
@ -24,7 +24,7 @@ use Activitypub\Activity\Extended_Object\Event;
* @since 1.0.0 * @since 1.0.0
*/ */
class Settings { class Settings {
const SETTINGS_SLUG = 'activitypub-event-bridge'; const SETTINGS_SLUG = 'activitypub-event-extensions';
/** /**
* The default ActivityPub event category. * The default ActivityPub event category.
@ -34,14 +34,14 @@ class Settings {
const DEFAULT_EVENT_CATEGORY = 'MEETING'; const DEFAULT_EVENT_CATEGORY = 'MEETING';
/** /**
* Register the settings for the ActivityPub Event Bridge plugin. * Register the settings for the ActivityPub Event Extensions plugin.
* *
* @return void * @return void
*/ */
public static function register_settings(): void { public static function register_settings(): void {
\register_setting( \register_setting(
'activitypub-event-bridge', 'activitypub-event-extensions',
'activitypub_event_bridge_default_event_category', 'activitypub_event_extensions_default_event_category',
array( array(
'type' => 'string', 'type' => 'string',
'description' => \__( 'Define your own custom post template', 'activitypub' ), 'description' => \__( 'Define your own custom post template', 'activitypub' ),
@ -52,8 +52,8 @@ class Settings {
); );
\register_setting( \register_setting(
'activitypub-event-bridge', 'activitypub-event-extensions',
'activitypub_event_bridge_event_category_mappings', 'activitypub_event_extensions_event_category_mappings',
array( array(
'type' => 'array', 'type' => 'array',
'description' => \__( 'Define your own custom post template', 'activitypub' ), 'description' => \__( 'Define your own custom post template', 'activitypub' ),

View file

@ -1,31 +1,31 @@
<?php <?php
/** /**
* Class responsible for initializing ActivityPub Event Bridge. * Class responsible for initializing ActivityPub Event Extensions.
* *
* The setup class provides function for checking if this plugin should be activated. * The setup class provides function for checking if this plugin should be activated.
* It detects supported event plugins and provides all setup hooks and filters. * It detects supported event plugins and provides all setup hooks and filters.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
namespace ActivityPub_Event_Bridge; namespace Activitypub_Event_Extensions;
use Activitypub_Event_Extensions\Admin\Event_Plugin_Admin_Notices;
use Activitypub_Event_Extensions\Admin\General_Admin_Notices;
use Activitypub_Event_Extensions\Admin\Settings_Page;
use Activitypub_Event_Extensions\Plugins\Event_Plugin;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use ActivityPub_Event_Bridge\Admin\Event_Plugin_Admin_Notices;
use ActivityPub_Event_Bridge\Admin\General_Admin_Notices;
use ActivityPub_Event_Bridge\Admin\Settings_Page;
use ActivityPub_Event_Bridge\Plugins\Event_Plugin;
require_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php';
/** /**
* Class Setup. * Class Setup.
* *
* This class is responsible for initializing ActivityPub Event Bridge. * This class is responsible for initializing ActivityPub Event Extensions.
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -63,7 +63,7 @@ class Setup {
is_plugin_active( 'activitypub/activitypub.php' ); is_plugin_active( 'activitypub/activitypub.php' );
// BeforeFirstRelease: decide whether we want to do anything at all when ActivityPub plugin is note active. // BeforeFirstRelease: decide whether we want to do anything at all when ActivityPub plugin is note active.
// if ( ! $this->activitypub_plugin_is_active ) { // if ( ! $this->activitypub_plugin_is_active ) {
// deactivate_plugins( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ); // deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE );
// return; // return;
// }. // }.
$this->active_event_plugins = self::detect_active_event_plugins(); $this->active_event_plugins = self::detect_active_event_plugins();
@ -124,10 +124,10 @@ class Setup {
* @var array * @var array
*/ */
private const EVENT_PLUGIN_CLASSES = array( private const EVENT_PLUGIN_CLASSES = array(
'\ActivityPub_Event_Bridge\Plugins\Events_Manager', '\Activitypub_Event_Extensions\Plugins\Events_Manager',
'\ActivityPub_Event_Bridge\Plugins\GatherPress', '\Activitypub_Event_Extensions\Plugins\GatherPress',
'\ActivityPub_Event_Bridge\Plugins\The_Events_Calendar', '\Activitypub_Event_Extensions\Plugins\The_Events_Calendar',
'\ActivityPub_Event_Bridge\Plugins\VS_Event_List', '\Activitypub_Event_Extensions\Plugins\VS_Event_List',
); );
/** /**
@ -160,7 +160,7 @@ class Setup {
* @return void * @return void
*/ */
protected function setup_hooks(): void { protected function setup_hooks(): void {
register_activation_hook( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE, array( $this, 'activate' ) ); register_activation_hook( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE, array( $this, 'activate' ) );
add_action( 'admin_init', array( $this, 'do_admin_notices' ) ); add_action( 'admin_init', array( $this, 'do_admin_notices' ) );
add_action( 'admin_init', array( Settings::class, 'register_settings' ) ); add_action( 'admin_init', array( Settings::class, 'register_settings' ) );
@ -175,12 +175,12 @@ class Setup {
add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) ); add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) );
add_filter( add_filter(
'plugin_action_links_' . ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_BASENAME, 'plugin_action_links_' . ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_BASENAME,
array( Settings_Page::class, 'settings_link' ) array( Settings_Page::class, 'settings_link' )
); );
// Check if the minimum required version of the ActivityPub plugin is installed. // 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, ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
return; return;
} }
@ -195,15 +195,15 @@ class Setup {
* @return void * @return void
*/ */
public static function enqueue_styles( $hook_suffix ): void { public static function enqueue_styles( $hook_suffix ): void {
if ( false !== strpos( $hook_suffix, 'activitypub-event-bridge' ) ) { if ( false !== strpos( $hook_suffix, 'activitypub-event-extensions' ) ) {
wp_enqueue_style( wp_enqueue_style(
'activitypub-event-bridge-admin-styles', 'activitypub-event-extensions-admin-styles',
plugins_url( plugins_url(
'assets/css/activitypub-event-bridge-admin.css', 'assets/css/activitypub-event-extensions-admin.css',
ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE
), ),
array(), array(),
ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_VERSION ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_VERSION
); );
} }
} }
@ -218,15 +218,15 @@ class Setup {
// Check if any general admin notices are needed and add actions to insert the needed admin notices. // Check if any general admin notices are needed and add actions to insert the needed admin notices.
if ( ! $this->activitypub_plugin_is_active ) { if ( ! $this->activitypub_plugin_is_active ) {
// The ActivityPub plugin is not 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( 'Activitypub_Event_Extensions\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, ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
// The ActivityPub plugin is too old. // 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( 'Activitypub_Event_Extensions\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 );
} }
if ( empty( $this->active_event_plugins ) ) { if ( empty( $this->active_event_plugins ) ) {
// No supported Event Plugin is active. // 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( 'Activitypub_Event_Extensions\Admin\General_Admin_Notices', 'no_supported_event_plugin_active' ), 10, 1 );
} }
} }
@ -272,16 +272,15 @@ class Setup {
foreach ( $this->active_event_plugins as $event_plugin ) { foreach ( $this->active_event_plugins as $event_plugin ) {
if ( ! in_array( $event_plugin->get_post_type(), $activitypub_supported_post_types, true ) ) { if ( ! in_array( $event_plugin->get_post_type(), $activitypub_supported_post_types, true ) ) {
$activitypub_supported_post_types[] = $event_plugin->get_post_type(); $activitypub_supported_post_types[] = $event_plugin->get_post_type();
add_post_type_support( $event_plugin->get_post_type(), 'activitypub' );
} }
} }
update_option( 'activitypub_support_post_types', $activitypub_supported_post_types ); update_option( 'activitypub_support_post_types', $activitypub_supported_post_types );
} }
/** /**
* Activates the ActivityPub Event Bridge plugin. * Activates the ActivityPub Event Extensions plugin.
* *
* This method handles the activation of the ActivityPub Event Bridge plugin. * This method handles the activation of the ActivityPub Event Extensions plugin.
* *
* @since 1.0.0 * @since 1.0.0
* *
@ -290,7 +289,7 @@ class Setup {
public function activate(): void { public function activate(): void {
// Don't allow plugin activation, when the ActivityPub plugin is not activated yet. // Don't allow plugin activation, when the ActivityPub plugin is not activated yet.
if ( ! $this->activitypub_plugin_is_active ) { if ( ! $this->activitypub_plugin_is_active ) {
deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ) ); deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ) );
$notice = General_Admin_Notices::get_admin_notice_activitypub_plugin_not_enabled(); $notice = General_Admin_Notices::get_admin_notice_activitypub_plugin_not_enabled();
wp_die( wp_die(
wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ), wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ),
@ -300,7 +299,7 @@ class Setup {
} }
if ( empty( $this->active_event_plugins ) ) { if ( empty( $this->active_event_plugins ) ) {
deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ) ); deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ) );
$notice = General_Admin_Notices::get_admin_notice_no_supported_event_plugin_active(); $notice = General_Admin_Notices::get_admin_notice_no_supported_event_plugin_active();
wp_die( wp_die(
wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ), wp_kses( $notice, General_Admin_Notices::ALLOWED_HTML ),

View file

@ -1,47 +0,0 @@
<?php
/**
* File responsible for defining the event category strings.
*
* @package ActivityPub_Event_Bridge
* @since 1.0.0
* @license AGPL-3.0-or-later
*/
namespace ActivityPub_Event_Bridge;
define(
'ACTIVITYPUB_EVENT_BRIDGE_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.
),
);

View file

@ -4,13 +4,13 @@
* *
* Basic information that each supported event needs for this plugin to work. * Basic information that each supported event needs for this plugin to work.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Plugins; namespace Activitypub_Event_Extensions\Plugins;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer; use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

View file

@ -5,11 +5,11 @@
* Defines all the necessary meta information for the Events Manager WordPress Plugin. * Defines all the necessary meta information for the Events Manager WordPress Plugin.
* *
* @link https://wordpress.org/plugins/events-manager/ * @link https://wordpress.org/plugins/events-manager/
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Plugins; namespace Activitypub_Event_Extensions\Plugins;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

View file

@ -5,11 +5,11 @@
* Defines all the necessary meta information for the GatherPress plugin. * Defines all the necessary meta information for the GatherPress plugin.
* *
* @link https://wordpress.org/plugins/gatherpress/ * @link https://wordpress.org/plugins/gatherpress/
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Plugins; namespace Activitypub_Event_Extensions\Plugins;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

View file

@ -5,11 +5,11 @@
* Defines all the necessary meta information for the events calendar. * Defines all the necessary meta information for the events calendar.
* *
* @link https://wordpress.org/plugins/the-events-calendar/ * @link https://wordpress.org/plugins/the-events-calendar/
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Plugins; namespace Activitypub_Event_Extensions\Plugins;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

View file

@ -6,13 +6,13 @@
* "Very Simple Events List". * "Very Simple Events List".
* *
* @link https://de.wordpress.org/plugins/very-simple-event-list/ * @link https://de.wordpress.org/plugins/very-simple-event-list/
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
*/ */
namespace ActivityPub_Event_Bridge\Plugins; namespace Activitypub_Event_Extensions\Plugins;
use ActivityPub_Event_Bridge\Event_Plugins; use Activitypub_Event_Extensions\Event_Plugins;
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

View file

@ -105,7 +105,7 @@
<rule ref="WordPress.WP.I18n"> <rule ref="WordPress.WP.I18n">
<properties> <properties>
<property name="text_domain" type="array"> <property name="text_domain" type="array">
<element value="activitypub-event-bridge"/> <element value="activitypub-event-extensions"/>
<element value="activitypub"/> <element value="activitypub"/>
</property> </property>
</properties> </properties>
@ -114,7 +114,7 @@
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties> <properties>
<property name="prefixes" type="array"> <property name="prefixes" type="array">
<element value="ACTIVITYPUB_EVENT_BRIDGE"/> <element value="ACTIVITYPUB_EVENT_EXTENSIONS"/>
</property> </property>
</properties> </properties>
</rule> </rule>

View file

@ -1,6 +1,6 @@
=== ActivityPub Event Bridge === === ActivityPub Event Extensions ===
Contributors: andremenrath Contributors: andremenrath
Tags: events, fediverse, activitypub, calendar Tags: events, fediverse, activitypub, activitystreams, calendar
Requires at least: 6.5 Requires at least: 6.5
Tested up to: 6.6 Tested up to: 6.6
Stable tag: 0.1.0 Stable tag: 0.1.0
@ -11,30 +11,30 @@ Integrating popular event plugins with the ActivityPub plugin.
== Description == == 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). Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and part of the growing decentralized web.
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 ActivityPub Event Extensions Plugin for WordPress, your events can be automatically 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. 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/). 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/).
With the ActivityPub plugin people can follow your website directly and engage with your events just as they would on social media: liking, boosting and even commenting if you enable it. With the ActivityPub plugin people can follow your website directly and engage with your events just as they would on social media - liking, boosting and even commenting if you enable it.
You retain full ownership of your content. By integrating into your existing setup, it ensures no extra work is needed while enhancing your events' visibility across the web. You retain full ownership of your content. By integrating into your existing setup, it ensures no extra work is needed while enhancing your events' visibility across the Fediverse.
= How It Works = = How It Works =
With the ActivityPub Event Bridge WordPress plugin, sharing your events is effortless and automatic! With the Event Federation Plugin for WordPress, 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. Once you create an event on your WordPress site, it is seamlessly shared across the decentralized web using the ActivityPub protocol.
![](./.wordpress-org/event-activitypub-publishing.gif) ![](./.wordpress-org/event-activitypub-publishing.gif)
Your events can be automatically delivered to platforms that fully support events, such as [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Your events can be automatically delivered to platforms that fully support events, such as [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/).
These platforms create public event calendars by pulling in events from various sources, including your website. Any updates you make to your events are synced across these platforms—so you only need to manage your events on your own site, with no extra work required. These platforms build public event calendars utilizing multiple event sources, including your site. Updates are also handled automatically whenever you make changes — no extra work for you than managing the event on your own website.
![](./.wordpress-org/decentralized-event-calenders.gif) ![](./.wordpress-org/decentralized-event-calenders.gif)
== Installation == == Installation ==
This plugin depends on the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). Additionally, you need to use one of the supported event Plugins. This plugin depends on the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/). Additionally, you need to use one of the supported Event Plugins.
= Supported Event Plugins = = Supported Event Plugins =
@ -50,11 +50,10 @@ If youre new to the [ActivityPub plugin](https://wordpress.org/plugins/activi
= Do I need to install another event plugin to use the Event Federation Plugin? = = Do I need to install another event plugin to use the Event Federation Plugin? =
Yes, this plugin works as an add-on and requires both the ActivityPub plugin and a supported event plugin such as The Events Calendar, VS Event List, or Events Manager to manage your events. Yes, this plugin works as an add-on and requires both the ActivityPub plugin a supported event plugin such as The Events Calendar, VS Event List, or Events Manager to manage your events.
= What platforms can follow my events? = = What platforms can follow my events? =
Your events can be followed on platforms that support ActivityPub like [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Even other applications like [Mastodon](https://joinmastodon.org), which dont fully support events yet, will display a all important information about the events.
Your events can be followed on platforms that support ActivityPub like [Mobilizon](https://joinmobilizon.org/), [Gancio](https://gancio.org), [Friendica](https://friendi.ca), [Hubzilla](https://hubzilla.org), and [Pleroma](https://pleroma.social/). Even other applications like [Mastodon](https://joinmastodon.org), which dont fully support events yet, will display all important information about the events.
= How much extra work is required to maintain my events across the decentralized Web? = = How much extra work is required to maintain my events across the decentralized Web? =
@ -70,11 +69,11 @@ No, the Event Federation Plugin depends on the [ActivityPub plugin](https://word
= My event plugin is not supported, what can I do? = = 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-activitypub-event-extensions/issues), if we can spare some free hours we might add it.
= What if I experience problems? = = 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-activitypub-event-extensions/issues).
== Changelog == == Changelog ==

View file

@ -1,10 +1,10 @@
<?php <?php
/** /**
* Template for ActivityPub Event Bridge settings page. * Template for ActivityPub Event Extensions settings page.
* *
* This template is used to display and manage settings for the ActivityPub Event Bridge plugin. * This template is used to display and manage settings for the ActivityPub Event Extensions plugin.
* *
* @package ActivityPub_Event_Bridge * @package ActivityPub_Event_Extensions
* @since 1.0.0 * @since 1.0.0
* *
* @param array $args An array of arguments for the settings page. * @param array $args An array of arguments for the settings page.
@ -25,33 +25,65 @@ if ( ! current_user_can( 'manage_options' ) ) {
$event_terms = $args['event_terms']; $event_terms = $args['event_terms'];
require_once ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_DIR . '/includes/event-categories.php'; $default_event_category_strings = array(
'ARTS' => __( 'Arts', 'activitypub-event-extensions' ),
'BOOK_CLUBS' => __( 'Book clubs', 'activitypub-event-extensions' ),
'BUSINESS' => __( 'Business', 'activitypub-event-extensions' ),
'CAUSES' => __( 'Causes', 'activitypub-event-extensions' ),
'COMEDY' => __( 'Comedy', 'activitypub-event-extensions' ),
'CRAFTS' => __( 'Crafts', 'activitypub-event-extensions' ),
'FOOD_DRINK' => __( 'Food & Drink', 'activitypub-event-extensions' ),
'HEALTH' => __( 'Health', 'activitypub-event-extensions' ),
'MUSIC' => __( 'Music', 'activitypub-event-extensions' ),
'AUTO_BOAT_AIR' => __( 'Auto, boat and air', 'activitypub-event-extensions' ),
'COMMUNITY' => __( 'Community', 'activitypub-event-extensions' ),
'FAMILY_EDUCATION' => __( 'Family & Education', 'activitypub-event-extensions' ),
'FASHION_BEAUTY' => __( 'Fashion & Beauty', 'activitypub-event-extensions' ),
'FILM_MEDIA' => __( 'Film & Media', 'activitypub-event-extensions' ),
'GAMES' => __( 'Games', 'activitypub-event-extensions' ),
'LANGUAGE_CULTURE' => __( 'Language & Culture', 'activitypub-event-extensions' ),
'LEARNING' => __( 'Learning', 'activitypub-event-extensions' ),
'LGBTQ' => __( 'LGBTQ', 'activitypub-event-extensions' ),
'MOVEMENTS_POLITICS' => __( 'Movements and politics', 'activitypub-event-extensions' ),
'NETWORKING' => __( 'Networking', 'activitypub-event-extensions' ),
'PARTY' => __( 'Party', 'activitypub-event-extensions' ),
'PERFORMING_VISUAL_ARTS' => __( 'Performing & Visual Arts', 'activitypub-event-extensions' ),
'PETS' => __( 'Pets', 'activitypub-event-extensions' ),
'PHOTOGRAPHY' => __( 'Photography', 'activitypub-event-extensions' ),
'OUTDOORS_ADVENTURE' => __( 'Outdoors & Adventure', 'activitypub-event-extensions' ),
'SPIRITUALITY_RELIGION_BELIEFS' => __( 'Spirituality, Religion & Beliefs', 'activitypub-event-extensions' ),
'SCIENCE_TECH' => __( 'Science & Tech', 'activitypub-event-extensions' ),
'SPORTS' => __( 'Sports', 'activitypub-event-extensions' ),
'THEATRE' => __( 'Theatre', 'activitypub-event-extensions' ),
'MEETING' => __( 'Meeting', 'activitypub-event-extensions' ), // Default value in federation.
'DEFAULT' => __( 'Default', 'activitypub-event-extensions' ), // Internal default for overrides.
);
$selected_default_event_category = \get_option( 'activitypub_event_bridge_default_event_category', 'MEETING' ); $selected_default_event_category = \get_option( 'activitypub_event_extensions_default_event_category', 'MEETING' );
$current_category_mapping = \get_option( 'activitypub_event_bridge_event_category_mappings', array() ); $current_category_mapping = \get_option( 'activitypub_event_extensions_event_category_mappings', array() );
?> ?>
<div class="activitypub-settings-header"> <div class="activitypub-settings-header">
<div class="activitypub-settings-title-section"> <div class="activitypub-settings-title-section">
<h1><?php \esc_html_e( 'ActivityPub Event Bridge', 'activitypub-event-bridge' ); ?></h1> <h1><?php \esc_html_e( 'ActivityPub Event Extensions', 'activitypub-event-extensions' ); ?></h1>
</div> </div>
</div> </div>
<hr class="wp-header-end"> <hr class="wp-header-end">
<div class="activitypub-settings activitypub-settings-page activitypub-event-bridge-settings-page hide-if-no-js"> <div class="activitypub-settings activitypub-settings-page activitypub-event-extensions-settings-page hide-if-no-js">
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php \settings_fields( 'activitypub-event-bridge' ); ?> <?php \settings_fields( 'activitypub-event-extensions' ); ?>
<div class="box"> <div class="box">
<h2> <?php esc_html_e( 'Default ActivityPub Event Category', 'activitypub-event-bridge' ); ?> </h2> <h2> <?php esc_html_e( 'Default ActivityPub Event Category', 'activitypub-event-extensions' ); ?> </h2>
<p> <?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.', 'activitypub-event-bridge' ); ?> </p> <p> <?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.', 'activitypub-event-extensions' ); ?> </p>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row"> <?php esc_html_e( 'Default Category', 'activitypub-event-bridge' ); ?> </th> <th scope="row"> <?php esc_html_e( 'Default Category', 'activitypub-event-extensions' ); ?> </th>
<td> <td>
<select id="activitypub_event_bridge_default_event_category" name="activitypub_event_bridge_default_event_category">'; <select id="activitypub_event_extensions_default_event_category" name="activitypub_event_extensions_default_event_category">';
<?php <?php
foreach ( ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES as $value => $label ) { foreach ( $default_event_category_strings as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $selected_default_event_category, $value, false ) . '>' . esc_html( $label ) . '</option>'; echo '<option value="' . esc_attr( $value ) . '" ' . selected( $selected_default_event_category, $value, false ) . '>' . esc_html( $label ) . '</option>';
} }
?> ?>
@ -63,14 +95,14 @@ $current_category_mapping = \get_option( 'activitypub_event_bridge_event_
<?php if ( ! empty( $event_terms ) ) : ?> <?php if ( ! empty( $event_terms ) ) : ?>
<div class="box"> <div class="box">
<h2> <?php esc_html_e( 'Advanced Event Category Settings', 'activitypub-event-bridge' ); ?> </h2> <h2> <?php esc_html_e( 'Advanced Event Category Settings', 'activitypub-event-extensions' ); ?> </h2>
<p> <?php esc_html_e( 'Take more control by adjusting how your event categories are mapped to the basic category set used in ActivityPub. This option lets you override the default selection above, ensuring more accurate categorization and better visibility for your events.', 'activitypub-event-bridge' ); ?> </p> <p> <?php esc_html_e( 'Take more control by adjusting how your event categories are mapped to the basic category set used in ActivityPub. This option lets you override the default selection above, ensuring more accurate categorization and better visibility for your events.', 'activitypub-event-extensions' ); ?> </p>
<table class="form-table"> <table class="form-table">
<?php foreach ( $event_terms as $event_term ) { ?> <?php foreach ( $event_terms as $event_term ) { ?>
<tr> <tr>
<th scope="row"> <?php echo esc_html( $event_term->name ); ?> </th> <th scope="row"> <?php echo esc_html( $event_term->name ); ?> </th>
<td> <td>
<select name="activitypub_event_bridge_event_category_mappings[<?php echo esc_attr( $event_term->slug ); ?>]"> <select name="activitypub_event_extensions_event_category_mappings[<?php echo esc_attr( $event_term->slug ); ?>]">
<?php <?php
$current_mapping_is_set = false; $current_mapping_is_set = false;
if ( ! empty( $current_category_mapping ) ) { if ( ! empty( $current_category_mapping ) ) {
@ -82,13 +114,13 @@ $current_category_mapping = \get_option( 'activitypub_event_bridge_event_
$mapping = 'DEFAULT'; $mapping = 'DEFAULT';
} }
if ( 'DEFAULT' === $mapping ) { if ( 'DEFAULT' === $mapping ) {
echo '<option value="' . esc_attr( $mapping ) . '"> -- ' . esc_html( ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES[ $mapping ] ) . ' -- </option>'; echo '<option value="' . esc_attr( $mapping ) . '"> -- ' . esc_html( $default_event_category_strings[ $mapping ] ) . ' -- </option>';
} else { } else {
echo '<option value="' . esc_attr( $mapping ) . '">' . esc_html( ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES[ $mapping ] ) . '</option>'; echo '<option value="' . esc_attr( $mapping ) . '">' . esc_html( $default_event_category_strings[ $mapping ] ) . '</option>';
} }
echo '<option value="DEFAULT" ' . selected( $selected_default_event_category, 'DEFAULT', false ) . '> -- ' . esc_html__( 'Default', 'activitypub-event-bridge' ) . ' -- </option>'; echo '<option value="DEFAULT" ' . selected( $selected_default_event_category, 'DEFAULT', false ) . '> -- ' . esc_html__( 'Default', 'activitypub-event-extensions' ) . ' -- </option>';
foreach ( Event::DEFAULT_EVENT_CATEGORIES as $event_category ) { 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( ACTIVITYPUB_EVENT_BRIDGE_EVENT_CATEGORIES[ $event_category ] ) . '</option>'; echo '<option value="' . esc_attr( $event_category ) . '" ' . selected( $mappings[ $event_term->slug ] ?? '', $event_category, false ) . '>' . esc_html( $default_event_category_strings[ $event_category ] ) . '</option>';
} }
?> ?>
</select> </select>

View file

@ -2,7 +2,7 @@
/** /**
* PHPUnit bootstrap file. * PHPUnit bootstrap file.
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
*/ */
$_tests_dir = getenv( 'WP_TESTS_DIR' ); $_tests_dir = getenv( 'WP_TESTS_DIR' );
@ -78,7 +78,7 @@ function _manually_load_plugin() {
} }
// At last manually load our WordPress plugin. // At last manually load our WordPress plugin.
require dirname( __DIR__ ) . '/activitypub-event-bridge.php'; require dirname( __DIR__ ) . '/activitypub-event-extensions.php';
} }
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

View file

@ -2,7 +2,7 @@
/** /**
* Class SampleTest * Class SampleTest
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
*/ */
/** /**
@ -23,7 +23,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
update_option( 'dbem_events_anonymous_submissions', true ); update_option( 'dbem_events_anonymous_submissions', true );
// Make sure that ActivityPub support is enabled for Events Manager. // Make sure that ActivityPub support is enabled for Events Manager.
$aec = \ActivityPub_Event_Bridge\Setup::get_instance(); $aec = \Activitypub_Event_Extensions\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins(); $aec->activate_activitypub_support_for_active_event_plugins();
// Delete all posts afterwards. // Delete all posts afterwards.
@ -37,7 +37,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// We only test for one event plugin being active at the same time, // We only test for one event plugin being active at the same time,
// even though we support multiple onces in theory. // even though we support multiple onces in theory.
// But testing all combinations is beyond scope. // But testing all combinations is beyond scope.
$active_event_plugins = \ActivityPub_Event_Bridge\Setup::get_instance()->get_active_event_plugins(); $active_event_plugins = \Activitypub_Event_Extensions\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) ); $this->assertEquals( 1, count( $active_event_plugins ) );
// Enable ActivityPub support for the event plugin. // Enable ActivityPub support for the event plugin.
@ -47,7 +47,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$wp_post_id = wp_insert_post( $wp_post_id = wp_insert_post(
array( array(
'post_title' => 'Events Manager Test event', 'post_title' => 'Events Manager Test event',
'post_status' => 'publish', 'post_status' => 'published',
'post_type' => EM_POST_TYPE_EVENT, 'post_type' => EM_POST_TYPE_EVENT,
'meta_input' => array( 'meta_input' => array(
'event_start_time' => strtotime( '+10 days 15:00:00' ), 'event_start_time' => strtotime( '+10 days 15:00:00' ),
@ -61,7 +61,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\Events_Manager::class, $transformer ); $this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\Events_Manager::class, $transformer );
} }
/** /**
@ -75,7 +75,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_start_date = gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ); $event->event_start_date = gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) );
$event->event_start_time = '15:00:00'; $event->event_start_time = '15:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time ); $event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
$event->force_status = 'publish'; $event->force_status = 'published';
$event->event_rsvp = false; $event->event_rsvp = false;
$this->assertTrue( $event->save() ); $this->assertTrue( $event->save() );
@ -85,7 +85,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] ); $this->assertEquals( 'Events Manager Test event', $event_array['name'] );
$this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( comments_open( $event->post_id ), $event_array['commentsEnabled'] ); $this->assertEquals( comments_open( $event->post_id ), $event_array['commentsEnabled'] );
$this->assertEquals( comments_open( $event->post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] ); $this->assertEquals( comments_open( $event->post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
@ -121,7 +121,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_end_time = '16:00:00'; $event->event_end_time = '16:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time ); $event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
$event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time ); $event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time );
$event->force_status = 'publish'; $event->force_status = 'published';
$event->event_rsvp = false; $event->event_rsvp = false;
$this->assertTrue( $event->save() ); $this->assertTrue( $event->save() );
@ -131,7 +131,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] ); $this->assertEquals( 'Events Manager Test event', $event_array['name'] );
$this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] ); $this->assertEquals( 'external', $event_array['joinMode'] );
$this->assertEquals( 'MEETING', $event_array['category'] ); $this->assertEquals( 'MEETING', $event_array['category'] );
@ -164,7 +164,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_end_time = '16:00:00'; $event->event_end_time = '16:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time ); $event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
$event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time ); $event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time );
$event->force_status = 'publish'; $event->force_status = 'published';
$event->event_rsvp = false; $event->event_rsvp = false;
$this->assertTrue( $event->save() ); $this->assertTrue( $event->save() );
@ -174,7 +174,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] ); $this->assertEquals( 'Events Manager Test event', $event_array['name'] );
$this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] ); $this->assertEquals( 'external', $event_array['joinMode'] );
$this->assertEquals( 'MEETING', $event_array['category'] ); $this->assertEquals( 'MEETING', $event_array['category'] );

View file

@ -2,7 +2,7 @@
/** /**
* Class SampleTest * Class SampleTest
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
*/ */
/** /**
@ -23,7 +23,7 @@ class Test_GatherPress extends WP_UnitTestCase {
GatherPress\Core\Setup::get_instance()->activate_gatherpress_plugin( false ); GatherPress\Core\Setup::get_instance()->activate_gatherpress_plugin( false );
// Make sure that ActivityPub support is enabled for The Events Calendar. // Make sure that ActivityPub support is enabled for The Events Calendar.
$aec = \ActivityPub_Event_Bridge\Setup::get_instance(); $aec = \Activitypub_Event_Extensions\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins(); $aec->activate_activitypub_support_for_active_event_plugins();
// Delete all posts afterwards. // Delete all posts afterwards.
@ -37,7 +37,7 @@ class Test_GatherPress extends WP_UnitTestCase {
// We only test for one event plugin being active at the same time, // We only test for one event plugin being active at the same time,
// even though we support multiple onces in theory. // even though we support multiple onces in theory.
// But testing all combinations is beyond scope. // But testing all combinations is beyond scope.
$active_event_plugins = \ActivityPub_Event_Bridge\Setup::get_instance()->get_active_event_plugins(); $active_event_plugins = \Activitypub_Event_Extensions\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) ); $this->assertEquals( 1, count( $active_event_plugins ) );
// Enable ActivityPub support for the event plugin. // Enable ActivityPub support for the event plugin.
@ -49,7 +49,6 @@ class Test_GatherPress extends WP_UnitTestCase {
'post_title' => 'Unit Test Event', 'post_title' => 'Unit Test Event',
'post_type' => 'gatherpress_event', 'post_type' => 'gatherpress_event',
'post_content' => 'Unit Test description.', 'post_content' => 'Unit Test description.',
'post_status' => 'publish',
) )
); );
$event = new \GatherPress\Core\Event( $post_id ); $event = new \GatherPress\Core\Event( $post_id );
@ -65,7 +64,7 @@ class Test_GatherPress extends WP_UnitTestCase {
$transformer = \Activitypub\Transformer\Factory::get_transformer( $event->event ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $event->event );
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\GatherPress::class, $transformer ); $this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\GatherPress::class, $transformer );
} }
/** /**
@ -78,7 +77,7 @@ class Test_GatherPress extends WP_UnitTestCase {
'post_title' => 'Unit Test Event', 'post_title' => 'Unit Test Event',
'post_type' => 'gatherpress_event', 'post_type' => 'gatherpress_event',
'post_content' => 'Unit Test description.', 'post_content' => 'Unit Test description.',
'post_status' => 'publish', 'post_status' => 'published',
) )
); );
$event = new \GatherPress\Core\Event( $post_id ); $event = new \GatherPress\Core\Event( $post_id );
@ -95,7 +94,7 @@ class Test_GatherPress extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected. // Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Unit Test Event', $event_array['name'] ); $this->assertEquals( 'Unit Test Event', $event_array['name'] );
$this->assertEquals( 'Unit Test description.', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( 'Unit Test description.', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] ); $this->assertEquals( 'external', $event_array['joinMode'] );

View file

@ -2,7 +2,7 @@
/** /**
* Class SampleTest * Class SampleTest
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
*/ */
/** /**
@ -37,14 +37,14 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
public const MOCKUP_EVENTS = array( public const MOCKUP_EVENTS = array(
'minimal_event' => array( 'minimal_event' => array(
'title' => 'My Event', 'title' => 'My Event',
'content' => 'Come to my event!', 'content' => 'Come to my event. Let\'s connect!',
'start_date' => '+10 days 15:00:00', 'start_date' => '+10 days 15:00:00',
'duration' => HOUR_IN_SECONDS, 'duration' => HOUR_IN_SECONDS,
'status' => 'publish', 'status' => 'publish',
), ),
'complex_event' => array( 'complex_event' => array(
'title' => 'My Event', 'title' => 'My Event',
'content' => 'Come to my event!', 'content' => 'Come to my event. Let\'s connect!',
'start_date' => '+10 days 15:00:00', 'start_date' => '+10 days 15:00:00',
'duration' => HOUR_IN_SECONDS, 'duration' => HOUR_IN_SECONDS,
'status' => 'publish', 'status' => 'publish',
@ -62,7 +62,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
} }
// Make sure that ActivityPub support is enabled for The Events Calendar. // Make sure that ActivityPub support is enabled for The Events Calendar.
$aec = \ActivityPub_Event_Bridge\Setup::get_instance(); $aec = \Activitypub_Event_Extensions\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins(); $aec->activate_activitypub_support_for_active_event_plugins();
// Delete all posts afterwards. // Delete all posts afterwards.
@ -76,7 +76,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// We only test for one event plugin being active at the same time, // We only test for one event plugin being active at the same time,
// even though we support multiple onces in theory. // even though we support multiple onces in theory.
// But testing all combinations is beyond scope. // But testing all combinations is beyond scope.
$active_event_plugins = \ActivityPub_Event_Bridge\Setup::get_instance()->get_active_event_plugins(); $active_event_plugins = \Activitypub_Event_Extensions\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) ); $this->assertEquals( 1, count( $active_event_plugins ) );
// Enable ActivityPub support for the event plugin. // Enable ActivityPub support for the event plugin.
@ -91,7 +91,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\The_Events_Calendar::class, $transformer ); $this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\The_Events_Calendar::class, $transformer );
} }
/** /**
@ -109,7 +109,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected. // Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] ); $this->assertEquals( 'My Event', $event_array['name'] );
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertTrue( $event_array['commentsEnabled'] ); $this->assertTrue( $event_array['commentsEnabled'] );
@ -128,10 +128,10 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
$category_id_theatre = wp_insert_term( 'Theatre', Tribe__Events__Main::TAXONOMY, array( 'slug' => 'theatre' ) ); $category_id_theatre = wp_insert_term( 'Theatre', Tribe__Events__Main::TAXONOMY, array( 'slug' => 'theatre' ) );
// Set default mapping for event categories. // Set default mapping for event categories.
update_option( 'activitypub_event_bridge_default_event_category', 'MUSIC' ); update_option( 'activitypub_event_extensions_default_event_category', 'MUSIC' );
// Set an override for the category with the slug theatre. // Set an override for the category with the slug theatre.
update_option( 'activitypub_event_bridge_event_category_mappings', array( 'theatre' => 'THEATRE' ) ); update_option( 'activitypub_event_extensions_event_category_mappings', array( 'theatre' => 'THEATRE' ) );
// Create a The Events Calendar event with the music category. // Create a The Events Calendar event with the music category.
$wp_object = tribe_events() $wp_object = tribe_events()
@ -170,7 +170,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected. // Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] ); $this->assertEquals( 'My Event', $event_array['name'] );
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] );
@ -197,7 +197,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected. // Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] ); $this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] ); $this->assertEquals( 'My Event', $event_array['name'] );
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) ); $this->assertEquals( '', $event_array['content'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] ); $this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] );

View file

@ -2,7 +2,7 @@
/** /**
* Class SampleTest * Class SampleTest
* *
* @package ActivityPub_Event_Bridge * @package Activitypub_Event_Extensions
*/ */
/** /**
@ -20,7 +20,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
} }
// Make sure that ActivityPub support is enabled for The Events Calendar. // Make sure that ActivityPub support is enabled for The Events Calendar.
$aec = \ActivityPub_Event_Bridge\Setup::get_instance(); $aec = \Activitypub_Event_Extensions\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins(); $aec->activate_activitypub_support_for_active_event_plugins();
// Delete all posts afterwards. // Delete all posts afterwards.
@ -34,7 +34,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
// We only test for one event plugin being active at the same time, // We only test for one event plugin being active at the same time,
// even though we support multiple onces in theory. // even though we support multiple onces in theory.
// But testing all combinations is beyond scope. // But testing all combinations is beyond scope.
$active_event_plugins = \ActivityPub_Event_Bridge\Setup::get_instance()->get_active_event_plugins(); $active_event_plugins = \Activitypub_Event_Extensions\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) ); $this->assertEquals( 1, count( $active_event_plugins ) );
// Enable ActivityPub support for the event plugin. // Enable ActivityPub support for the event plugin.
@ -58,7 +58,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
// Check that we got the right transformer. // Check that we got the right transformer.
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\VS_Event_List::class, $transformer ); $this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\VS_Event_List::class, $transformer );
} }
/** /**
@ -173,10 +173,10 @@ class Test_VS_Event_List extends WP_UnitTestCase {
$category_id_theatre = wp_insert_term( 'Theatre', 'event_cat', array( 'slug' => 'theatre' ) ); $category_id_theatre = wp_insert_term( 'Theatre', 'event_cat', array( 'slug' => 'theatre' ) );
// Set default mapping for event categories. // Set default mapping for event categories.
update_option( 'activitypub_event_bridge_default_event_category', 'MUSIC' ); update_option( 'activitypub_event_extensions_default_event_category', 'MUSIC' );
// Set an override for the category with the slug theatre. // Set an override for the category with the slug theatre.
update_option( 'activitypub_event_bridge_event_category_mappings', array( 'theatre' => 'THEATRE' ) ); update_option( 'activitypub_event_extensions_event_category_mappings', array( 'theatre' => 'THEATRE' ) );
// Create a VS Event List event with the music category. // Create a VS Event List event with the music category.
$wp_post_id = wp_insert_post( $wp_post_id = wp_insert_post(