Compare commits
58 commits
plugin_doc
...
main
Author | SHA1 | Date | |
---|---|---|---|
16b3c1402e | |||
6dd511e4b0 | |||
44daeb5b59 | |||
4bc5e37c2c | |||
871af8215c | |||
c676439880 | |||
1bf04a4a40 | |||
fa1796eec1 | |||
cacfb2a730 | |||
09ba5cac00 | |||
d625750a7e | |||
dddd3e395f | |||
7eb011859a | |||
9e51823595 | |||
53cdbd3838 | |||
7f23ed17c0 | |||
ba922e6030 | |||
37bd66ee9b | |||
03026aea03 | |||
2f08102243 | |||
a95c4bc308 | |||
ba457357dc | |||
c8ea6e4eac | |||
2da7bd443c | |||
45f36d5c2a | |||
036cea2708 | |||
2e9d4c4523 | |||
7bc134e135 | |||
580b6b9989 | |||
7e8346cf7b | |||
29536e7a4d | |||
cc04a1e7dd | |||
8fb92bfc10 | |||
596e32fe26 | |||
d229529acc | |||
0fba291706 | |||
8168df2965 | |||
8e56eb66c0 | |||
4cc992d79b | |||
17648dc664 | |||
a8627cdb02 | |||
4aad867d1f | |||
2124b1f612 | |||
ced5ee90b1 | |||
972fcbb2db | |||
2257e86f0f | |||
11bf3a2048 | |||
6f744b9e14 | |||
c599384006 | |||
f92c5853ad | |||
19457a9f19 | |||
7ab51b104e | |||
3dbd3e21ee | |||
20f0ea2823 | |||
c13230ac6f | |||
4d4328f3fd | |||
35bd198f47 | |||
ac99300949 |
24
.distignore
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
.distignore
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.wordpress-org
|
||||||
|
.wp-env.json
|
||||||
|
bin
|
||||||
|
CHANGELOG.md
|
||||||
|
CODE_OF_CONDUCT.md
|
||||||
|
composer.json
|
||||||
|
composer.lock
|
||||||
|
docker-compose.yml
|
||||||
|
Dockerfile
|
||||||
|
docs
|
||||||
|
FEDERATION.md
|
||||||
|
Gruntfile.js
|
||||||
|
node_modules
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
|
phpcs.xml
|
||||||
|
phpunit.xml
|
||||||
|
README.md
|
||||||
|
src
|
||||||
|
tests
|
||||||
|
vendor
|
|
@ -21,7 +21,8 @@ jobs:
|
||||||
MYSQL_ROOT_PASSWORD: root
|
MYSQL_ROOT_PASSWORD: root
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-version: ['8.1', '8.2', '8.3']
|
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
|
||||||
|
wordpress-version: ['6.7']
|
||||||
name: PHPUnit – PHP ${{ matrix.php-version }}
|
name: PHPUnit – PHP ${{ matrix.php-version }}
|
||||||
env:
|
env:
|
||||||
extensions: mysql
|
extensions: mysql
|
||||||
|
@ -37,7 +38,7 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
${{ env.WP_CORE_DIR }}
|
${{ env.WP_CORE_DIR }}
|
||||||
${{ env.WP_TESTS_DIR }}
|
${{ env.WP_TESTS_DIR }}
|
||||||
key: cache-wordpress-4
|
key: cache-wordpress-67-4
|
||||||
|
|
||||||
- name: Cache Composer
|
- name: Cache Composer
|
||||||
id: cache-composer-phpunit
|
id: cache-composer-phpunit
|
||||||
|
@ -45,7 +46,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
./vendor/
|
./vendor/
|
||||||
key: cache-composer-phpunit-1
|
key: cache-composer-phpunit-2
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: https://github.com/shivammathur/setup-php@v2
|
uses: https://github.com/shivammathur/setup-php@v2
|
||||||
|
@ -68,28 +69,58 @@ jobs:
|
||||||
|
|
||||||
- name: Setup Test Environment
|
- name: Setup Test Environment
|
||||||
if: steps.cache-wordpress.outputs.cache-hit != 'true'
|
if: steps.cache-wordpress.outputs.cache-hit != 'true'
|
||||||
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 false false false false
|
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wordpress-version }} false false false false
|
||||||
|
|
||||||
- name: Initialize WordPress test database
|
- name: Initialize WordPress test database
|
||||||
if: steps.cache-wordpress.outputs.cache-hit != 'false'
|
if: steps.cache-wordpress.outputs.cache-hit != 'false'
|
||||||
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 ${{ matrix.wordpress-version }} false true true true
|
||||||
|
|
||||||
|
- name: Run General Tests
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=event_bridge_for_activitypub
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
- name: Run Integration tests for The Events Calendar
|
- name: Run Integration tests for The Events Calendar
|
||||||
run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && ./vendor/bin/phpunit --filter=the_events_calendar
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=the_events_calendar
|
||||||
env:
|
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-extensions/ && ./vendor/bin/phpunit --filter=vs_event_list
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=vs_event_list
|
||||||
env:
|
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-extensions/ && ./vendor/bin/phpunit --filter=gatherpress
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./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-extensions/ && ./vendor/bin/phpunit --filter=events_manager
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=events_manager
|
||||||
env:
|
env:
|
||||||
PHP_VERSION: ${{ matrix.php-version }}
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for WP Event Manager
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=wp_event_manager
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for Eventin (WP Event Solution)
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=eventin
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for Modern Events Calendar Lite
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=modern_events_calendar_lite
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for EventPrime
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=eventprime
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for Event Organiser
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-event-bridge-for-activitypub/ && ./vendor/bin/phpunit --filter=event_organiser
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
16
.forgejo/workflows/release.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
upload-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: https://code.forgejo.org/actions/forgejo-release@v2
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
url: https://code.event-federation.eu
|
||||||
|
release-notes: ${{ TAG }}
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
23
.gitattributes
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
.distignore export-ignore
|
||||||
|
.forgejo export-ignore
|
||||||
|
.gitattributes export-ignore
|
||||||
|
.gitignore export-ignore
|
||||||
|
.wp-env.json export-ignore
|
||||||
|
bin export-ignore
|
||||||
|
CODE_OF_CONDUCT.md export-ignore
|
||||||
|
composer.json export-ignore
|
||||||
|
composer.lock export-ignore
|
||||||
|
docker-compose.yml export-ignore
|
||||||
|
Dockerfile export-ignore
|
||||||
|
docs export-ignore
|
||||||
|
FEDERATION.md export-ignore
|
||||||
|
Gruntfile.js export-ignore
|
||||||
|
node_modules export-ignore
|
||||||
|
package.json export-ignore
|
||||||
|
package-lock.json export-ignore
|
||||||
|
phpcs.xml export-ignore
|
||||||
|
phpunit.xml export-ignore
|
||||||
|
README.md export-ignore
|
||||||
|
src export-ignore
|
||||||
|
tests export-ignore
|
||||||
|
vendor export-ignore
|
4
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
vendor
|
vendor/
|
||||||
composer.lock
|
composer.lock
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
|
BIN
.wordpress-org/banner-1544x500.jpg
Normal file
After Width: | Height: | Size: 324 KiB |
BIN
.wordpress-org/banner-772x250.jpg
Normal file
After Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 392 KiB |
BIN
.wordpress-org/icon-128x128.gif
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
.wordpress-org/icon-256x256.gif
Normal file
After Width: | Height: | Size: 125 KiB |
17
CHANGELOG.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Add custom summary via shortcodes
|
||||||
|
|
||||||
|
## [0.3.2] - 2024-12-12
|
||||||
|
|
||||||
|
* Initial release on WordPress.org
|
||||||
|
|
126
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
|
any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address,
|
||||||
|
without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official email address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement via email to
|
||||||
|
simon@fdpl.io. All complaints will be reviewed and investigated fairly
|
||||||
|
and as soon as personal time and energy of community leaders permits.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
|
||||||
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
|
59
Gruntfile.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig(
|
||||||
|
{
|
||||||
|
checktextdomain: {
|
||||||
|
options:{
|
||||||
|
text_domain: 'event-bridge-for-activitypub',
|
||||||
|
keywords: [
|
||||||
|
'__:1,2d',
|
||||||
|
'_e:1,2d',
|
||||||
|
'_x:1,2c,3d',
|
||||||
|
'esc_html__:1,2d',
|
||||||
|
'esc_html_e:1,2d',
|
||||||
|
'esc_html_x:1,2c,3d',
|
||||||
|
'esc_attr__:1,2d',
|
||||||
|
'esc_attr_e:1,2d',
|
||||||
|
'esc_attr_x:1,2c,3d',
|
||||||
|
'_ex:1,2c,3d',
|
||||||
|
'_n:1,2,4d',
|
||||||
|
'_nx:1,2,4c,5d',
|
||||||
|
'_n_noop:1,2,3d',
|
||||||
|
'_nx_noop:1,2,3c,4d'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
src: [
|
||||||
|
'**/*.php', // Include all files
|
||||||
|
'!sass/**', // Exclude sass/
|
||||||
|
'!node_modules/**', // Exclude node_modules/
|
||||||
|
'!tests/**', // Exclude tests/
|
||||||
|
'!vendor/**', // Exclude vendor/
|
||||||
|
'!build/**', // Exclude build/
|
||||||
|
'!static/**', // Exclude static resources
|
||||||
|
],
|
||||||
|
expand: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
wp_readme_to_markdown: {
|
||||||
|
target: {
|
||||||
|
files: {
|
||||||
|
'README.md': 'readme.txt'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
pre_convert: function ( readme ) {
|
||||||
|
return readme.replace( /\*\*Note\*\*:/g, "> [!NOTE]\n>" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
|
||||||
|
grunt.loadNpmTasks( 'grunt-checktextdomain' );
|
||||||
|
|
||||||
|
// Default task(s).
|
||||||
|
grunt.registerTask( 'default', ['wp_readme_to_markdown', 'checktextdomain'] );
|
||||||
|
};
|
107
README.md
|
@ -1,92 +1,109 @@
|
||||||
# ActivityPub Event Extensions
|
# Event Bridge for ActivityPub #
|
||||||
|
**Contributors:** [andremenrath](https://profiles.wordpress.org/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.7
|
||||||
Tested up to: 6.6
|
**Stable tag:** 0.3.2
|
||||||
Stable tag: 0.1.0
|
**Requires PHP:** 7.4
|
||||||
Requires PHP: 8.1
|
**License:** AGPL-3.0-or-later
|
||||||
License: AGPL-3.0-or-later
|
**License URI:** https://www.gnu.org/licenses/agpl-3.0.html
|
||||||
License URI: https://www.gnu.org/licenses/agpl-3.0.html
|
|
||||||
|
|
||||||
Integrating popular event plugins with the ActivityPub plugin.
|
Integrating popular event plugins with the ActivityPub plugin.
|
||||||
|
|
||||||
![](.wordpress-org/banner-1544x500.jpg)
|
![Federate your Events, Expand your Reach!](.wordpress-org/banner-1544x500.jpg)
|
||||||
|
|
||||||
## Description
|
## Description ##
|
||||||
|
|
||||||
Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and part of the growing decentralized web.
|
Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and be a part of the growing decentralized web (the Fediverse).
|
||||||
With the ActivityPub Event 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.
|
With the Event Bridge for ActivityPub Plugin for WordPress, your events can be automatically followed, aggregated and displayed across decentralized platforms like [Mastodon](https://joinmastodon.org) or [Gancio](https://gancio.org), without any extra work.
|
||||||
Forget the hassle of managing multiple social media accounts just to keep your audience informed.
|
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 Fediverse.
|
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.
|
||||||
|
|
||||||
### How It Works
|
### How It Works ###
|
||||||
|
|
||||||
With the Event Federation Plugin for WordPress, sharing your events is effortless and automatic!
|
With the Event Bridge for ActivityPub WordPress plugin, sharing your events is effortless and automatic!
|
||||||
Once you create an event on your WordPress site, it is seamlessly shared across the decentralized web using the ActivityPub protocol.
|
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">
|
||||||
<img src="./.wordpress-org/event-activitypub-publishing.gif" alt="Logo" width="250" />
|
<img src="./.wordpress-org/event-activitypub-publishing.gif" alt="Logo" width="300"/>
|
||||||
</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 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.
|
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.
|
||||||
|
|
||||||
<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 don’t yet fully support events, like [Mastodon](https://joinmastodon.org), will still receive a detailed, well-composed summary of your event.
|
Even platforms that don't 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
|
### Features for Your WordPress Events and the Fediverse ###
|
||||||
|
|
||||||
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.
|
**ActivityPub-Enabled Event Sharing:** Your WordPress events are now compatible with the Fediverse, using the ActivityStreams format. This means your events can be easily discovered and followed by users on platforms like Mastodon and other ActivityPub-compatible services.
|
||||||
|
|
||||||
### Supported Event Plugins
|
**Automatic Event Summaries:** When your event is shared on the Fediverse, platforms like Mastodon that don't fully support events will display a brief HTML summary of key details — such as the event's title, start time, and location. This ensures that even if someone can't view the full event on their platform, they still get the important info at a glance, with a link to your WordPress event page. Advanced users can create custom summaries via a set of shortcodes.
|
||||||
|
|
||||||
|
**Improved Event Discoverability:** Your custom event categories are mapped to a set of default categories used in the Fediverse, helping your events reach a wider audience. This improves the chances that users searching for similar events on other platforms will find yours.
|
||||||
|
|
||||||
|
**Event Reminders for Your Followers:** Often, events are planned well in advance. To keep your followers informed right in time, you can set up reminders that are supposed to trigger the events showing up in their timelines right before the event starts. At the moment this reminder is implemented as a self-boost of your original event post. While this feature may behave differently across various platforms, we are working on a more robust solution that will let you schedule dedicated reminder notes that appear in all followers' timelines.
|
||||||
|
|
||||||
|
## Installation ##
|
||||||
|
|
||||||
|
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 ###
|
||||||
|
|
||||||
* [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/)
|
||||||
* [Events Manager](https://de.wordpress.org/plugins/events-manager/)
|
* [Events Manager](https://de.wordpress.org/plugins/events-manager/)
|
||||||
|
* [WP Event Manager](https://de.wordpress.org/plugins/wp-event-manager/)
|
||||||
|
* [Eventin](https://de.wordpress.org/plugins/wp-event-solution/)
|
||||||
|
* [Modern Events Calendar Lite](https://webnus.net/modern-events-calendar/)
|
||||||
|
* [GatherPress](https://gatherpress.org/)
|
||||||
|
* [EventPrime – Events Calendar, Bookings and Tickets](https://wordpress.org/plugins/eventprime-event-calendar-management/)
|
||||||
|
* [Event Organiser](https://wordpress.org/plugins/event-organiser/)
|
||||||
|
|
||||||
## Configuration
|
## Configuration ##
|
||||||
|
|
||||||
If you’re new to the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/), it’s recommended to spend a few minutes reading through its documentation to familiarize yourself with its setup and functionality.
|
If you're new to the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/), it’s recommended to spend a few minutes reading through its documentation to familiarize yourself with its setup and functionality.
|
||||||
|
|
||||||
## 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 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/).
|
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/).
|
||||||
|
|
||||||
### 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 don’t 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?
|
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 don't 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? ###
|
||||||
|
|
||||||
None! Once the plugin is set up, your events are automatically sent to all connected platforms or account that follow you (your Website). Any updates you make to your events are synced without additional effort.
|
None! Once the plugin is set up, your events are automatically sent to all connected platforms or account that follow you (your Website). Any updates you make to your events are synced without additional effort.
|
||||||
|
|
||||||
### Can I still use social media to promote my events?
|
### Can I still use social media to promote my events? ###
|
||||||
|
|
||||||
Yes, you can still use traditional social media if you wish. However, this plugin helps reduce reliance on commercial platforms by connecting your events to the decentralized Fediverse.
|
Yes, you can still use traditional social media if you wish. However, this plugin helps reduce reliance on commercial platforms by connecting your events to the decentralized Fediverse.
|
||||||
|
|
||||||
### 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](https://wordpress.org/plugins/activitypub/) 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-extensions/issues), if we can spare some free hours we might add it.
|
If you know about coding have a look at the documentation of how to add your plugin or open an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues), if we can spare some free hours we might add it.
|
||||||
|
|
||||||
### What if I experience problems?
|
### 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-extensions/issues).
|
We're always interested in your feedback. Feel free to reach out to us via [E-Mail](https://event-federation.eu/contact/) or create an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues).
|
||||||
|
|
||||||
## Changelog
|
## Changelog ##
|
||||||
|
|
||||||
|
### [0.3.2] 2024-12-12 ###
|
||||||
|
|
||||||
|
* Initial release on https://wordpress.org/
|
||||||
|
|
||||||
### [0.1.0] 2024-10-01
|
|
||||||
|
|
||||||
* Initial alpha release on WordPress.org
|
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
<?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;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
.activitypub-event-extensions-settings-page .box {
|
|
||||||
border: 1px solid #c3c4c7;
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 1em 1.5em;
|
|
||||||
margin-bottom: 1.5em;
|
|
||||||
}
|
|
187
assets/css/event-bridge-for-activitypub-admin.css
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
.settings_page_event-bridge-for-activitypub #wpcontent {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-page .box {
|
||||||
|
border: 1px solid #c3c4c7;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 1em 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-page .box ul.event-bridge-for-activitypub-list {
|
||||||
|
margin-left: 0.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-page .box pre {
|
||||||
|
padding: 1rem;
|
||||||
|
min-height: 200px;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: 15px;
|
||||||
|
border: 1px solid #dfe0e2;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-header {
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 0 1rem;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #dcdcde;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-title-section {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
clear: both;
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-tabs-wrapper {
|
||||||
|
display: -ms-inline-grid;
|
||||||
|
-ms-grid-columns: auto auto auto auto;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-grid;
|
||||||
|
grid-template-columns: auto auto auto auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-tab.active {
|
||||||
|
box-shadow: inset 0 -3px #3582c4;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-tab {
|
||||||
|
display: block;
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
padding: .5rem 1rem 1rem;
|
||||||
|
margin: 0 1rem;
|
||||||
|
transition: box-shadow .5s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings .box h3 {
|
||||||
|
font-size: 1.15em;
|
||||||
|
margin-bottom: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#event_bridge_for_activitypub_initially_activated {
|
||||||
|
display: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Accordions for admin pages */
|
||||||
|
.event-bridge-for-activitypub-settings-accordion {
|
||||||
|
border: 1px solid #c3c4c7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-heading {
|
||||||
|
margin: 0;
|
||||||
|
border-top: 1px solid #c3c4c7;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
font-weight: 600;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-heading:first-child {
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-panel {
|
||||||
|
margin: 0;
|
||||||
|
padding: 1em 1.5em;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger {
|
||||||
|
background: #fff;
|
||||||
|
border: 0;
|
||||||
|
color: #2c3338;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
font-weight: 400;
|
||||||
|
margin: 0;
|
||||||
|
padding: 1em 3.5em 1em 1.5em;
|
||||||
|
min-height: 46px;
|
||||||
|
position: relative;
|
||||||
|
text-align: left;
|
||||||
|
width: 100%;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
-webkit-user-select: auto;
|
||||||
|
user-select: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger {
|
||||||
|
color: #2c3338;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 400;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger .title {
|
||||||
|
pointer-events: none;
|
||||||
|
font-weight: 600;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger .icon,
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-viewed .icon {
|
||||||
|
border: solid #50575e medium;
|
||||||
|
border-width: 0 2px 2px 0;
|
||||||
|
height: .5rem;
|
||||||
|
pointer-events: none;
|
||||||
|
position: absolute;
|
||||||
|
right: 1.5em;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-70%) rotate(45deg);
|
||||||
|
width: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger[aria-expanded="true"] .icon {
|
||||||
|
transform: translateY(-30%) rotate(-135deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger:active,
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger:hover {
|
||||||
|
background: #f6f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-accordion-trigger:focus {
|
||||||
|
color: #1d2327;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
outline-offset: -1px;
|
||||||
|
outline: 2px solid #2271b1;
|
||||||
|
background-color: #f6f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-bridge-for-activitypub-settings-inline-icon {
|
||||||
|
width: 1.5em;
|
||||||
|
height: 1.5em;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 0 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
code.event-bridge-for-activitypub-settings-example-url {
|
||||||
|
display: block;
|
||||||
|
background: rgb(28, 29, 33);
|
||||||
|
padding: 8px;
|
||||||
|
margin: 10px 0px 10px 0;
|
||||||
|
border-radius: 7px;
|
||||||
|
color: #d5d5d6;
|
||||||
|
overflow-x: auto;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
#event_bridge_for_activitypub_summary_type_custom-details {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#event_bridge_for_activitypub_summary_type_custom-details > details {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
288
assets/img/activitypub.svg
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="130"
|
||||||
|
height="130"
|
||||||
|
viewBox="0 0 34.395832 34.395832"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="0.92.1 r15371"
|
||||||
|
sodipodi:docname="ActivityPub-logo-symbol.svg">
|
||||||
|
<title
|
||||||
|
id="title4590">ActivityPub logo</title>
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<linearGradient
|
||||||
|
id="AP-4-0"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#5e5e5e;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5660" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5640"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5638" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5634"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5632" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5628"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5626" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="AP-3-7"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#c678c5;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5498" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="AP-2-3"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#6d6d6d;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5230" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="AP1-5"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#f1007e;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5212" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP-3-7"
|
||||||
|
id="linearGradient5749"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3319.292"
|
||||||
|
y1="-1291.2802"
|
||||||
|
x2="3344.3645"
|
||||||
|
y2="-1291.2802" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP1-5"
|
||||||
|
id="linearGradient7297-7"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3241.6836"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3254.9529"
|
||||||
|
y2="-1355.4329" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP-2-3"
|
||||||
|
id="linearGradient7303-7"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3225.7603"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3239.0295"
|
||||||
|
y2="-1355.4329" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP1-5"
|
||||||
|
id="linearGradient8308"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3241.6836"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3254.9529"
|
||||||
|
y2="-1355.4329" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP1-5"
|
||||||
|
id="linearGradient8310"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3241.6836"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3254.9529"
|
||||||
|
y2="-1355.4329" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP1-5"
|
||||||
|
id="linearGradient8312"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3241.6836"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3254.9529"
|
||||||
|
y2="-1355.4329" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP-2-3"
|
||||||
|
id="linearGradient8314"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="3225.7603"
|
||||||
|
y1="-1355.4329"
|
||||||
|
x2="3239.0295"
|
||||||
|
y2="-1355.4329"
|
||||||
|
gradientTransform="matrix(3.7000834,0,0,3.7000834,-11935.582,4544.6634)" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#AP-2-3"
|
||||||
|
id="linearGradient5188"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(0.42732603,0,0,0.42732603,-1363.3009,454.91899)"
|
||||||
|
x1="3269.126"
|
||||||
|
y1="-1354.6217"
|
||||||
|
x2="3322.1943"
|
||||||
|
y2="-1354.6217" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="0.14509804"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.70710678"
|
||||||
|
inkscape:cx="-195.34129"
|
||||||
|
inkscape:cy="-120.65903"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:snap-global="true"
|
||||||
|
showguides="false"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
showborder="true"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
borderlayer="false"
|
||||||
|
units="px">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid4572"
|
||||||
|
enabled="false"
|
||||||
|
originx="7.1437514"
|
||||||
|
originy="-404.28382" />
|
||||||
|
<inkscape:grid
|
||||||
|
type="axonomgrid"
|
||||||
|
id="grid4574"
|
||||||
|
units="mm"
|
||||||
|
empspacing="12"
|
||||||
|
originx="7.1437514"
|
||||||
|
originy="-404.28382"
|
||||||
|
enabled="false" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="3278.981,1256.5057"
|
||||||
|
orientation="0,1"
|
||||||
|
id="guide5059"
|
||||||
|
inkscape:locked="false" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="3278.981,1238.2495"
|
||||||
|
orientation="0,1"
|
||||||
|
id="guide5061"
|
||||||
|
inkscape:locked="false" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title>ActivityPub logo</dc:title>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
|
||||||
|
<dc:date>2017-04-15</dc:date>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Robert Martinez</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<dc:subject>
|
||||||
|
<rdf:Bag>
|
||||||
|
<rdf:li>ActivityPub</rdf:li>
|
||||||
|
</rdf:Bag>
|
||||||
|
</dc:subject>
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
style="opacity:1"
|
||||||
|
transform="translate(7.1437516,141.67967)">
|
||||||
|
<path
|
||||||
|
style="fill:#000000;stroke-width:0.26458335"
|
||||||
|
d=""
|
||||||
|
id="path5497"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<g
|
||||||
|
id="g5197"
|
||||||
|
transform="translate(-4.2352716,0.01824528)">
|
||||||
|
<g
|
||||||
|
id="g5132-90"
|
||||||
|
style="fill:url(#linearGradient7297-7);fill-opacity:1"
|
||||||
|
transform="matrix(0.9789804,0,0,0.9789804,-3157.9561,1202.4422)">
|
||||||
|
<g
|
||||||
|
transform="matrix(0.2553682,0,0,0.2553682,2615.9213,-1125.3113)"
|
||||||
|
id="g5080-78"
|
||||||
|
style="fill:url(#linearGradient8312);fill-opacity:1">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path5404-0-0"
|
||||||
|
d="m 2450.431,-937.13662 51.9615,30 v 12 l -51.9615,30 v -12 l 41.5693,-24 -41.5692,-24 z"
|
||||||
|
style="fill:url(#linearGradient8308);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
sodipodi:nodetypes="cccccccc" />
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
style="fill:url(#linearGradient8310);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 2450.431,-913.13662 20.7847,12 -20.7847,12 z"
|
||||||
|
id="path5406-6-3"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g5127-1"
|
||||||
|
style="fill:url(#linearGradient7303-7);fill-opacity:1"
|
||||||
|
transform="matrix(0.9789804,0,0,0.9789804,-3157.9561,1202.4422)">
|
||||||
|
<path
|
||||||
|
id="path5467-2-0"
|
||||||
|
transform="matrix(0.27026418,0,0,0.27026418,3225.7603,-1228.2597)"
|
||||||
|
d="M 49.097656,-504.56641 0,-476.2207 v 11.33789 l 39.277344,-22.67578 v 45.35351 l 9.820312,5.66992 z m -19.638672,34.01563 -19.6406246,11.33789 19.6406246,11.33789 z"
|
||||||
|
style="fill:url(#linearGradient8314);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25000042px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 8.8 KiB |
17
assets/img/fediverse.svg
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="196.52mm" height="196.52mm" viewBox="0 0 196.52 196.52">
|
||||||
|
<path fill="#a730b8" d="M47.9242 72.7966a18.2278 18.2278 0 0 1-7.7959 7.7597l42.7984 42.9653 10.3182-5.2291zm56.4524 56.6704-10.3182 5.2291 21.686 21.7708a18.2278 18.2278 0 0 1 7.7975-7.7608z"/>
|
||||||
|
<path fill="#5496be" d="M129.6645 102.0765l1.7865 11.4272 27.4149-13.8942a18.2278 18.2278 0 0 1-4.9719-9.8124zm-14.0658 7.1282-57.2891 29.0339a18.2278 18.2278 0 0 1 4.9728 9.8133l54.1027-27.4194z"/>
|
||||||
|
<path fill="#ce3d1a" d="M69.5312 91.6539l8.1618 8.1933 29.269-57.1387a18.2278 18.2278 0 0 1-9.787-5.0219zm-7.1897 14.0363-14.0022 27.3353a18.2278 18.2278 0 0 1 9.786 5.0214l12.3775-24.1639z"/>
|
||||||
|
<path fill="#d0188f" d="M39.8906 80.6763a18.2278 18.2278 0 0 1-10.8655 1.7198l8.1762 52.2981a18.2278 18.2278 0 0 1 10.8645-1.7198z"/>
|
||||||
|
<path fill="#5b36e9" d="M63.3259 148.3109a18.2278 18.2278 0 0 1-1.7322 10.8629l52.2893 8.3907a18.2278 18.2278 0 0 1 1.7322-10.8629z"/>
|
||||||
|
<path fill="#30b873" d="M134.9148 146.9182a18.2278 18.2278 0 0 1 9.788 5.0224l24.1345-47.117a18.2278 18.2278 0 0 1-9.7875-5.0229z"/>
|
||||||
|
<path fill="#ebe305" d="M126.1329 33.1603a18.2278 18.2278 0 0 1-7.7975 7.7608l37.3765 37.5207a18.2278 18.2278 0 0 1 7.7969-7.7608z"/>
|
||||||
|
<path fill="#f47601" d="M44.7704 51.6279a18.2278 18.2278 0 0 1 4.9723 9.8123l47.2478-23.9453a18.2278 18.2278 0 0 1-4.9718-9.8113z"/>
|
||||||
|
<path fill="#57c115" d="M118.2491 40.9645a18.2278 18.2278 0 0 1-10.8511 1.8123l4.1853 26.8 11.42 1.8324zm-4.2333 44.1927 9.8955 63.3631a18.2278 18.2278 0 0 1 10.88-1.6278l-9.355-59.9035z"/>
|
||||||
|
<path fill="#dbb210" d="M49.7763 61.6412a18.2278 18.2278 0 0 1-1.694 10.8686l26.8206 4.3077 5.2715-10.2945zm45.9677 7.382-5.272 10.2955 63.3713 10.1777a18.2278 18.2278 0 0 1 1.7606-10.8593z"/>
|
||||||
|
<path fill="#ffca00" d="M93.4385 23.8419a1 1 0 1 0 33.0924 1.8025 1 1 0 1 0-33.0924-1.8025"/>
|
||||||
|
<path fill="#64ff00" d="M155.314 85.957a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||||
|
<path fill="#00a3ff" d="M115.3466 163.9824a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||||
|
<path fill="#9500ff" d="M28.7698 150.0898a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||||
|
<path fill="#ff0000" d="M15.2298 63.4781a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
10
assets/img/mastodon.svg
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<svg width="75" height="79" viewBox="0 0 75 79" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M73.8393 17.4898C72.6973 9.00165 65.2994 2.31235 56.5296 1.01614C55.05 0.797115 49.4441 0 36.4582 0H36.3612C23.3717 0 20.585 0.797115 19.1054 1.01614C10.5798 2.27644 2.79399 8.28712 0.904997 16.8758C-0.00358524 21.1056 -0.100549 25.7949 0.0682394 30.0965C0.308852 36.2651 0.355538 42.423 0.91577 48.5665C1.30307 52.6474 1.97872 56.6957 2.93763 60.6812C4.73325 68.042 12.0019 74.1676 19.1233 76.6666C26.7478 79.2728 34.9474 79.7055 42.8039 77.9162C43.6682 77.7151 44.5217 77.4817 45.3645 77.216C47.275 76.6092 49.5123 75.9305 51.1571 74.7385C51.1797 74.7217 51.1982 74.7001 51.2112 74.6753C51.2243 74.6504 51.2316 74.6229 51.2325 74.5948V68.6416C51.2321 68.6154 51.2259 68.5896 51.2142 68.5661C51.2025 68.5426 51.1858 68.522 51.1651 68.5058C51.1444 68.4896 51.1204 68.4783 51.0948 68.4726C51.0692 68.4669 51.0426 68.467 51.0171 68.4729C45.9835 69.675 40.8254 70.2777 35.6502 70.2682C26.7439 70.2682 24.3486 66.042 23.6626 64.2826C23.1113 62.762 22.7612 61.1759 22.6212 59.5646C22.6197 59.5375 22.6247 59.5105 22.6357 59.4857C22.6466 59.4609 22.6633 59.4391 22.6843 59.422C22.7053 59.4048 22.73 59.3929 22.7565 59.3871C22.783 59.3813 22.8104 59.3818 22.8367 59.3886C27.7864 60.5826 32.8604 61.1853 37.9522 61.1839C39.1768 61.1839 40.3978 61.1839 41.6224 61.1516C46.7435 61.008 52.1411 60.7459 57.1796 59.7621C57.3053 59.7369 57.431 59.7154 57.5387 59.6831C65.4861 58.157 73.0493 53.3672 73.8178 41.2381C73.8465 40.7606 73.9184 36.2364 73.9184 35.7409C73.9219 34.0569 74.4606 23.7949 73.8393 17.4898Z" fill="url(#paint0_linear_549_34)"/>
|
||||||
|
<path d="M61.2484 27.0263V48.114H52.8916V27.6475C52.8916 23.3388 51.096 21.1413 47.4437 21.1413C43.4287 21.1413 41.4177 23.7409 41.4177 28.8755V40.0782H33.1111V28.8755C33.1111 23.7409 31.0965 21.1413 27.0815 21.1413C23.4507 21.1413 21.6371 23.3388 21.6371 27.6475V48.114H13.2839V27.0263C13.2839 22.7176 14.384 19.2946 16.5843 16.7572C18.8539 14.2258 21.8311 12.926 25.5264 12.926C29.8036 12.926 33.0357 14.5705 35.1905 17.8559L37.2698 21.346L39.3527 17.8559C41.5074 14.5705 44.7395 12.926 49.0095 12.926C52.7013 12.926 55.6784 14.2258 57.9553 16.7572C60.1531 19.2922 61.2508 22.7152 61.2484 27.0263Z" fill="white"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="paint0_linear_549_34" x1="37.0692" y1="0" x2="37.0692" y2="79" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#6364FF"/>
|
||||||
|
<stop offset="1" stop-color="#563ACC"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
1
assets/img/mobilizon.svg
Normal file
After Width: | Height: | Size: 14 KiB |
34
assets/js/event-bridge-for-activitypub-admin.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
jQuery( function( $ ) {
|
||||||
|
// Accordion handling in various areas.
|
||||||
|
$( '.event-bridge-for-activitypub-settings-accordion' ).on( 'click', '.event-bridge-for-activitypub-settings-accordion-trigger', function() {
|
||||||
|
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
|
||||||
|
|
||||||
|
if ( isExpanded ) {
|
||||||
|
$( this ).attr( 'aria-expanded', 'false' );
|
||||||
|
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true );
|
||||||
|
} else {
|
||||||
|
$( this ).attr( 'aria-expanded', 'true' );
|
||||||
|
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Function to toggle visibility of custom details based on selected radio button.
|
||||||
|
function toggleCustomDetailsForSummary() {
|
||||||
|
if ($("#event_bridge_for_activitypub_summary_type_custom").is(':checked')) {
|
||||||
|
$("#event_bridge_for_activitypub_summary_type_custom-details").show();
|
||||||
|
} else {
|
||||||
|
$("#event_bridge_for_activitypub_summary_type_custom-details").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the toggle function on page load.
|
||||||
|
$(document).ready(function() {
|
||||||
|
window.console.log("test");
|
||||||
|
toggleCustomDetailsForSummary(); // Set the correct state on load.
|
||||||
|
|
||||||
|
// Listen for changes on the radio buttons
|
||||||
|
$("input[name=event_bridge_for_activitypub_summary_type]").change(function() {
|
||||||
|
toggleCustomDetailsForSummary(); // Update visibility on change.
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} );
|
|
@ -208,9 +208,15 @@ install_wp_plugin() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the latest tag.
|
# Get the latest tag.
|
||||||
LATEST_TAG=$(svn log https://plugins.svn.wordpress.org/$PLUGIN_NAME/tags --limit 1 | awk 'NR == 4 { print $4 }')
|
if [ -z "$2" ]; then
|
||||||
if [ -n "$LATEST_TAG" ]; then
|
LATEST_TAG=$(svn log https://plugins.svn.wordpress.org/$PLUGIN_NAME/tags --limit 1 | awk 'NR == 4 { print $4 }')
|
||||||
PLUGIN_FILE="$PLUGIN_NAME.$LATEST_TAG.zip"
|
PLUGIN_VERSION=$LATEST_TAG
|
||||||
|
else
|
||||||
|
PLUGIN_VERSION=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$PLUGIN_VERSION" ]; then
|
||||||
|
PLUGIN_FILE="$PLUGIN_NAME.$PLUGIN_VERSION.zip"
|
||||||
else
|
else
|
||||||
PLUGIN_FILE="$PLUGIN_NAME.zip"
|
PLUGIN_FILE="$PLUGIN_NAME.zip"
|
||||||
fi
|
fi
|
||||||
|
@ -226,6 +232,20 @@ install_wp_plugin() {
|
||||||
unzip -q -o "$TMPDIR/$PLUGIN_FILE" -d "$WP_CORE_DIR/wp-content/plugins/"
|
unzip -q -o "$TMPDIR/$PLUGIN_FILE" -d "$WP_CORE_DIR/wp-content/plugins/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_wp_plugin_mec() {
|
||||||
|
mkdir -p "$WP_CORE_DIR/wp-content/plugins/"
|
||||||
|
|
||||||
|
if [ -d "$WP_CORE_DIR/wp-content/plugins/modern-events-calendar-lite" ]; then
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLUGIN_VERSION="v7.15.0"
|
||||||
|
|
||||||
|
URL="https://code.event-federation.eu/Event-Federation/modern-events-calendar-lite"
|
||||||
|
|
||||||
|
git clone $URL "$WP_CORE_DIR/wp-content/plugins/modern-events-calendar-lite"
|
||||||
|
}
|
||||||
|
|
||||||
install_wp_plugins() {
|
install_wp_plugins() {
|
||||||
if [ "$SKIP_PLUGINS_INSTALL" = "true" ]; then
|
if [ "$SKIP_PLUGINS_INSTALL" = "true" ]; then
|
||||||
echo "Skipping WordPress plugin installation."
|
echo "Skipping WordPress plugin installation."
|
||||||
|
@ -234,10 +254,16 @@ install_wp_plugins() {
|
||||||
# Install the one and only ActivityPub plugin (greetings @pfefferle).
|
# Install the one and only ActivityPub plugin (greetings @pfefferle).
|
||||||
install_wp_plugin activitypub
|
install_wp_plugin activitypub
|
||||||
# Install (not-activate) all supported event plugins.
|
# Install (not-activate) all supported event plugins.
|
||||||
install_wp_plugin the-events-calendar
|
install_wp_plugin the-events-calendar "6.8.1"
|
||||||
install_wp_plugin very-simple-event-list
|
install_wp_plugin very-simple-event-list
|
||||||
install_wp_plugin gatherpress
|
install_wp_plugin gatherpress
|
||||||
install_wp_plugin events-manager
|
install_wp_plugin eventprime-event-calendar-management
|
||||||
|
install_wp_plugin events-manager "6.6.3"
|
||||||
|
install_wp_plugin wp-event-manager "3.1.45.1"
|
||||||
|
install_wp_plugin wp-event-solution "4.0.14"
|
||||||
|
install_wp_plugin event-organiser "3.12.8"
|
||||||
|
# Mec is not installable via wordpress.org, we use our own mirror.
|
||||||
|
install_wp_plugin_mec
|
||||||
}
|
}
|
||||||
|
|
||||||
install_wp
|
install_wp
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "menrath/wordpress-activitypub-event-extensions",
|
"name": "menrath/wordpress-event-bridge-for-activitypub",
|
||||||
"description": "The ActivityPub Event Extensions help for event custom post types to federate properly.",
|
"version": "1.0.0",
|
||||||
|
"description": "The Event Bridge for ActivityPub help for event custom post types to federate properly.",
|
||||||
"type": "wordpress-plugin",
|
"type": "wordpress-plugin",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1.0",
|
"php": ">=7.4.0",
|
||||||
"composer/installers": "^2.0"
|
"composer/installers": "^2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"extra": {
|
"extra": {
|
||||||
"installer-name": "activitypub-event-extensions"
|
"installer-name": "event-bridge-for-activitypub"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": [
|
"lint": [
|
||||||
|
@ -50,15 +51,27 @@
|
||||||
"@test-vs-event-list",
|
"@test-vs-event-list",
|
||||||
"@test-the-events-calendar",
|
"@test-the-events-calendar",
|
||||||
"@test-gatherpress",
|
"@test-gatherpress",
|
||||||
"@test-events-manager"
|
"@test-events-manager",
|
||||||
|
"@test-wp-event-manager",
|
||||||
|
"@test-eventin",
|
||||||
|
"@test-modern-events-calendar-lite",
|
||||||
|
"@test-eventprime",
|
||||||
|
"@test-event-organiser"
|
||||||
],
|
],
|
||||||
"test-debug": [
|
"test-debug": [
|
||||||
"@prepare-test",
|
"@prepare-test",
|
||||||
"@test-vs-event-list"
|
"@test-event-bridge-for-activitypub-shortcodes"
|
||||||
],
|
],
|
||||||
"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",
|
||||||
"test-gatherpress": "phpunit --filter=gatherpress",
|
"test-gatherpress": "phpunit --filter=gatherpress",
|
||||||
"test-events-manager": "phpunit --filter=events_manager"
|
"test-events-manager": "phpunit --filter=events_manager",
|
||||||
|
"test-wp-event-manager": "phpunit --filter=wp_event_manager",
|
||||||
|
"test-eventin": "phpunit --filter=eventin",
|
||||||
|
"test-modern-events-calendar-lite": "phpunit --filter=modern_events_calendar_lite",
|
||||||
|
"test-eventprime": "phpunit --filter=eventprime",
|
||||||
|
"test-event-organiser": "phpunit --filter=event_organiser",
|
||||||
|
"test-event-bridge-for-activitypub-shortcodes": "phpunit --filter=event_bridge_for_activitypub_shortcodes",
|
||||||
|
"test-all": "phpunit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
# This files purpose is to run the PHPunit tests locally.
|
# This files purpose is to run the PHPunit tests locally.
|
||||||
|
# Prerequisites:
|
||||||
|
# Run "composer install" to generate a composer.lock file and install PHP dev dependencies.
|
||||||
|
#
|
||||||
# Install docker and docker compose and than just run:
|
# Install docker and docker compose and than just run:
|
||||||
# docker compose up
|
# docker compose up
|
||||||
|
|
||||||
|
@ -13,7 +16,7 @@ version: '3'
|
||||||
# "request": "launch",
|
# "request": "launch",
|
||||||
# "port": 9003,
|
# "port": 9003,
|
||||||
# "pathMappings": {
|
# "pathMappings": {
|
||||||
# "/app/": "${workspaceRoot}/wp-content/plugins/activitypub-event-extensions/",
|
# "/app/": "${workspaceRoot}/wp-content/plugins/event-bridge-for-activitypub/",
|
||||||
# "/tmp/wordpress/": "${workspaceRoot}/"
|
# "/tmp/wordpress/": "${workspaceRoot}/"
|
||||||
# },
|
# },
|
||||||
# },
|
# },
|
||||||
|
|
|
@ -10,34 +10,57 @@ 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 in the constant `SUPPORTED_EVENT_PLUGIN` in the file `includes/class-setup.php`:
|
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.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Example from the Events Manager plugin.
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
'events_manager' => array( // Choose any key you like.
|
|
||||||
'plugin_file' => 'events-manager/events-manager.php',
|
// Exit if accessed directly.
|
||||||
'post_type' => 'event',
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
'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 Plugin takes care of applying the transformer, so you can jump right into implementing it.
|
Then you need to tell the Event Bridge for ActivityPub about that class by adding it to the `EVENT_PLUGIN_CLASSES` constant in the `includes/setup.php` file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
private const EVENT_PLUGIN_CLASSES = array(
|
||||||
|
...
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\My_Event_Plugin',
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
The Event Bridge for ActivityPub then takes care of applying the transformer, so you can jump right into implementing it.
|
||||||
|
|
||||||
## Writing an event transformer class
|
## Writing an event transformer class
|
||||||
|
|
||||||
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.
|
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 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_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event as Event_Transformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Transformer for my_event_post_type.
|
* ActivityPub Transformer for My Event Plugin' event post type.
|
||||||
*/
|
*/
|
||||||
class My_Event_Post_Type_Transformer extends Event; {
|
class My_Event_Plugin extends Event_Transformer; {
|
||||||
```
|
```
|
||||||
|
|
||||||
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 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 chances are good that you will not need to override that function.
|
||||||
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +75,16 @@ public function to_object() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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:
|
||||||
|
|
||||||
|
```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
|
||||||
|
|
||||||
|
@ -65,7 +97,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 Properties for an Event
|
#### Mandatory fields
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
@ -75,8 +107,116 @@ 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
|
||||||
|
|
||||||
#### Recommended properties for an Event in order to achieve good interoperability with other ActivityPub platforms
|
#### Checklist for properties you SHOULD at least consider writing a getter functions for
|
||||||
|
|
||||||
* **[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.
|
* **`endTime`**
|
||||||
|
* **`location`** – Note: the `address` within can be both a `string` or a `PostalAddress`.
|
||||||
|
* **`isOnline`**
|
||||||
|
* **`status`**
|
||||||
|
* **`get_tag`**
|
||||||
|
* **`timezone`**
|
||||||
|
* **`commentsEnabled`**
|
||||||
|
|
||||||
* **`isOnline`**:
|
## Writing integration tests
|
||||||
|
|
||||||
|
Create a new tests class in `tests/test-class-plugin-my-event-plugin.php`.
|
||||||
|
|
||||||
|
```
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_My_Event_Plugin extends WP_UnitTestCase {
|
||||||
|
```
|
||||||
|
|
||||||
|
Implement a check whether your event plugin is active in the `set_up` function. It may be the presence of a class, function or constant.
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! <TODO:my-event-plugin-is-active> ) {
|
||||||
|
self::markTestSkipped( 'The Events Calendar plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the tests for your plugin/ add the tests to the CI pipeline
|
||||||
|
|
||||||
|
### Install the plugin in the CI
|
||||||
|
|
||||||
|
The tests are set up by the bash script in `bin/install-wp-tests.sh`. Make sure your WordPress Event plugin is installed within the function `install_wp_plugins`.
|
||||||
|
|
||||||
|
### Add a composer script for your plugin
|
||||||
|
|
||||||
|
In the pipeline we want to run each event plugins integration tests in a single command, to achieve that, we use phpunit's filters.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
...
|
||||||
|
"test": [
|
||||||
|
...
|
||||||
|
"@test-my-event-plugin"
|
||||||
|
],
|
||||||
|
...
|
||||||
|
"@test-my-event-plugin": "phpunit --filter=my_event_plugin",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Load your plugin during the tests
|
||||||
|
|
||||||
|
To activate/load your plugin add it to the switch statement within the function `_manually_load_plugin()` within `tests/bootstrap.php`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
switch ( $event_bridge_for_activitypub_integration_filter ) {
|
||||||
|
...
|
||||||
|
case 'my_event_plugin':
|
||||||
|
$plugin_file = 'my-event-plugin/my-event-plugin.php';
|
||||||
|
break;
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to run your tests locally just change the `test-debug` script in the `composer.json` file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"test-debug": [
|
||||||
|
"@prepare-test",
|
||||||
|
"@test-my-event-plugin"
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you just can execute `docker compose up` to run the tests (make sure you have the latest docker and docker-compose installed).
|
||||||
|
|
||||||
|
### Debugging the tests
|
||||||
|
|
||||||
|
If you are using Visual Studio Code or VSCodium you can step-debug within the tests by adding this configuration to your `.vscode/launch.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
...,
|
||||||
|
{
|
||||||
|
"name": "Listen for PHPUnit",
|
||||||
|
"type": "php",
|
||||||
|
"request": "launch",
|
||||||
|
"port": 9003,
|
||||||
|
"pathMappings": {
|
||||||
|
"/app/": "${workspaceRoot}/wp-content/plugins/event-bridge-for-activitypub/",
|
||||||
|
"/tmp/wordpress/": "${workspaceRoot}/"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
38
event-bridge-for-activitypub.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: Event Bridge for ActivityPub
|
||||||
|
* Description: Integrating popular event plugins with the ActivityPub plugin.
|
||||||
|
* Plugin URI: https://event-federation.eu/
|
||||||
|
* Version: 0.3.2
|
||||||
|
* Author: André Menrath
|
||||||
|
* Author URI: https://graz.social/@linos
|
||||||
|
* Text Domain: event-bridge-for-activitypub
|
||||||
|
* License: AGPL-3.0-or-later
|
||||||
|
* License URI: https://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
* Requires PHP: 7.4
|
||||||
|
*
|
||||||
|
* Requires at least ActivityPub plugin with version >= 3.2.2. ActivityPub plugin tested up to: 4.3.0.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION', current( get_file_data( __FILE__, array( 'Version' ), 'plugin' ) ) );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_DOMAIN', 'event-bridge-for-activitypub' );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION', '3.2.2' );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY', "<ul>\n <li>[ap_start_time]</li>\n <li>[ap_end_time]</li>\n <li>[ap_location]</li>\n</ul>\n[ap_hashcats] [ap_hashtags]" );
|
||||||
|
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE', 'preset' );
|
||||||
|
|
||||||
|
// Include and register the autoloader class for automatic loading of plugin classes.
|
||||||
|
require_once EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/class-autoloader.php';
|
||||||
|
Event_Bridge_For_ActivityPub\Autoloader::register();
|
||||||
|
|
||||||
|
// Initialize the plugin.
|
||||||
|
Event_Bridge_For_ActivityPub\Setup::get_instance();
|
99
includes/activitypub/transformer/class-event-organiser.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for the plugin Event Organiser.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for Event Organiser.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Event_Organiser extends Event {
|
||||||
|
/**
|
||||||
|
* Extended constructor.
|
||||||
|
*
|
||||||
|
* The wp_object is overridden with a the wp_object with filters. This object
|
||||||
|
* also contains attributes specific to the Event organiser plugin like the
|
||||||
|
* occurrence id.
|
||||||
|
*
|
||||||
|
* @param WP_Post $wp_object The WordPress object.
|
||||||
|
* @param string $wp_taxonomy The taxonomy slug of the event post type.
|
||||||
|
*/
|
||||||
|
public function __construct( $wp_object, $wp_taxonomy ) {
|
||||||
|
parent::__construct( $wp_object, $wp_taxonomy );
|
||||||
|
$this->wp_object = get_posts(
|
||||||
|
array(
|
||||||
|
'ID' => $wp_object->ID,
|
||||||
|
'post_type' => 'event',
|
||||||
|
'suppress_filters' => false,
|
||||||
|
)
|
||||||
|
)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): ?string {
|
||||||
|
return eo_get_the_end( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_start_time(): string {
|
||||||
|
return eo_get_the_start( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get location from the event object.
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
$venue_id = eo_get_venue( $this->wp_object->ID );
|
||||||
|
|
||||||
|
if ( ! $venue_id ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = eo_get_venue_address( $venue_id );
|
||||||
|
|
||||||
|
$venue_name = eo_get_venue_name( $venue_id );
|
||||||
|
|
||||||
|
$address['streetAddress'] = $address['address'];
|
||||||
|
unset( $address['address'] );
|
||||||
|
|
||||||
|
$address['postalCode'] = $address['postcode'];
|
||||||
|
unset( $address['postcode'] );
|
||||||
|
|
||||||
|
$address['addressRegion'] = $address['state'];
|
||||||
|
unset( $address['state'] );
|
||||||
|
|
||||||
|
$address['addressLocality'] = $address['city'];
|
||||||
|
unset( $address['city'] );
|
||||||
|
|
||||||
|
$address['addressCountry'] = $address['country'];
|
||||||
|
unset( $address['country'] );
|
||||||
|
|
||||||
|
$address['type'] = 'PostalAddress';
|
||||||
|
|
||||||
|
$location = new Place();
|
||||||
|
$location->set_name( eo_get_venue_name( $this->wp_object->ID ) );
|
||||||
|
$location->set_latitude( eo_get_venue_lat( $this->wp_object->ID ) ?? null );
|
||||||
|
$location->set_longitude( eo_get_venue_lng( $this->wp_object->ID ) ?? null );
|
||||||
|
$location->set_address( $address );
|
||||||
|
$location->set_name( $venue_name );
|
||||||
|
$location->set_content( eo_get_venue_description( $venue_id ) );
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,22 +2,34 @@
|
||||||
/**
|
/**
|
||||||
* Replace the default ActivityPub Transformer
|
* Replace the default ActivityPub Transformer
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\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\Shortcodes;
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
class Event extends Post {
|
abstract class Event extends Post {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WordPress event taxonomy.
|
* The WordPress event taxonomy.
|
||||||
|
@ -26,17 +38,6 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -55,6 +56,16 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -72,7 +83,7 @@ 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 ) {
|
public function __construct( $wp_object, $wp_taxonomy = 'category' ) {
|
||||||
parent::__construct( $wp_object );
|
parent::__construct( $wp_object );
|
||||||
$this->wp_taxonomy = $wp_taxonomy;
|
$this->wp_taxonomy = $wp_taxonomy;
|
||||||
}
|
}
|
||||||
|
@ -102,9 +113,14 @@ 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 {
|
||||||
$current_category_mapping = \get_option( 'activitypub_event_extensions_event_category_mappings', array() );
|
if ( is_null( $this->wp_taxonomy ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$current_category_mapping = \get_option( 'event_bridge_for_activitypub_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.
|
||||||
|
@ -112,10 +128,434 @@ 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_extensions_default_event_category', 'MEETING' ) );
|
return sanitize_text_field( \get_option( 'event_bridge_for_activitypub_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 public function get_start_time(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time.
|
||||||
|
*
|
||||||
|
* This is not mandatory and therefore just return null by default.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): ?string {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a default for the location.
|
||||||
|
*
|
||||||
|
* This should be overridden in the actual event transformer.
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for the event status.
|
||||||
|
*/
|
||||||
|
public 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.
|
||||||
|
*/
|
||||||
|
protected 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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates output for the 'ap_start_time' shortcode.
|
||||||
|
*
|
||||||
|
* @param ?array $atts The shortcode's attributes.
|
||||||
|
* @return string The formatted start date and time of the event.
|
||||||
|
*/
|
||||||
|
public function shortcode_start_time( $atts ) {
|
||||||
|
$start_timestamp = $this->get_start_time();
|
||||||
|
return $this->generate_time_output( $start_timestamp, $atts, '🗓️', __( 'Start', 'event-bridge-for-activitypub' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates output for the 'ap_end_time' shortcode.
|
||||||
|
*
|
||||||
|
* @param ?array $atts The shortcode's attributes.
|
||||||
|
* @return string The formatted end date and time of the event.
|
||||||
|
*/
|
||||||
|
public function shortcode_end_time( $atts ) {
|
||||||
|
$end_timestamp = $this->get_end_time();
|
||||||
|
return $this->generate_time_output( $end_timestamp, $atts, '⏳', __( 'End', 'event-bridge-for-activitypub' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the formatted time output for a shortcode.
|
||||||
|
*
|
||||||
|
* @param int|null $timestamp The timestamp for the event time.
|
||||||
|
* @param array $atts The shortcode attributes.
|
||||||
|
* @param string $icon The icon to display.
|
||||||
|
* @param string $label The label to display (e.g., 'Start', 'End').
|
||||||
|
* @return string The formatted date and time, or an empty string if the timestamp is invalid.
|
||||||
|
*/
|
||||||
|
private function generate_time_output( $timestamp, $atts, $icon, $label ) {
|
||||||
|
if ( ! $timestamp ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = shortcode_atts(
|
||||||
|
array(
|
||||||
|
'icon' => 'true',
|
||||||
|
'label' => 'true',
|
||||||
|
),
|
||||||
|
$atts
|
||||||
|
);
|
||||||
|
|
||||||
|
$args['icon'] = filter_var( $args['icon'], FILTER_VALIDATE_BOOLEAN );
|
||||||
|
$args['label'] = filter_var( $args['label'], FILTER_VALIDATE_BOOLEAN );
|
||||||
|
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
if ( $args['icon'] ) {
|
||||||
|
$output[] = $icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $args['label'] ) {
|
||||||
|
$output[] = $label . ':';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output[] = self::format_time( $timestamp );
|
||||||
|
|
||||||
|
return implode( ' ', $output );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates output for the 'ap_location' shortcode.
|
||||||
|
*
|
||||||
|
* @param ?array $atts The shortcode's attributes.
|
||||||
|
* @return string The formatted location/address of the event.
|
||||||
|
*/
|
||||||
|
public function shortcode_location( $atts ) {
|
||||||
|
$args = shortcode_atts(
|
||||||
|
array(
|
||||||
|
'icon' => 'true',
|
||||||
|
'label' => 'true',
|
||||||
|
'country' => 'true',
|
||||||
|
'zip' => 'true',
|
||||||
|
'city' => 'true',
|
||||||
|
'street' => 'true',
|
||||||
|
'name' => 'true',
|
||||||
|
),
|
||||||
|
$atts,
|
||||||
|
'ap_location'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert attributes to booleans.
|
||||||
|
$args = array_map(
|
||||||
|
function ( $value ) {
|
||||||
|
return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
|
||||||
|
},
|
||||||
|
$args
|
||||||
|
);
|
||||||
|
|
||||||
|
$location = $this->get_location();
|
||||||
|
if ( ! $location ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = array();
|
||||||
|
if ( $args['icon'] ) {
|
||||||
|
$output[] = '📍';
|
||||||
|
}
|
||||||
|
if ( $args['label'] ) {
|
||||||
|
$output[] = esc_html__( 'Location', 'event-bridge-for-activitypub' ) . ':';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output[] = self::format_address( $location->get_address(), $args );
|
||||||
|
|
||||||
|
// Join output array into a single string with spaces and return.
|
||||||
|
return implode( ' ', array_filter( $output ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the address based on provided arguments.
|
||||||
|
*
|
||||||
|
* @param mixed $address The address data, either as a string or an array.
|
||||||
|
* @param array $args The arguments for which components to include.
|
||||||
|
* @return string The formatted address.
|
||||||
|
*/
|
||||||
|
protected static function format_address( $address, $args = null ) {
|
||||||
|
if ( is_string( $address ) ) {
|
||||||
|
return esc_html( $address );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_null( $args ) ) {
|
||||||
|
$args = array(
|
||||||
|
'icon' => 'true',
|
||||||
|
'title' => 'true',
|
||||||
|
'country' => 'true',
|
||||||
|
'zip' => 'true',
|
||||||
|
'city' => 'true',
|
||||||
|
'street' => 'true',
|
||||||
|
'name' => 'true',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_array( $address ) ) {
|
||||||
|
$address_parts = array();
|
||||||
|
|
||||||
|
$components = array(
|
||||||
|
'name' => 'name',
|
||||||
|
'street' => 'streetAddress',
|
||||||
|
'zip' => 'postalCode',
|
||||||
|
'city' => 'addressLocality',
|
||||||
|
'country' => 'addressCountry',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $components as $arg_key => $address_key ) {
|
||||||
|
if ( $args[ $arg_key ] && ! empty( $address[ $address_key ] ) ) {
|
||||||
|
$address_parts[] = esc_html( $address[ $address_key ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode( ', ', $address_parts );
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/event-categories.php';
|
||||||
|
$federated_category = $this->get_category();
|
||||||
|
if ( array_key_exists( $federated_category, EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES ) ) {
|
||||||
|
$categories[] = EVENT_BRIDGE_FOR_ACTIVITYPUB_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 '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the shortcodes.
|
||||||
|
*/
|
||||||
|
public function register_shortcodes() {
|
||||||
|
foreach ( get_class_methods( self::class ) as $function ) {
|
||||||
|
if ( 'shortcode_' === substr( $function, 0, 10 ) ) {
|
||||||
|
add_shortcode( 'ap_' . substr( $function, 10, strlen( $function ) ), array( $this, $function ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the shortcodes.
|
||||||
|
*/
|
||||||
|
public function unregister_shortcodes() {
|
||||||
|
foreach ( get_class_methods( self::class ) as $function ) {
|
||||||
|
if ( 'shortcode_' === substr( $function, 0, 10 ) ) {
|
||||||
|
remove_shortcode( 'ap_' . substr( $function, 10, strlen( $function ) ), array( $this, $function ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the summary.
|
||||||
|
*/
|
||||||
|
public function get_summary(): ?string {
|
||||||
|
if ( 'preset' === get_option( 'event_bridge_for_activitypub_summary_type', 'preset' ) ) {
|
||||||
|
return $this->format_preset_summary();
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||||
|
$post = $this->wp_object;
|
||||||
|
$summary = $this->get_event_summary_template();
|
||||||
|
|
||||||
|
// It seems that shortcodes are only applied to published posts.
|
||||||
|
if ( is_preview() ) {
|
||||||
|
$post->post_status = 'publish';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register our shortcodes just in time.
|
||||||
|
|
||||||
|
Shortcodes::register();
|
||||||
|
$this->register_shortcodes();
|
||||||
|
|
||||||
|
// Fill in the shortcodes.
|
||||||
|
\setup_postdata( $post );
|
||||||
|
$summary = \do_shortcode( $summary );
|
||||||
|
\wp_reset_postdata();
|
||||||
|
|
||||||
|
$summary = \wpautop( $summary );
|
||||||
|
$summary = \preg_replace( '/[\n\r\t]/', '', $summary );
|
||||||
|
$summary = \trim( $summary );
|
||||||
|
|
||||||
|
$summary = \apply_filters( 'event_bridge_for_activitypub_the_summary', $summary, $post );
|
||||||
|
|
||||||
|
// Unregister the shortcodes.
|
||||||
|
Shortcodes::unregister();
|
||||||
|
$this->unregister_shortcodes();
|
||||||
|
|
||||||
|
return $summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 format_preset_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 = false;
|
||||||
|
if ( is_null( $excerpt ) && $fallback_to_content ) {
|
||||||
|
$excerpt = $this->get_content();
|
||||||
|
}
|
||||||
|
remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) );
|
||||||
|
|
||||||
|
$category = $this->format_categories();
|
||||||
|
$start_time = $this->get_start_time();
|
||||||
|
$end_time = $this->get_end_time();
|
||||||
|
$address = $this->format_address( $this->get_location() );
|
||||||
|
$time_atts = array(
|
||||||
|
'icon' => true,
|
||||||
|
'label' => true,
|
||||||
|
);
|
||||||
|
|
||||||
|
$formatted_items = array();
|
||||||
|
if ( ! empty( $category ) ) {
|
||||||
|
$formatted_items[] = '🏷️ ' . __( 'Category', 'event-bridge-for-activitypub' ) . ': ' . $category;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $start_time ) ) {
|
||||||
|
$formatted_items[] = $this->generate_time_output( $start_time, $time_atts, '🗓️', __( 'Start', 'event-bridge-for-activitypub' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $end_time ) ) {
|
||||||
|
$formatted_items[] = $this->generate_time_output( $end_time, $time_atts, '⏳', __( 'End', 'event-bridge-for-activitypub' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $address ) ) {
|
||||||
|
$formatted_items[] = '📍 ' . __( 'Address', 'event-bridge-for-activitypub' ) . ': ' . $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the template to use to generate the summary of the ActivityStreams representation of an event post.
|
||||||
|
*
|
||||||
|
* @return string The Template.
|
||||||
|
*/
|
||||||
|
protected function get_event_summary_template() {
|
||||||
|
$summary = \get_option( 'event_bridge_for_activitypub_custom_summary', EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY );
|
||||||
|
$template = $summary ?? EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY;
|
||||||
|
|
||||||
|
return apply_filters( 'event_bridge_for_activitypub_summary_template', $template, $this->wp_object );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
*
|
*
|
||||||
|
@ -125,6 +565,8 @@ 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 ) );
|
||||||
|
@ -144,7 +586,7 @@ 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->get_actor_object()->get_followers(), // this fails on my machine.
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
164
includes/activitypub/transformer/class-eventin.php
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for Events managed with Eventin.
|
||||||
|
*
|
||||||
|
* @link https://support.themewinter.com/docs/plugins/docs-category/eventin/
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event;
|
||||||
|
use DateTime;
|
||||||
|
use DateTimeZone;
|
||||||
|
use Etn\Core\Event\Event_Model;
|
||||||
|
|
||||||
|
use function Activitypub\esc_hashtag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for Events managed with Eventin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Eventin extends Event {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the EM_Event object.
|
||||||
|
*
|
||||||
|
* @var Event_Model
|
||||||
|
*/
|
||||||
|
protected $event_model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the constructor, to also set the Event Model.
|
||||||
|
*
|
||||||
|
* This is a special class object form The Events Calendar which
|
||||||
|
* has a lot of useful functions, we make use of our getter functions.
|
||||||
|
*
|
||||||
|
* @param WP_Post $wp_object The WordPress object.
|
||||||
|
* @param string $wp_taxonomy The taxonomy slug of the event post type.
|
||||||
|
*/
|
||||||
|
public function __construct( $wp_object, $wp_taxonomy ) {
|
||||||
|
parent::__construct( $wp_object, $wp_taxonomy );
|
||||||
|
$this->event_model = new Event_Model( $this->wp_object->ID );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_start_time(): string {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', strtotime( $this->event_model->get_start_datetime() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): string {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', strtotime( $this->event_model->get_end_datetime() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timezone of the event.
|
||||||
|
*/
|
||||||
|
public function get_timezone(): string {
|
||||||
|
return $this->event_model->get_timezone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether the event is online.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function get_is_online(): bool {
|
||||||
|
return 'online' === $this->event_model->__get( 'event_type' ) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maybe add online link to attachments.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_attachment(): array {
|
||||||
|
$attachment = parent::get_attachment();
|
||||||
|
|
||||||
|
$location = (array) $this->event_model->__get( 'location' );
|
||||||
|
if ( array_key_exists( 'integration', $location ) && array_key_exists( $location['integration'], $location ) ) {
|
||||||
|
$online_link = array(
|
||||||
|
'type' => 'Link',
|
||||||
|
'mediaType' => 'text/html',
|
||||||
|
'name' => $location[ $location['integration'] ],
|
||||||
|
'href' => $location[ $location['integration'] ],
|
||||||
|
);
|
||||||
|
$attachment[] = $online_link;
|
||||||
|
}
|
||||||
|
return $attachment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose the events tags.
|
||||||
|
*/
|
||||||
|
public function get_tag() {
|
||||||
|
// The parent tag function also fetches the mentions.
|
||||||
|
$tags = parent::get_tag();
|
||||||
|
|
||||||
|
$post_tags = \wp_get_post_terms( $this->wp_object->ID, 'etn_tags' );
|
||||||
|
$post_categories = \wp_get_post_terms( $this->wp_object->ID, 'etn_category' );
|
||||||
|
|
||||||
|
if ( ! is_wp_error( $post_tags ) && $post_tags ) {
|
||||||
|
foreach ( $post_tags as $term ) {
|
||||||
|
$tag = array(
|
||||||
|
'type' => 'Hashtag',
|
||||||
|
'href' => \esc_url( \get_tag_link( $term->term_id ) ),
|
||||||
|
'name' => esc_hashtag( $term->name ),
|
||||||
|
);
|
||||||
|
$tags[] = $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! is_wp_error( $post_categories ) && $post_categories ) {
|
||||||
|
foreach ( $post_categories as $term ) {
|
||||||
|
$tag = array(
|
||||||
|
'type' => 'Hashtag',
|
||||||
|
'href' => \esc_url( \get_tag_link( $term->term_id ) ),
|
||||||
|
'name' => esc_hashtag( $term->name ),
|
||||||
|
);
|
||||||
|
$tags[] = $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $tags ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the location.
|
||||||
|
*
|
||||||
|
* @return ?Place
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
$location = (array) $this->event_model->__get( 'location' );
|
||||||
|
|
||||||
|
if ( ! array_key_exists( 'address', $location ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$place = new Place();
|
||||||
|
|
||||||
|
$address = $location['address'];
|
||||||
|
|
||||||
|
$place->set_name( $address );
|
||||||
|
$place->set_address( $address );
|
||||||
|
$place->set_sensitive( null );
|
||||||
|
|
||||||
|
return $place;
|
||||||
|
}
|
||||||
|
}
|
78
includes/activitypub/transformer/class-eventprime.php
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for the plugin EventPrime.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for VS Event
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class EventPrime extends Event {
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): ?string {
|
||||||
|
$timestamp = get_post_meta( $this->wp_object->ID, 'em_end_date', true );
|
||||||
|
if ( $timestamp ) {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp );
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_start_time(): string {
|
||||||
|
$timestamp = get_post_meta( $this->wp_object->ID, 'em_start_date', true );
|
||||||
|
if ( $timestamp ) {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp );
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get location from the event object.
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
$venue_term_id = get_post_meta( $this->wp_object->ID, 'em_venue', true );
|
||||||
|
if ( ! $venue_term_id ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$venue = wp_get_post_terms( $this->wp_object->ID, 'em_venue' );
|
||||||
|
|
||||||
|
if ( empty( $venue ) ) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
$venue = $venue[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$place = new Place();
|
||||||
|
|
||||||
|
$place->set_name( $venue->name );
|
||||||
|
$place->set_content( $venue->description );
|
||||||
|
|
||||||
|
$address = get_term_meta( $venue->term_id, 'em_address', true );
|
||||||
|
$display_address = get_term_meta( $venue->term_id, 'em_display_address_on_frontend', true );
|
||||||
|
|
||||||
|
if ( $address && $display_address ) {
|
||||||
|
$place->set_address( get_term_meta( $venue->term_id, 'em_address', true ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $place;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,23 +2,22 @@
|
||||||
/**
|
/**
|
||||||
* ActivityPub Transformer for the plugin Very Simple Event List.
|
* ActivityPub Transformer for the plugin Very Simple Event List.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer;
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\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;
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
use function Activitypub\esc_hashtag;
|
||||||
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,42 +36,17 @@ final class Events_Manager extends Event_Transformer {
|
||||||
protected $em_event;
|
protected $em_event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get transformer name.
|
* Extend the constructor, to also set the Eventsmanager objects.
|
||||||
*
|
*
|
||||||
* Retrieve the transformers name.
|
* This is a special class object form The Events Calendar which
|
||||||
|
* has a lot of useful functions, we make use of our getter functions.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @param WP_Post $wp_object The WordPress object.
|
||||||
* @access public
|
* @param string $wp_taxonomy The taxonomy slug of the event post type.
|
||||||
* @return string Widget name.
|
|
||||||
*/
|
*/
|
||||||
public function get_transformer_name() {
|
public function __construct( $wp_object, $wp_taxonomy ) {
|
||||||
return 'activitypub-event-transformers/events-manager';
|
parent::__construct( $wp_object, $wp_taxonomy );
|
||||||
}
|
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +63,7 @@ final class Events_Manager extends Event_Transformer {
|
||||||
*
|
*
|
||||||
* @return array The Place.
|
* @return array The Place.
|
||||||
*/
|
*/
|
||||||
public function get_location() {
|
public function get_location(): ?Place {
|
||||||
if ( 'url' === $this->em_event->event_location_type ) {
|
if ( 'url' === $this->em_event->event_location_type ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -114,9 +88,6 @@ 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;
|
||||||
|
@ -125,14 +96,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() {
|
public function get_end_time(): ?string {
|
||||||
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() {
|
public function get_start_time(): string {
|
||||||
$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;
|
||||||
|
@ -163,8 +134,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 = $this->em_event->get_bookings()->get_bookings();
|
$em_bookings_count = $this->get_participant_count();
|
||||||
$remaining_attendee_capacity = $this->em_event->event_spaces - count( $em_bookings->bookings );
|
$remaining_attendee_capacity = $this->em_event->event_spaces - $em_bookings_count;
|
||||||
return $remaining_attendee_capacity;
|
return $remaining_attendee_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,23 +149,6 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -260,20 +214,4 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ActivityPub Transformer for the plugin Very Simple Event List.
|
* ActivityPub Transformer for the GatherPress event plugin.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\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 Event_Bridge_For_ActivityPub\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
|
||||||
*
|
*
|
||||||
|
@ -27,13 +23,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*
|
*
|
||||||
|
@ -63,25 +52,12 @@ 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|null {
|
public function get_location(): ?Place {
|
||||||
$address = $this->gp_venue['full_address'];
|
$address = $this->gp_venue['full_address'];
|
||||||
if ( $address ) {
|
if ( $address ) {
|
||||||
$place = new Place();
|
$place = new Place();
|
||||||
|
@ -97,14 +73,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() {
|
public function get_end_time(): ?string {
|
||||||
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() {
|
public function get_start_time(): string {
|
||||||
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' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,47 +117,30 @@ final class GatherPress extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the User-URL of the Author of the Post.
|
* Prevents gatherpress blocks from being rendered for the content.
|
||||||
*
|
*
|
||||||
* If `single_user` mode is enabled, the URL of the Blog-User is returned.
|
* @param mixed $block_content The blocks content.
|
||||||
*
|
* @param mixed $block The block.
|
||||||
* @return string The User-URL.
|
|
||||||
*/
|
*/
|
||||||
protected function get_attributed_to(): string {
|
public static function filter_gatherpress_blocks( $block_content, $block ) {
|
||||||
$user = new Blog();
|
// Check if the block name starts with 'gatherpress'.
|
||||||
return $user->get_url();
|
if ( isset( $block['blockName'] ) && 0 === strpos( $block['blockName'], 'gatherpress/' ) ) {
|
||||||
}
|
return ''; // Skip rendering this block.
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 {
|
|
||||||
if ( $this->wp_object->excerpt ) {
|
|
||||||
$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 {
|
|
||||||
$excerpt = $this->get_content();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$address = get_post_meta( $this->wp_object->ID, 'event-location', true );
|
return $block_content; // Return the content for other blocks.
|
||||||
$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.
|
* Apply the filter for preventing the rendering off gatherpress blocks just in time.
|
||||||
|
*
|
||||||
|
* @return Event_Object
|
||||||
*/
|
*/
|
||||||
public function get_content(): string {
|
public function to_object(): Event_Object {
|
||||||
return $this->wp_object->post_content;
|
add_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ), 10, 2 );
|
||||||
|
$activitypub_object = parent::to_object();
|
||||||
|
remove_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ) );
|
||||||
|
return $activitypub_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,16 +151,4 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Tribe Transformer
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event;
|
||||||
|
|
||||||
|
use MEC;
|
||||||
|
use MEC\Events\Event as MEC_Event;
|
||||||
|
use MEC_main;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Tribe Transformer
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Modern_Events_Calendar_Lite extends Event {
|
||||||
|
/**
|
||||||
|
* The MEC Event object.
|
||||||
|
*
|
||||||
|
* @var MEC_Event|null
|
||||||
|
*/
|
||||||
|
protected $mec_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The MEC main instance.
|
||||||
|
*
|
||||||
|
* @var MEC_main|null
|
||||||
|
*/
|
||||||
|
protected $mec_main;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the constructor, to also set the tribe object.
|
||||||
|
*
|
||||||
|
* This is a special class object form The Events Calendar which
|
||||||
|
* has a lot of useful functions, we make use of our getter functions.
|
||||||
|
*
|
||||||
|
* @param WP_Post $wp_object The WordPress object.
|
||||||
|
* @param string $wp_taxonomy The taxonomy slug of the event post type.
|
||||||
|
*/
|
||||||
|
public function __construct( $wp_object, $wp_taxonomy ) {
|
||||||
|
parent::__construct( $wp_object, $wp_taxonomy );
|
||||||
|
$this->mec_main = MEC::getInstance( 'app.libraries.main' );
|
||||||
|
$this->mec_event = new MEC_Event( $wp_object );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the content without the plugins rendered shortcodes.
|
||||||
|
*/
|
||||||
|
public function get_content(): string {
|
||||||
|
$content = wpautop( $this->wp_object->post_content );
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_start_time(): string {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $this->mec_event->get_datetime()['start']['timestamp'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the event object.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): ?string {
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $this->mec_event->get_datetime()['end']['timestamp'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the location.
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
$location_id = $this->mec_main->get_master_location_id( $this->mec_event->ID );
|
||||||
|
|
||||||
|
if ( ! $location_id ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->mec_main->get_location_data( $location_id );
|
||||||
|
|
||||||
|
$location = new Place();
|
||||||
|
$location->set_sensitive( null );
|
||||||
|
|
||||||
|
if ( ! empty( $data['address'] ) ) {
|
||||||
|
$location->set_address( $data['address'] );
|
||||||
|
}
|
||||||
|
if ( ! empty( $data['name'] ) ) {
|
||||||
|
$location->set_name( $data['name'] );
|
||||||
|
}
|
||||||
|
if ( ! empty( $data['longitude'] ) ) {
|
||||||
|
$location->set_longitude( $data['longitude'] );
|
||||||
|
}
|
||||||
|
if ( ! empty( $data['latitude'] ) ) {
|
||||||
|
$location->set_latitude( $data['latitude'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the location.
|
||||||
|
*/
|
||||||
|
public function get_timezone(): string {
|
||||||
|
$timezone = get_post_meta( $this->wp_object->ID, 'mec_timezone', true );
|
||||||
|
|
||||||
|
if ( 'global' === $timezone ) {
|
||||||
|
return parent::get_timezone();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $timezone;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,22 +2,21 @@
|
||||||
/**
|
/**
|
||||||
* ActivityPub Tribe Transformer
|
* ActivityPub Tribe Transformer
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
// Exit if accessed directly.
|
||||||
exit; // Exit if accessed directly.
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
}
|
|
||||||
|
|
||||||
use Activitypub_Event_Extensions\Activitypub\Transformer\Event;
|
|
||||||
use Activitypub\Activity\Extended_Object\Place;
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
use Activitypub\Activity\Extended_Object\Event as Event_Object;
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event;
|
||||||
use WP_Error;
|
|
||||||
use WP_Post;
|
use WP_Post;
|
||||||
|
|
||||||
|
use function Activitypub\esc_hashtag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Tribe Transformer
|
* ActivityPub Tribe Transformer
|
||||||
*
|
*
|
||||||
|
@ -47,24 +46,36 @@ final class The_Events_Calendar extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tribe category of wp_post
|
* Get the tags, including also the set categories from The Events Calendar.
|
||||||
*
|
*
|
||||||
* @return string|null tribe category if it exists
|
* @return ?array The array if tags,
|
||||||
*/
|
*/
|
||||||
public function get_tribe_category() {
|
public function get_tag(): ?array {
|
||||||
$categories = tribe_get_event_cat_slugs( $this->wp_object->ID );
|
$tags = array();
|
||||||
|
$category_ids = tribe_get_event_cat_ids();
|
||||||
if ( count( $categories ) === 0 ) {
|
if ( $category_ids ) {
|
||||||
return null;
|
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 $categories[0];
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the end time from the event object.
|
* Get the end time from the event object.
|
||||||
*/
|
*/
|
||||||
protected function get_end_time() {
|
public function get_end_time(): ?string {
|
||||||
|
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() );
|
||||||
}
|
}
|
||||||
|
@ -72,7 +83,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() {
|
public function get_start_time(): string {
|
||||||
$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() );
|
||||||
}
|
}
|
||||||
|
@ -82,21 +93,17 @@ final class The_Events_Calendar extends Event {
|
||||||
*
|
*
|
||||||
* @return string status of the event
|
* @return string status of the event
|
||||||
*/
|
*/
|
||||||
public function get_tribe_status() {
|
public function get_status(): ?string {
|
||||||
|
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
@ -111,32 +118,14 @@ 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.
|
||||||
*
|
*
|
||||||
* @return Place|array The place/venue if one is set.
|
* @return ?Place The place/venue if one is set.
|
||||||
*/
|
*/
|
||||||
public function get_location(): Place|null {
|
public function get_location(): ?Place {
|
||||||
// Get short handle for the venues.
|
// Get short handle for the venues.
|
||||||
$venues = $this->wp_object->venues;
|
$venues = $this->tribe_event->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 ) {
|
||||||
|
@ -181,23 +170,21 @@ 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->ID );
|
||||||
$location->set_name( $venue->post_title );
|
$location->set_name( $venue->post_title );
|
||||||
|
|
||||||
return $location;
|
return $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the default event transformers to_object function.
|
* Get the timezone of the event.
|
||||||
*
|
*
|
||||||
* This is the heart of the ActivityPub transformer.
|
* @return string The timezone string of the site.
|
||||||
*
|
|
||||||
* @return Event_Object
|
|
||||||
*/
|
*/
|
||||||
public function to_object(): Event_Object {
|
public function get_timezone(): string {
|
||||||
$activitypub_object = parent::to_object();
|
return $this->tribe_event->timezone;
|
||||||
|
|
||||||
return $activitypub_object;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,17 @@
|
||||||
/**
|
/**
|
||||||
* ActivityPub Transformer for the plugin Very Simple Event List.
|
* ActivityPub Transformer for the plugin Very Simple Event List.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Activitypub\Transformer;
|
namespace Event_Bridge_For_ActivityPub\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\Place;
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\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.
|
||||||
|
@ -27,23 +22,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
* @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.
|
||||||
|
@ -66,20 +44,23 @@ final class VS_Event_List extends Event_Transformer {
|
||||||
/**
|
/**
|
||||||
* Get the end time from the events metadata.
|
* Get the end time from the events metadata.
|
||||||
*/
|
*/
|
||||||
protected function get_end_time(): ?string {
|
public function get_end_time(): ?string {
|
||||||
if ( 'yes' === get_post_meta( $this->wp_object->ID, 'event-hide-end-time', true ) ) {
|
if ( 'yes' === get_post_meta( $this->wp_object->ID, 'event-hide-end-time', true ) ) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the end time from the events metadata.
|
* Get the end time from the events metadata.
|
||||||
*/
|
*/
|
||||||
protected function get_start_time(): string {
|
public 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 $start_time ? \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ) : null;
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $start_time );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,27 +99,15 @@ final class VS_Event_List extends Event_Transformer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a custom summary.
|
* Retrieves the excerpt text (may be HTML). Used for constructing the summary.
|
||||||
*
|
*
|
||||||
* It contains also the most important meta-information. The summary is often used when the
|
* @return ?string
|
||||||
* ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
|
|
||||||
*
|
|
||||||
* @return string $summary The custom event summary.
|
|
||||||
*/
|
*/
|
||||||
public function get_summary(): ?string {
|
protected function retrieve_excerpt(): ?string {
|
||||||
if ( $this->wp_object->excerpt ) {
|
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
|
||||||
$excerpt = $this->wp_object->post_excerpt;
|
return get_post_meta( $this->wp_object->ID, 'event-summary', true );
|
||||||
} elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
|
|
||||||
$excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
|
|
||||||
} else {
|
} else {
|
||||||
$excerpt = $this->get_content();
|
return parent::retrieve_excerpt();
|
||||||
}
|
}
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
140
includes/activitypub/transformer/class-wp-event-manager.php
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for the plugin Very Simple Event List.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event as Event_Transformer;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for events from the WordPress plugin 'Events Manager'
|
||||||
|
*
|
||||||
|
* @see https://wordpress.org/plugins/events-manager/
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class WP_Event_Manager extends Event_Transformer {
|
||||||
|
/**
|
||||||
|
* Returns whether the even is online
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function get_is_online() {
|
||||||
|
$is_online_text = get_post_meta( $this->wp_object->ID, '_event_online', true );
|
||||||
|
$is_online = false;
|
||||||
|
// Radio buttons.
|
||||||
|
if ( 'yes' === $is_online_text ) {
|
||||||
|
$is_online = true;
|
||||||
|
}
|
||||||
|
// Checkbox.
|
||||||
|
if ( '1' === $is_online_text ) {
|
||||||
|
$is_online = true;
|
||||||
|
}
|
||||||
|
return $is_online;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the event location.
|
||||||
|
*
|
||||||
|
* @return array The Place.
|
||||||
|
*/
|
||||||
|
public function get_location(): ?Place {
|
||||||
|
$location_name = get_post_meta( $this->wp_object->ID, '_event_location', true );
|
||||||
|
|
||||||
|
if ( $location_name ) {
|
||||||
|
$location = new Place();
|
||||||
|
$location->set_name( $location_name );
|
||||||
|
$location->set_sensitive( null );
|
||||||
|
$location->set_address( $location_name );
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the events metadata.
|
||||||
|
*
|
||||||
|
* @return ?string The events end-datetime if is set, null otherwise.
|
||||||
|
*/
|
||||||
|
public function get_end_time(): ?string {
|
||||||
|
$end_date = get_post_meta( $this->wp_object->ID, '_event_end_date', true );
|
||||||
|
if ( $end_date ) {
|
||||||
|
$end_datetime = new DateTime( $end_date );
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $end_datetime->getTimestamp() );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the end time from the events metadata.
|
||||||
|
*/
|
||||||
|
public function get_start_time(): string {
|
||||||
|
$start_date = get_post_meta( $this->wp_object->ID, '_event_start_date', true );
|
||||||
|
if ( ! is_numeric( $start_date ) ) {
|
||||||
|
$start_datetime = new DateTime( $start_date );
|
||||||
|
$start_timestamp = $start_datetime->getTimestamp();
|
||||||
|
} else {
|
||||||
|
$start_timestamp = (int) $start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
return \gmdate( 'Y-m-d\TH:i:s\Z', $start_timestamp );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the event link as an ActivityPub Link object, but as an associative array.
|
||||||
|
*
|
||||||
|
* @return ?array
|
||||||
|
*/
|
||||||
|
private function get_event_link_attachment(): ?array {
|
||||||
|
$event_link_url = get_post_meta( $this->wp_object->ID, '_event_video_url', true );
|
||||||
|
|
||||||
|
if ( str_starts_with( $event_link_url, 'http' ) ) {
|
||||||
|
return array(
|
||||||
|
'type' => 'Link',
|
||||||
|
'name' => \esc_html__( 'Video URL', 'event-bridge-for-activitypub' ),
|
||||||
|
'href' => \esc_url( $event_link_url ),
|
||||||
|
'mediaType' => 'text/html',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides/extends the get_attachments function to also add the event Link.
|
||||||
|
*/
|
||||||
|
protected function get_attachment() {
|
||||||
|
// Get attachments via parent function.
|
||||||
|
$attachments = parent::get_attachment();
|
||||||
|
|
||||||
|
// The first attachment is the featured image, make sure it is compatible with Mobilizon.
|
||||||
|
if ( count( $attachments ) ) {
|
||||||
|
$attachments[0]['type'] = 'Document';
|
||||||
|
$attachments[0]['name'] = 'Banner';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->get_event_link_attachment() ) {
|
||||||
|
$attachments[] = $this->get_event_link_attachment();
|
||||||
|
}
|
||||||
|
return $attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the events title/name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_name(): string {
|
||||||
|
return $this->wp_object->post_title;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,14 +4,17 @@
|
||||||
*
|
*
|
||||||
* 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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Admin;
|
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||||
|
|
||||||
use Activitypub_Event_Extensions\Plugins\Event_Plugin;
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for Event Plugin related admin notices.
|
* Class responsible for Event Plugin related admin notices.
|
||||||
|
@ -66,17 +69,25 @@ class Event_Plugin_Admin_Notices {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function do_admin_notice_post_type_not_activitypub_enabled(): void {
|
private function do_admin_notice_post_type_not_activitypub_enabled(): void {
|
||||||
$event_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $this->event_plugin::get_plugin_file() );
|
$all_plugins = get_plugins();
|
||||||
|
$event_plugin_file = $this->event_plugin::get_relative_plugin_file();
|
||||||
|
if ( isset( $all_plugins[ $event_plugin_file ]['Name'] ) ) {
|
||||||
|
$event_plugin_name = $all_plugins[ $event_plugin_file ]['Name'];
|
||||||
|
} elseif ( isset( get_mu_plugins()[ $event_plugin_file ]['Name'] ) ) {
|
||||||
|
$event_plugin_name = get_mu_plugins()[ $event_plugin_file ]['Name'];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$activitypub_plugin_data = get_plugin_data( ACTIVITYPUB_PLUGIN_FILE );
|
$activitypub_plugin_data = get_plugin_data( ACTIVITYPUB_PLUGIN_FILE );
|
||||||
$notice = sprintf(
|
$notice = sprintf(
|
||||||
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
|
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
|
||||||
_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-extensions'
|
'event-bridge-for-activitypub'
|
||||||
),
|
),
|
||||||
esc_html( $activitypub_plugin_data['Name'] ),
|
esc_html( $activitypub_plugin_data['Name'] ),
|
||||||
esc_html( $event_plugin_data['Name'] ),
|
esc_html( $event_plugin_name ),
|
||||||
admin_url( 'options-general.php?page=activitypub&tab=settings' )
|
admin_url( 'options-general.php?page=activitypub&tab=settings' )
|
||||||
);
|
);
|
||||||
$allowed_html = array(
|
$allowed_html = array(
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
*
|
*
|
||||||
* Notices for guiding to proper configuration of this plugin.
|
* Notices for guiding to proper configuration of this plugin.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Admin;
|
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for general admin notices.
|
* Class responsible for general admin notices.
|
||||||
|
@ -26,7 +29,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_EXTENSIONS_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-extensions#events-plugin-that-will-be-supported-at-first';
|
const EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub#events-plugin-that-will-be-supported-at-first';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allowed HTML for admin notices.
|
* Allowed HTML for admin notices.
|
||||||
|
@ -51,9 +54,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 Extensions to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.',
|
'For the Event Bridge for ActivityPub to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.',
|
||||||
'admin notice',
|
'admin notice',
|
||||||
'activitypub-event-extensions'
|
'event-bridge-for-activitypub'
|
||||||
),
|
),
|
||||||
esc_html( self::ACTIVITYPUB_PLUGIN_URL )
|
esc_html( self::ACTIVITYPUB_PLUGIN_URL )
|
||||||
);
|
);
|
||||||
|
@ -68,12 +71,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 extensions to work.',
|
'Please upgrade your <a href="%1$s">ActivityPub</a> plugin. At least version %2$s is required for the Event Bridge for ActivityPub to work.',
|
||||||
'admin notice',
|
'admin notice',
|
||||||
'activitypub-event-extensions'
|
'event-bridge-for-activitypub'
|
||||||
),
|
),
|
||||||
esc_html( self::ACTIVITYPUB_PLUGIN_URL ),
|
esc_html( self::ACTIVITYPUB_PLUGIN_URL ),
|
||||||
esc_html( ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION )
|
esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +89,30 @@ 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 Extensions</i> is of no use, because you do not have installed and activated a supported Event Plugin.
|
'The Plugin <i>Event Bridge for ActivityPub</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-extensions'
|
'event-bridge-for-activitypub'
|
||||||
),
|
),
|
||||||
esc_html( self::ACTIVITYPUB_EVENT_EXTENSIONS_SUPPORTED_EVENT_PLUGINS_URL )
|
esc_html( self::EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning to fix status issues first.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_admin_notice_status_not_ok(): string {
|
||||||
|
return sprintf(
|
||||||
|
/* translators: 1: An URL to the list of supported event plugins. */
|
||||||
|
_x(
|
||||||
|
'The Plugin <i>Event Bridge for ActivityPub</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>.',
|
||||||
|
'admin notice',
|
||||||
|
'event-bridge-for-activitypub'
|
||||||
|
),
|
||||||
|
esc_html( self::EVENT_BRIDGE_FOR_ACTIVITYPUB_SUPPORTED_EVENT_PLUGINS_URL )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
187
includes/admin/class-health-check.php
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Health_Check class.
|
||||||
|
*
|
||||||
|
* @package Activitypub_Event_Bridge
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||||
|
|
||||||
|
use Activitypub\Transformer\Factory as Transformer_Factory;
|
||||||
|
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin;
|
||||||
|
use Event_Bridge_For_ActivityPub\Setup;
|
||||||
|
use WP_Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Health_Check Class.
|
||||||
|
*/
|
||||||
|
class Health_Check {
|
||||||
|
/**
|
||||||
|
* Initialize health checks.
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
\add_filter( 'site_status_tests', array( self::class, 'add_tests' ) );
|
||||||
|
\add_filter( 'debug_information', array( self::class, 'add_debug_information' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add tests to the Site Health Check.
|
||||||
|
*
|
||||||
|
* @param array $tests The test array.
|
||||||
|
*
|
||||||
|
* @return array The filtered test array.
|
||||||
|
*/
|
||||||
|
public static function add_tests( $tests ) {
|
||||||
|
$tests['direct']['event_bridge_for_activitypub_test'] = array(
|
||||||
|
'label' => __( 'ActivityPub Event Transformer Test', 'event-bridge-for-activitypub' ),
|
||||||
|
'test' => array( self::class, 'test_event_transformation' ),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The the transformation of the most recent event posts.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function test_event_transformation() {
|
||||||
|
$result = array(
|
||||||
|
'label' => \__( 'Transformation of Events to a valid ActivityStreams representation.', 'event-bridge-for-activitypub' ),
|
||||||
|
'status' => 'good',
|
||||||
|
'badge' => array(
|
||||||
|
'label' => \__( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ),
|
||||||
|
'color' => 'green',
|
||||||
|
),
|
||||||
|
'description' => \sprintf(
|
||||||
|
'<p>%s</p>',
|
||||||
|
\__( 'The transformation of your most recent events was successful.', 'event-bridge-for-activitypub' )
|
||||||
|
),
|
||||||
|
'actions' => '',
|
||||||
|
'test' => 'test_event_transformation',
|
||||||
|
);
|
||||||
|
|
||||||
|
$check = self::transform_most_recent_event_posts();
|
||||||
|
|
||||||
|
if ( true === $check ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['status'] = 'critical';
|
||||||
|
$result['label'] = \__( 'One or more of your most recent events failed to transform to ActivityPub', 'event-bridge-for-activitypub' );
|
||||||
|
$result['badge']['color'] = 'red';
|
||||||
|
$result['description'] = \sprintf(
|
||||||
|
'<p>%s</p>',
|
||||||
|
$check->get_error_message()
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if right transformer gets applied.
|
||||||
|
*
|
||||||
|
* @param Event_Plugin $event_plugin The event plugin definition.
|
||||||
|
*
|
||||||
|
* @return bool True if the check passed.
|
||||||
|
*/
|
||||||
|
public static function test_if_event_transformer_is_used( $event_plugin ) {
|
||||||
|
// Get a (random) event post.
|
||||||
|
$event_posts = self::get_most_recent_event_posts( $event_plugin->get_post_type(), 1 );
|
||||||
|
|
||||||
|
// If no post is found, we can not do this test.
|
||||||
|
if ( ! $event_posts || is_wp_error( $event_posts ) || empty( $event_posts ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = Transformer_Factory::get_transformer( $event_posts[0] );
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$desired_transformer_class = $event_plugin::get_activitypub_event_transformer_class();
|
||||||
|
if ( $transformer instanceof $desired_transformer_class ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the most recently published event posts of a certain event post type.
|
||||||
|
*
|
||||||
|
* @param ?string $event_post_type The post type of the events.
|
||||||
|
* @param ?int $number_of_posts The maximum number of events to return.
|
||||||
|
*
|
||||||
|
* @return WP_Post[]|false Array of event posts, or false if none are found.
|
||||||
|
*/
|
||||||
|
public static function get_most_recent_event_posts( $event_post_type = null, $number_of_posts = 5 ) {
|
||||||
|
if ( ! $event_post_type ) {
|
||||||
|
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$active_event_plugin = reset( $active_event_plugins );
|
||||||
|
$event_post_type = $active_event_plugin->get_post_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'numberposts' => $number_of_posts,
|
||||||
|
'category' => 0,
|
||||||
|
'orderby' => 'date',
|
||||||
|
'order' => 'DESC',
|
||||||
|
'include' => array(),
|
||||||
|
'exclude' => array(),
|
||||||
|
'meta_key' => '',
|
||||||
|
'meta_value' => '',
|
||||||
|
'post_type' => $event_post_type,
|
||||||
|
'suppress_filters' => true,
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = new WP_Query();
|
||||||
|
return $query->query( $args );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the most recent event posts.
|
||||||
|
*/
|
||||||
|
public static function transform_most_recent_event_posts() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves information like name and version from active event plugins.
|
||||||
|
*/
|
||||||
|
private static function get_info_about_active_event_plugins() {
|
||||||
|
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$info = array();
|
||||||
|
foreach ( $active_event_plugins as $active_event_plugin ) {
|
||||||
|
$event_plugin_file = $active_event_plugin->get_relative_plugin_file();
|
||||||
|
$event_plugin_data = \get_plugin_data( $event_plugin_file );
|
||||||
|
$event_plugin_name = isset( $event_plugin_data['Plugin Name'] ) ? $event_plugin_data['Plugin Name'] : 'Name not found';
|
||||||
|
$event_plugin_version = isset( $event_plugin_version['Plugin Version'] ) ? $event_plugin_version['Plugin Version'] : 'Version not found';
|
||||||
|
|
||||||
|
$info[] = array(
|
||||||
|
'event_plugin_name' => $event_plugin_name,
|
||||||
|
'event_plugin_version' => $event_plugin_version,
|
||||||
|
'event_plugin_file' => $event_plugin_file,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static function for generating site debug data when required.
|
||||||
|
*
|
||||||
|
* @param array $info The debug information to be added to the core information page.
|
||||||
|
* @return array The extended information.
|
||||||
|
*/
|
||||||
|
public static function add_debug_information( $info ) {
|
||||||
|
$info['event_bridge_for_activitypub'] = array(
|
||||||
|
'label' => __( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ),
|
||||||
|
'fields' => array(
|
||||||
|
'plugin_version' => array(
|
||||||
|
'label' => __( 'Plugin Version', 'event-bridge-for-activitypub' ),
|
||||||
|
'value' => EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION,
|
||||||
|
'private' => true,
|
||||||
|
),
|
||||||
|
'active_event_plugins' => self::get_info_about_active_event_plugins(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,32 +3,32 @@
|
||||||
* General settings class.
|
* General settings class.
|
||||||
*
|
*
|
||||||
* 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 Event Bridge for ActivityPub Plugin, providing options for configuring various general settings.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Admin;
|
namespace Event_Bridge_For_ActivityPub\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 Event_Bridge_For_ActivityPub\Integrations\Event_Plugin;
|
||||||
|
use Event_Bridge_For_ActivityPub\Setup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for the ActivityPub Event Extension related Settings.
|
* Class responsible for the Event Bridge for ActivityPub related Settings.
|
||||||
*
|
*
|
||||||
* Class which handles the "General" settings page for the ActivityPub Event Extension Plugin,
|
* Class which handles the "General" settings page for the Event Bridge for ActivityPub Plugin,
|
||||||
* providing options for configuring various general settings.
|
* providing options for configuring various general settings.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Settings_Page {
|
class Settings_Page {
|
||||||
const STATIC = 'Activitypub_Event_Extensions\Admin\Settings_Page';
|
const STATIC = 'Event_Bridge_For_ActivityPub\Admin\Settings_Page';
|
||||||
|
|
||||||
const SETTINGS_SLUG = 'activitypub-event-extensions';
|
const SETTINGS_SLUG = 'event-bridge-for-activitypub';
|
||||||
/**
|
/**
|
||||||
* Warning if the plugin is Active and the ActivityPub plugin is not.
|
* Warning if the plugin is Active and the ActivityPub plugin is not.
|
||||||
*
|
*
|
||||||
|
@ -36,11 +36,11 @@ class Settings_Page {
|
||||||
*/
|
*/
|
||||||
public static function admin_menu(): void {
|
public static function admin_menu(): void {
|
||||||
\add_options_page(
|
\add_options_page(
|
||||||
'Activitypub Event Extension',
|
'Event Bridge for ActivityPub',
|
||||||
__( 'ActivityPub Events', 'activitypub-event-extensions' ),
|
__( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
self::SETTINGS_SLUG,
|
self::SETTINGS_SLUG,
|
||||||
array( self::STATIC, 'settings_page' )
|
array( self::STATIC, 'settings_page' ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,21 +89,44 @@ class Settings_Page {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function settings_page(): void {
|
public static function settings_page(): void {
|
||||||
$plugin_setup = Setup::get_instance();
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
if ( empty( $_GET['tab'] ) ) {
|
||||||
$event_plugins = $plugin_setup->get_active_event_plugins();
|
$tab = 'welcome';
|
||||||
|
} else {
|
||||||
$event_terms = array();
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
$tab = sanitize_key( $_GET['tab'] );
|
||||||
foreach ( $event_plugins as $event_plugin ) {
|
|
||||||
$event_terms = array_merge( $event_terms, self::get_event_terms( $event_plugin ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array(
|
// Fallback to always re-scan active event plugins, when user visits admin area of this plugin.
|
||||||
'slug' => self::SETTINGS_SLUG,
|
Setup::get_instance()->redetect_active_event_plugins();
|
||||||
'event_terms' => $event_terms,
|
|
||||||
);
|
|
||||||
|
|
||||||
\load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings.php', true, $args );
|
switch ( $tab ) {
|
||||||
|
case 'settings':
|
||||||
|
$plugin_setup = Setup::get_instance();
|
||||||
|
|
||||||
|
$event_plugins = $plugin_setup->get_active_event_plugins();
|
||||||
|
|
||||||
|
$event_terms = array();
|
||||||
|
|
||||||
|
foreach ( $event_plugins as $event_plugin ) {
|
||||||
|
$event_terms = array_merge( $event_terms, self::get_event_terms( $event_plugin ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'slug' => self::SETTINGS_SLUG,
|
||||||
|
'event_terms' => $event_terms,
|
||||||
|
);
|
||||||
|
|
||||||
|
\load_template( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . 'templates/settings.php', true, $args );
|
||||||
|
break;
|
||||||
|
case 'welcome':
|
||||||
|
default:
|
||||||
|
wp_enqueue_script( 'plugin-install' );
|
||||||
|
add_thickbox();
|
||||||
|
wp_enqueue_script( 'updates' );
|
||||||
|
|
||||||
|
\load_template( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . 'templates/welcome.php', true );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Class responsible for autoloading ActivityPub Event Extensions class files.
|
* Class responsible for autoloading Event Bridge for ActivityPub 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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions;
|
namespace Event_Bridge_For_ActivityPub;
|
||||||
|
|
||||||
// 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_EXTENSIONS_PLUGIN_DIR . '/includes/';
|
$base_dir = EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/';
|
||||||
$base = 'Activitypub_Event_Extensions\\';
|
$base = 'Event_Bridge_For_ActivityPub\\';
|
||||||
|
|
||||||
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 );
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
* General settings class.
|
* General settings class.
|
||||||
*
|
*
|
||||||
* 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 Event Bridge for ActivityPub Plugin, providing options for configuring various general settings.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions;
|
namespace Event_Bridge_For_ActivityPub;
|
||||||
|
|
||||||
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 @@ defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Settings {
|
class Settings {
|
||||||
const SETTINGS_SLUG = 'activitypub-event-extensions';
|
const SETTINGS_SLUG = 'event-bridge-for-activitypub';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default ActivityPub event category.
|
* The default ActivityPub event category.
|
||||||
|
@ -34,17 +34,17 @@ class Settings {
|
||||||
const DEFAULT_EVENT_CATEGORY = 'MEETING';
|
const DEFAULT_EVENT_CATEGORY = 'MEETING';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the settings for the ActivityPub Event Extensions plugin.
|
* Register the settings for the Event Bridge for ActivityPub plugin.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function register_settings(): void {
|
public static function register_settings(): void {
|
||||||
\register_setting(
|
\register_setting(
|
||||||
'activitypub-event-extensions',
|
'event-bridge-for-activitypub',
|
||||||
'activitypub_event_extensions_default_event_category',
|
'event_bridge_for_activitypub_default_event_category',
|
||||||
array(
|
array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => \__( 'Define your own custom post template', 'activitypub' ),
|
'description' => \__( 'Define your own custom post template', 'event-bridge-for-activitypub' ),
|
||||||
'show_in_rest' => true,
|
'show_in_rest' => true,
|
||||||
'default' => self::DEFAULT_EVENT_CATEGORY,
|
'default' => self::DEFAULT_EVENT_CATEGORY,
|
||||||
'sanitize_callback' => array( self::class, 'sanitize_mapped_event_category' ),
|
'sanitize_callback' => array( self::class, 'sanitize_mapped_event_category' ),
|
||||||
|
@ -52,15 +52,47 @@ class Settings {
|
||||||
);
|
);
|
||||||
|
|
||||||
\register_setting(
|
\register_setting(
|
||||||
'activitypub-event-extensions',
|
'event-bridge-for-activitypub',
|
||||||
'activitypub_event_extensions_event_category_mappings',
|
'event_bridge_for_activitypub_event_category_mappings',
|
||||||
array(
|
array(
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => \__( 'Define your own custom post template', 'activitypub' ),
|
'description' => \__( 'Define your own custom post template', 'event-bridge-for-activitypub' ),
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => array( self::class, 'sanitize_event_category_mappings' ),
|
'sanitize_callback' => array( self::class, 'sanitize_event_category_mappings' ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
\register_setting(
|
||||||
|
'event-bridge-for-activitypub',
|
||||||
|
'event_bridge_for_activitypub_initially_activated',
|
||||||
|
array(
|
||||||
|
'type' => 'boolean',
|
||||||
|
'description' => \__( 'Whether the plugin just got activated for the first time.', 'event-bridge-for-activitypub' ),
|
||||||
|
'default' => 1,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
\register_setting(
|
||||||
|
'event-bridge-for-activitypub',
|
||||||
|
'event_bridge_for_activitypub_summary_type',
|
||||||
|
array(
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => \__( 'Summary type to use for ActivityStreams', 'event-bridge-for-activitypub' ),
|
||||||
|
'show_in_rest' => true,
|
||||||
|
'default' => 'preset',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
\register_setting(
|
||||||
|
'event-bridge-for-activitypub',
|
||||||
|
'event_bridge_for_activitypub_custom_summary',
|
||||||
|
array(
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => \__( 'Define your own custom summary template for events', 'event-bridge-for-activitypub' ),
|
||||||
|
'show_in_rest' => true,
|
||||||
|
'default' => EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY,
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Class responsible for initializing ActivityPub Event Extensions.
|
* Class responsible for initializing Event Bridge for ActivityPub.
|
||||||
*
|
*
|
||||||
* 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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @license AGPL-3.0-or-later
|
* @license AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions;
|
namespace Event_Bridge_For_ActivityPub;
|
||||||
|
|
||||||
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 Event_Bridge_For_ActivityPub\Admin\Event_Plugin_Admin_Notices;
|
||||||
|
use Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices;
|
||||||
|
use Event_Bridge_For_ActivityPub\Admin\Health_Check;
|
||||||
|
use Event_Bridge_For_ActivityPub\Admin\Settings_Page;
|
||||||
|
use Event_Bridge_For_ActivityPub\Integrations\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 Extensions.
|
* This class is responsible for initializing Event Bridge for ActivityPub.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@ -63,12 +64,11 @@ 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_EXTENSIONS_PLUGIN_FILE );
|
// deactivate_plugins( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE );
|
||||||
// return;
|
// return;
|
||||||
// }.
|
// }.
|
||||||
$this->active_event_plugins = self::detect_active_event_plugins();
|
|
||||||
$this->activitypub_plugin_version = self::get_activitypub_plugin_version();
|
$this->activitypub_plugin_version = self::get_activitypub_plugin_version();
|
||||||
$this->setup_hooks();
|
add_action( 'plugins_loaded', array( $this, 'setup_hooks' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,8 +105,7 @@ class Setup {
|
||||||
if ( defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) {
|
if ( defined( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) {
|
||||||
return constant( 'ACTIVITYPUB_PLUGIN_VERSION' );
|
return constant( 'ACTIVITYPUB_PLUGIN_VERSION' );
|
||||||
}
|
}
|
||||||
$version = get_file_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php', array( 'Version' ) )[0];
|
return '0.0.0';
|
||||||
return $version ?? '0.0.0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,29 +123,58 @@ class Setup {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private const EVENT_PLUGIN_CLASSES = array(
|
private const EVENT_PLUGIN_CLASSES = array(
|
||||||
'\Activitypub_Event_Extensions\Plugins\Events_Manager',
|
'\Event_Bridge_For_ActivityPub\Integrations\Events_Manager',
|
||||||
'\Activitypub_Event_Extensions\Plugins\GatherPress',
|
'\Event_Bridge_For_ActivityPub\Integrations\GatherPress',
|
||||||
'\Activitypub_Event_Extensions\Plugins\The_Events_Calendar',
|
'\Event_Bridge_For_ActivityPub\Integrations\The_Events_Calendar',
|
||||||
'\Activitypub_Event_Extensions\Plugins\VS_Event_List',
|
'\Event_Bridge_For_ActivityPub\Integrations\VS_Event_List',
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\WP_Event_Manager',
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\Eventin',
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\Modern_Events_Calendar_Lite',
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\EventPrime',
|
||||||
|
'\Event_Bridge_For_ActivityPub\Integrations\Event_Organiser',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the re-scan for active event plugins without using the cached transient.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function redetect_active_event_plugins(): void {
|
||||||
|
delete_transient( 'event_bridge_for_activitypub_active_event_plugins' );
|
||||||
|
$this->detect_active_event_plugins();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that checks for supported activated event plugins.
|
* Function that checks for supported activated event plugins.
|
||||||
*
|
*
|
||||||
* @return array List of supported event plugins as keys from the SUPPORTED_EVENT_PLUGINS const.
|
* @return array List of supported event plugins as keys from the SUPPORTED_EVENT_PLUGINS const.
|
||||||
*/
|
*/
|
||||||
public static function detect_active_event_plugins(): array {
|
public function detect_active_event_plugins(): array {
|
||||||
$active_event_plugins = array();
|
$active_event_plugins = get_transient( 'event_bridge_for_activitypub_active_event_plugins' );
|
||||||
|
|
||||||
|
if ( $active_event_plugins ) {
|
||||||
|
$this->active_event_plugins = $active_event_plugins;
|
||||||
|
return $active_event_plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'get_plugins' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$all_plugins = array_merge( get_plugins(), get_mu_plugins() );
|
||||||
|
|
||||||
|
$active_event_plugins = array();
|
||||||
foreach ( self::EVENT_PLUGIN_CLASSES as $event_plugin_class ) {
|
foreach ( self::EVENT_PLUGIN_CLASSES as $event_plugin_class ) {
|
||||||
if ( ! class_exists( $event_plugin_class ) || ! method_exists( $event_plugin_class, 'get_plugin_file' ) ) {
|
$event_plugin_file = call_user_func( array( $event_plugin_class, 'get_relative_plugin_file' ) );
|
||||||
|
if ( ! $event_plugin_file ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$event_plugin_file = call_user_func( array( $event_plugin_class, 'get_plugin_file' ) );
|
if ( array_key_exists( $event_plugin_file, $all_plugins ) && \is_plugin_active( $event_plugin_file ) ) {
|
||||||
if ( \is_plugin_active( $event_plugin_file ) ) {
|
$active_event_plugins[ $event_plugin_file ] = new $event_plugin_class();
|
||||||
$active_event_plugins[] = new $event_plugin_class();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_transient( 'event_bridge_for_activitypub_active_event_plugins', $active_event_plugins );
|
||||||
|
$this->active_event_plugins = $active_event_plugins;
|
||||||
return $active_event_plugins;
|
return $active_event_plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,28 +187,32 @@ class Setup {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function setup_hooks(): void {
|
public function setup_hooks(): void {
|
||||||
register_activation_hook( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE, array( $this, 'activate' ) );
|
$this->detect_active_event_plugins();
|
||||||
|
|
||||||
|
register_activation_hook( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE, array( $this, 'activate' ) );
|
||||||
|
|
||||||
|
add_action( 'activated_plugin', array( $this, 'redetect_active_event_plugins' ) );
|
||||||
|
add_action( 'deactivated_plugin', array( $this, 'redetect_active_event_plugins' ) );
|
||||||
|
|
||||||
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' ) );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_styles' ) );
|
||||||
|
add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) );
|
||||||
|
add_filter(
|
||||||
|
'plugin_action_links_' . EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_BASENAME,
|
||||||
|
array( Settings_Page::class, 'settings_link' )
|
||||||
|
);
|
||||||
|
|
||||||
// If we don't have any active event plugins, or the ActivityPub plugin is not enabled, abort here.
|
// If we don't have any active event plugins, or the ActivityPub plugin is not enabled, abort here.
|
||||||
if ( empty( $this->active_event_plugins ) || ! $this->activitypub_plugin_is_active ) {
|
if ( empty( $this->active_event_plugins ) || ! $this->activitypub_plugin_is_active ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_styles' ) );
|
add_action( 'init', array( Health_Check::class, 'init' ) );
|
||||||
|
|
||||||
add_action( 'admin_menu', array( Settings_Page::class, 'admin_menu' ) );
|
|
||||||
|
|
||||||
add_filter(
|
|
||||||
'plugin_action_links_' . ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_BASENAME,
|
|
||||||
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_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
|
if ( ! version_compare( $this->activitypub_plugin_version, EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,15 +227,25 @@ 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-extensions' ) ) {
|
if ( false !== strpos( $hook_suffix, 'event-bridge-for-activitypub' ) ) {
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'activitypub-event-extensions-admin-styles',
|
'event-bridge-for-activitypub-admin-styles',
|
||||||
plugins_url(
|
plugins_url(
|
||||||
'assets/css/activitypub-event-extensions-admin.css',
|
'assets/css/event-bridge-for-activitypub-admin.css',
|
||||||
ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE
|
EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_VERSION
|
EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION
|
||||||
|
);
|
||||||
|
wp_enqueue_script(
|
||||||
|
'event-bridge-for-activitypub-admin-script',
|
||||||
|
plugins_url(
|
||||||
|
'assets/js/event-bridge-for-activitypub-admin.js',
|
||||||
|
EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE
|
||||||
|
),
|
||||||
|
array( 'jquery' ),
|
||||||
|
EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,15 +260,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_Extensions\Admin\General_Admin_Notices', 'activitypub_plugin_not_enabled' ), 10, 1 );
|
add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'activitypub_plugin_not_enabled' ), 10, 1 );
|
||||||
}
|
}
|
||||||
if ( ! version_compare( $this->activitypub_plugin_version, ACTIVITYPUB_EVENT_EXTENSIONS_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
|
if ( ! version_compare( $this->activitypub_plugin_version, EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION ) ) {
|
||||||
// The ActivityPub plugin is too old.
|
// The ActivityPub plugin is too old.
|
||||||
add_action( 'admin_notices', array( 'Activitypub_Event_Extensions\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 );
|
add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'activitypub_plugin_version_too_old' ), 10, 1 );
|
||||||
}
|
}
|
||||||
if ( empty( $this->active_event_plugins ) ) {
|
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_Extensions\Admin\General_Admin_Notices', 'no_supported_event_plugin_active' ), 10, 1 );
|
add_action( 'admin_notices', array( 'Event_Bridge_For_ActivityPub\Admin\General_Admin_Notices', 'no_supported_event_plugin_active' ), 10, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +281,7 @@ class Setup {
|
||||||
*
|
*
|
||||||
* @return \Activitypub\Transformer\Base|null
|
* @return \Activitypub\Transformer\Base|null
|
||||||
*/
|
*/
|
||||||
public function register_activitypub_event_transformer( $transformer, $wp_object, $object_class ): \Activitypub\Transformer\Base|null {
|
public function register_activitypub_event_transformer( $transformer, $wp_object, $object_class ): ?\Activitypub\Transformer\Base {
|
||||||
// If the current WordPress object is not a post (e.g., a WP_Comment), don't change the transformer.
|
// If the current WordPress object is not a post (e.g., a WP_Comment), don't change the transformer.
|
||||||
if ( 'WP_Post' !== $object_class ) {
|
if ( 'WP_Post' !== $object_class ) {
|
||||||
return $transformer;
|
return $transformer;
|
||||||
|
@ -272,24 +314,26 @@ 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 Extensions plugin.
|
* Activates the Event Bridge for ActivityPub plugin.
|
||||||
*
|
*
|
||||||
* This method handles the activation of the ActivityPub Event Extensions plugin.
|
* This method handles the activation of the Event Bridge for ActivityPub plugin.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*
|
* @see register_activation_hook()
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function activate(): void {
|
public function activate(): void {
|
||||||
|
$this->redetect_active_event_plugins();
|
||||||
// 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_EXTENSIONS_PLUGIN_FILE ) );
|
deactivate_plugins( plugin_basename( EVENT_BRIDGE_FOR_ACTIVITYPUB_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 ),
|
||||||
|
@ -299,7 +343,7 @@ class Setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $this->active_event_plugins ) ) {
|
if ( empty( $this->active_event_plugins ) ) {
|
||||||
deactivate_plugins( plugin_basename( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ) );
|
deactivate_plugins( plugin_basename( EVENT_BRIDGE_FOR_ACTIVITYPUB_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 ),
|
||||||
|
|
47
includes/event-categories.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* File responsible for defining the event category strings.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub;
|
||||||
|
|
||||||
|
define(
|
||||||
|
'EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES',
|
||||||
|
array(
|
||||||
|
'ARTS' => __( 'Arts', 'event-bridge-for-activitypub' ),
|
||||||
|
'BOOK_CLUBS' => __( 'Book clubs', 'event-bridge-for-activitypub' ),
|
||||||
|
'BUSINESS' => __( 'Business', 'event-bridge-for-activitypub' ),
|
||||||
|
'CAUSES' => __( 'Causes', 'event-bridge-for-activitypub' ),
|
||||||
|
'COMEDY' => __( 'Comedy', 'event-bridge-for-activitypub' ),
|
||||||
|
'CRAFTS' => __( 'Crafts', 'event-bridge-for-activitypub' ),
|
||||||
|
'FOOD_DRINK' => __( 'Food & Drink', 'event-bridge-for-activitypub' ),
|
||||||
|
'HEALTH' => __( 'Health', 'event-bridge-for-activitypub' ),
|
||||||
|
'MUSIC' => __( 'Music', 'event-bridge-for-activitypub' ),
|
||||||
|
'AUTO_BOAT_AIR' => __( 'Auto, boat and air', 'event-bridge-for-activitypub' ),
|
||||||
|
'COMMUNITY' => __( 'Community', 'event-bridge-for-activitypub' ),
|
||||||
|
'FAMILY_EDUCATION' => __( 'Family & Education', 'event-bridge-for-activitypub' ),
|
||||||
|
'FASHION_BEAUTY' => __( 'Fashion & Beauty', 'event-bridge-for-activitypub' ),
|
||||||
|
'FILM_MEDIA' => __( 'Film & Media', 'event-bridge-for-activitypub' ),
|
||||||
|
'GAMES' => __( 'Games', 'event-bridge-for-activitypub' ),
|
||||||
|
'LANGUAGE_CULTURE' => __( 'Language & Culture', 'event-bridge-for-activitypub' ),
|
||||||
|
'LEARNING' => __( 'Learning', 'event-bridge-for-activitypub' ),
|
||||||
|
'LGBTQ' => __( 'LGBTQ', 'event-bridge-for-activitypub' ),
|
||||||
|
'MOVEMENTS_POLITICS' => __( 'Movements and politics', 'event-bridge-for-activitypub' ),
|
||||||
|
'NETWORKING' => __( 'Networking', 'event-bridge-for-activitypub' ),
|
||||||
|
'PARTY' => __( 'Party', 'event-bridge-for-activitypub' ),
|
||||||
|
'PERFORMING_VISUAL_ARTS' => __( 'Performing & Visual Arts', 'event-bridge-for-activitypub' ),
|
||||||
|
'PETS' => __( 'Pets', 'event-bridge-for-activitypub' ),
|
||||||
|
'PHOTOGRAPHY' => __( 'Photography', 'event-bridge-for-activitypub' ),
|
||||||
|
'OUTDOORS_ADVENTURE' => __( 'Outdoors & Adventure', 'event-bridge-for-activitypub' ),
|
||||||
|
'SPIRITUALITY_RELIGION_BELIEFS' => __( 'Spirituality, Religion & Beliefs', 'event-bridge-for-activitypub' ),
|
||||||
|
'SCIENCE_TECH' => __( 'Science & Tech', 'event-bridge-for-activitypub' ),
|
||||||
|
'SPORTS' => __( 'Sports', 'event-bridge-for-activitypub' ),
|
||||||
|
'THEATRE' => __( 'Theatre', 'event-bridge-for-activitypub' ),
|
||||||
|
'MEETING' => __( 'Meeting', 'event-bridge-for-activitypub' ), // Default value in federation.
|
||||||
|
'DEFAULT' => __( 'Default', 'event-bridge-for-activitypub' ), // Internal default for overrides.
|
||||||
|
),
|
||||||
|
);
|
69
includes/integrations/class-event-organiser.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Event Organiser.
|
||||||
|
*
|
||||||
|
* Defines all the necessary meta information for the Event Organiser plugin.
|
||||||
|
*
|
||||||
|
* @link https://wordpress.org/plugins/event-organiser/
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a supported event plugin.
|
||||||
|
*
|
||||||
|
* This interface defines which information is necessary for a supported event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Event_Organiser extends Event_Plugin {
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_relative_plugin_file(): string {
|
||||||
|
return 'event-organiser/event-organiser.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
return 'event';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page urls.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'event-organiser' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ActivityPub transformer class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_activitypub_transformer_class_name(): string {
|
||||||
|
return 'Event_Organiser';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'event-category';
|
||||||
|
}
|
||||||
|
}
|
|
@ -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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Plugins;
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer;
|
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event as Event_Transformer;
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
@ -24,11 +24,11 @@ defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
abstract class Event_Plugin {
|
abstract class Event_Plugin {
|
||||||
/**
|
/**
|
||||||
* Returns the full plugin file.
|
* Returns the plugin file relative to the plugins dir.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract public static function get_plugin_file(): string;
|
abstract public static function get_relative_plugin_file(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the event post type of the plugin.
|
* Returns the event post type of the plugin.
|
||||||
|
@ -45,12 +45,24 @@ abstract class Event_Plugin {
|
||||||
abstract public static function get_event_category_taxonomy(): string;
|
abstract public static function get_event_category_taxonomy(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the main settings page of the plugin.
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
*
|
*
|
||||||
* @return string The settings page url.
|
* @return array The IDs of one or several admin/settings pages.
|
||||||
*/
|
*/
|
||||||
public static function get_settings_page(): string {
|
public static function get_settings_pages(): array {
|
||||||
return '';
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plugins name from the main plugin-file's top-level-file-comment.
|
||||||
|
*/
|
||||||
|
final public static function get_plugin_name(): string {
|
||||||
|
$all_plugins = array_merge( get_plugins(), get_mu_plugins() );
|
||||||
|
if ( isset( $all_plugins[ static::get_relative_plugin_file() ]['Name'] ) ) {
|
||||||
|
return $all_plugins[ static::get_relative_plugin_file() ]['Name'];
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +74,7 @@ abstract class Event_Plugin {
|
||||||
|
|
||||||
// Check if we are on a edit page for the event, or on the settings page of the event plugin.
|
// Check if we are on a edit page for the event, or on the settings page of the event plugin.
|
||||||
$is_event_plugins_edit_page = 'edit' === $screen->base && static::get_post_type() === $screen->post_type;
|
$is_event_plugins_edit_page = 'edit' === $screen->base && static::get_post_type() === $screen->post_type;
|
||||||
$is_event_plugins_settings_page = static::get_settings_page() === $screen->id;
|
$is_event_plugins_settings_page = in_array( $screen->id, static::get_settings_pages(), true );
|
||||||
|
|
||||||
return $is_event_plugins_edit_page || $is_event_plugins_settings_page;
|
return $is_event_plugins_edit_page || $is_event_plugins_settings_page;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +83,6 @@ abstract class Event_Plugin {
|
||||||
* Returns the Activitypub transformer for the event plugins event post type.
|
* Returns the Activitypub transformer for the event plugins event post type.
|
||||||
*/
|
*/
|
||||||
public static function get_activitypub_event_transformer_class(): string {
|
public static function get_activitypub_event_transformer_class(): string {
|
||||||
return str_replace( 'Plugins', 'Activitypub\Transformer', static::class );
|
return str_replace( 'Integrations', 'Activitypub\Transformer', static::class );
|
||||||
}
|
}
|
||||||
}
|
}
|
60
includes/integrations/class-eventin.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* The Events Calendar.
|
||||||
|
*
|
||||||
|
* Defines all the necessary meta information for the events calendar.
|
||||||
|
*
|
||||||
|
* @link https://wordpress.org/plugins/the-events-calendar/
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a supported event plugin.
|
||||||
|
*
|
||||||
|
* This interface defines which information is necessary for a supported event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Eventin extends Event_plugin {
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_relative_plugin_file(): string {
|
||||||
|
return 'wp-event-solution/eventin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
return 'etn';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page url.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'eventin' ); // Base always is wp-admin/admin.php?page=eventin.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'etn_category';
|
||||||
|
}
|
||||||
|
}
|
221
includes/integrations/class-eventprime.php
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* EventPrime – Events Calendar, Bookings and Tickets
|
||||||
|
*
|
||||||
|
* @link https://wordpress.org/plugins/eventprime-event-calendar-management/
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
|
use Activitypub\Signature;
|
||||||
|
use Eventprime_Basic_Functions;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines which information is necessary for the EventPrime event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class EventPrime extends Event_Plugin {
|
||||||
|
/**
|
||||||
|
* Add filter for the template inclusion.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
\add_filter( 'template_include', array( self::class, 'render_activitypub_template' ), 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_relative_plugin_file(): string {
|
||||||
|
return 'eventprime-event-calendar-management/event-prime.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
return 'em_event';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page urls.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'ep-settings' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ActivityPub transformer class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_activitypub_transformer_class_name(): string {
|
||||||
|
return 'EventPrime';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'em_event_type';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the current request is an EventPrime ActivityPub request.
|
||||||
|
*
|
||||||
|
* Forked from https://github.com/Automattic/wordpress-activitypub/blob/trunk/includes/functions.php
|
||||||
|
* the function is_activitypub_request.
|
||||||
|
*/
|
||||||
|
private static function is_eventprime_activitypub_request() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ActivityPub requests are currently only made for
|
||||||
|
* author archives, singular posts, and the homepage.
|
||||||
|
*/
|
||||||
|
if ( ! \is_author() && ! \is_singular() && ! \is_home() && ! defined( '\REST_REQUEST' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the current post type supports ActivityPub.
|
||||||
|
if ( \is_singular() ) {
|
||||||
|
$queried_object = \get_queried_object();
|
||||||
|
|
||||||
|
if ( ! $queried_object instanceof \WP_Post ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '[em_event]' !== $queried_object->post_content && '[em_events]' !== $queried_object->post_content ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if header already sent.
|
||||||
|
if ( ! \headers_sent() && ACTIVITYPUB_SEND_VARY_HEADER ) {
|
||||||
|
// Send Vary header for Accept header.
|
||||||
|
\header( 'Vary: Accept' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// One can trigger an ActivityPub request by adding ?activitypub to the URL.
|
||||||
|
if ( isset( $wp_query->query_vars['activitypub'] ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The other (more common) option to make an ActivityPub request
|
||||||
|
* is to send an Accept header.
|
||||||
|
*/
|
||||||
|
if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
|
||||||
|
$accept = sanitize_text_field( wp_unslash( $_SERVER['HTTP_ACCEPT'] ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $accept can be a single value, or a comma separated list of values.
|
||||||
|
* We want to support both scenarios,
|
||||||
|
* and return true when the header includes at least one of the following:
|
||||||
|
* - application/activity+json
|
||||||
|
* - application/ld+json
|
||||||
|
* - application/json
|
||||||
|
*/
|
||||||
|
if ( preg_match( '/(application\/(ld\+json|activity\+json|json))/i', $accept ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the post id of the event for an EventPrime event query.
|
||||||
|
*
|
||||||
|
* @return bool|int The post ID if an event could be identified, false otherwise.
|
||||||
|
*/
|
||||||
|
private static function get_eventprime_post_id() {
|
||||||
|
$event = get_query_var( 'event' );
|
||||||
|
if ( ! $event ) {
|
||||||
|
if ( ! empty( filter_input( INPUT_GET, 'event', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ) ) {
|
||||||
|
$event = rtrim( filter_input( INPUT_GET, 'event', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), '/\\' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $event ) {
|
||||||
|
$ep_basic_functions = new Eventprime_Basic_Functions();
|
||||||
|
return $ep_basic_functions->ep_get_id_by_slug( $event, 'em_event' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the ActivityPub template for EventPrime.
|
||||||
|
*
|
||||||
|
* @param string $template The path to the template object.
|
||||||
|
* @return string The new path to the JSON template.
|
||||||
|
*/
|
||||||
|
public static function render_activitypub_template( $template ) {
|
||||||
|
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the request is a page with (solely) the eventprime shortcode in it.
|
||||||
|
if ( ! self::is_eventprime_activitypub_request() ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! \is_singular() ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_id = self::get_eventprime_post_id();
|
||||||
|
|
||||||
|
if ( $post_id ) {
|
||||||
|
$preview = \get_query_var( 'preview' );
|
||||||
|
if ( $preview ) {
|
||||||
|
$activitypub_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/post-preview.php';
|
||||||
|
} else {
|
||||||
|
$activitypub_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/post-json.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the request is authorized.
|
||||||
|
*
|
||||||
|
* @see https://www.w3.org/wiki/SocialCG/ActivityPub/Primer/Authentication_Authorization#Authorized_fetch
|
||||||
|
* @see https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
||||||
|
*/
|
||||||
|
if ( $activitypub_template && defined( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) && constant( 'ACTIVITYPUB_AUTHORIZED_FETCH' ) ) {
|
||||||
|
$verification = Signature::verify_http_signature( $_SERVER );
|
||||||
|
if ( \is_wp_error( $verification ) ) {
|
||||||
|
header( 'HTTP/1.1 401 Unauthorized' );
|
||||||
|
|
||||||
|
// Fallback as template_loader can't return http headers.
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $activitypub_template ) {
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
$post = get_post( $post_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||||
|
|
||||||
|
// Ensure WordPress functions use the new post data.
|
||||||
|
setup_postdata( $post );
|
||||||
|
// Return the default ActivityPub template.
|
||||||
|
return $activitypub_template;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Plugins;
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
@ -27,7 +27,7 @@ final class Events_Manager extends Event_Plugin {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get_plugin_file(): string {
|
public static function get_relative_plugin_file(): string {
|
||||||
return 'events-manager/events-manager.php';
|
return 'events-manager/events-manager.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ final class Events_Manager extends Event_Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the main settings page of the plugin.
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
*
|
*
|
||||||
* @return string The settings page url.
|
* @return array The settings page urls.
|
||||||
*/
|
*/
|
||||||
public static function get_settings_page(): string {
|
public static function get_settings_page(): array {
|
||||||
return 'wp-admin/edit.php?post_type=event&page=events-manager-options#general';
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Plugins;
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
@ -27,7 +27,7 @@ final class GatherPress extends Event_Plugin {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get_plugin_file(): string {
|
public static function get_relative_plugin_file(): string {
|
||||||
return 'gatherpress/gatherpress.php';
|
return 'gatherpress/gatherpress.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ final class GatherPress extends Event_Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the main settings page of the plugin.
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
*
|
*
|
||||||
* @return string The settings page url.
|
* @return array The settings page urls.
|
||||||
*/
|
*/
|
||||||
public static function get_settings_page(): string {
|
public static function get_settings_pages(): array {
|
||||||
return class_exists( '\GatherPress\Core\Utility' ) ? \GatherPress\Core\Utility::prefix_key( 'general' ) : 'gatherpress_general';
|
return array( class_exists( '\GatherPress\Core\Utility' ) ? \GatherPress\Core\Utility::prefix_key( 'general' ) : 'gatherpress_general' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
61
includes/integrations/class-modern-events-calendar-lite.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Modern Events Calendar (Lite)
|
||||||
|
*
|
||||||
|
* Defines all the necessary meta information for the Modern Events Calendar (Lite).
|
||||||
|
*
|
||||||
|
* @link https://webnus.net/modern-events-calendar/
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a supported event plugin.
|
||||||
|
*
|
||||||
|
* This interface defines which information is necessary for a supported event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Modern_Events_Calendar_Lite extends Event_plugin {
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_relative_plugin_file(): string {
|
||||||
|
return 'modern-events-calendar-lite/modern-events-calendar-lite.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
// See MEC_feature_events->get_main_post_type().
|
||||||
|
return 'mec-events';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page urls.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'MEC-settings', 'MEC-support', 'MEC-ix', 'MEC-wizard', 'MEC-addons', 'mec-intro' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'mec_category';
|
||||||
|
}
|
||||||
|
}
|
|
@ -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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Plugins;
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
@ -27,7 +27,7 @@ final class The_Events_Calendar extends Event_plugin {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get_plugin_file(): string {
|
public static function get_relative_plugin_file(): string {
|
||||||
return 'the-events-calendar/the-events-calendar.php';
|
return 'the-events-calendar/the-events-calendar.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,17 +41,17 @@ final class The_Events_Calendar extends Event_plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the main settings page of the plugin.
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
*
|
*
|
||||||
* @return string The settings page url.
|
* @return array The settings page urls.
|
||||||
*/
|
*/
|
||||||
public static function get_settings_page(): string {
|
public static function get_settings_pages(): array {
|
||||||
if ( class_exists( '\Tribe\Events\Admin\Settings' ) ) {
|
if ( class_exists( '\Tribe\Events\Admin\Settings' ) ) {
|
||||||
$page = \Tribe\Events\Admin\Settings::$settings_page_id;
|
$page = \Tribe\Events\Admin\Settings::$settings_page_id;
|
||||||
} else {
|
} else {
|
||||||
$page = 'tec-events-settings';
|
$page = 'tec-events-settings';
|
||||||
}
|
}
|
||||||
return sprintf( 'edit.php?post_type=tribe_events&page=%s', $page );
|
return array( $page );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -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_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Activitypub_Event_Extensions\Plugins;
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
use Activitypub_Event_Extensions\Event_Plugins;
|
use Event_Bridge_For_ActivityPub\Event_Plugins;
|
||||||
|
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
@ -30,7 +30,7 @@ final class VS_Event_List extends Event_Plugin {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get_plugin_file(): string {
|
public static function get_relative_plugin_file(): string {
|
||||||
return 'very-simple-event-list/vsel.php';
|
return 'very-simple-event-list/vsel.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ final class VS_Event_List extends Event_Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the main settings page of the plugin.
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
*
|
*
|
||||||
* @return string The settings page url.
|
* @return array The settings page urls.
|
||||||
*/
|
*/
|
||||||
public static function get_settings_page(): string {
|
public static function get_settings_pages(): array {
|
||||||
return 'settings_page_vsel';
|
return array( 'settings_page_vsel' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
72
includes/integrations/class-wp-event-manager.php
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WP Event Manager.
|
||||||
|
*
|
||||||
|
* Defines all the necessary meta information for the WordPress event plugin
|
||||||
|
* "WP Event Manager"
|
||||||
|
*
|
||||||
|
* @link https://de.wordpress.org/plugins/wp-event-manager
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Event_Bridge_For_ActivityPub\Integrations;
|
||||||
|
|
||||||
|
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a supported event plugin.
|
||||||
|
*
|
||||||
|
* This interface defines which information is necessary for a supported event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class WP_Event_Manager extends Event_Plugin {
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_relative_plugin_file(): string {
|
||||||
|
return 'wp-event-manager/wp-event-manager.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
return 'event_listing';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page urls.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'event-manager-settings' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ActivityPub transformer class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_activitypub_transformer_class_name(): string {
|
||||||
|
return 'WP_Event_Manager';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'event_listing_category';
|
||||||
|
}
|
||||||
|
}
|
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "event-bridge-for-activitypub",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"author": {
|
||||||
|
"name": "André Menrath",
|
||||||
|
"web": "https://graz.social/@linos"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "wp-scripts start",
|
||||||
|
"build": "wp-scripts build",
|
||||||
|
"readme": "grunt wp_readme_to_markdown",
|
||||||
|
"env-start": "wp-env start && wp-env run cli wp rewrite structure '/%year%/%monthnum%/%postname%/'",
|
||||||
|
"env-stop": "wp-env stop"
|
||||||
|
},
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@wordpress/env": "^10.10.0",
|
||||||
|
"@wordpress/scripts": "^30.0.2",
|
||||||
|
"classnames": "^2.3.2",
|
||||||
|
"grunt": "^1.1.0",
|
||||||
|
"grunt-checktextdomain": "^1.0.1",
|
||||||
|
"grunt-wp-i18n": "^1.0.3",
|
||||||
|
"grunt-wp-readme-to-markdown": "^2.0.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,9 @@
|
||||||
<!-- Exclude minified Javascript files. -->
|
<!-- Exclude minified Javascript files. -->
|
||||||
<exclude-pattern>*.min.js</exclude-pattern>
|
<exclude-pattern>*.min.js</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Exclude the Grundfile.js. -->
|
||||||
|
<exclude-pattern>Gruntfile.js</exclude-pattern>
|
||||||
|
|
||||||
<!-- Strip the filepaths down to the relevant bit. -->
|
<!-- Strip the filepaths down to the relevant bit. -->
|
||||||
<arg name="basepath" value="."/>
|
<arg name="basepath" value="."/>
|
||||||
|
|
||||||
|
@ -105,8 +108,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-extensions"/>
|
<element value="event-bridge-for-activitypub"/>
|
||||||
<element value="activitypub"/>
|
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
|
@ -114,7 +116,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_EXTENSIONS"/>
|
<element value="EVENT_BRIDGE_FOR_ACTIVITYPUB"/>
|
||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
57
readme.txt
|
@ -1,59 +1,78 @@
|
||||||
=== ActivityPub Event Extensions ===
|
=== Event Bridge for ActivityPub ===
|
||||||
Contributors: andremenrath
|
Contributors: andremenrath
|
||||||
Tags: events, fediverse, activitypub, activitystreams, 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.7
|
||||||
Stable tag: 0.1.0
|
Stable tag: 0.3.2
|
||||||
Requires PHP: 8.1
|
Requires PHP: 7.4
|
||||||
License: AGPL-3.0-or-later
|
License: AGPL-3.0-or-later
|
||||||
License URI: https://www.gnu.org/licenses/agpl-3.0.html
|
License URI: https://www.gnu.org/licenses/agpl-3.0.html
|
||||||
Integrating popular event plugins with the ActivityPub plugin.
|
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 part of the growing decentralized web.
|
Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and be a part of the growing decentralized web (the Fediverse).
|
||||||
With the ActivityPub Event 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.
|
With the Event Bridge for ActivityPub Plugin for WordPress, your events can be automatically followed, aggregated and displayed across decentralized platforms like [Mastodon](https://joinmastodon.org) or [Gancio](https://gancio.org), without any extra work.
|
||||||
Forget the hassle of managing multiple social media accounts just to keep your audience informed.
|
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 Fediverse.
|
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.
|
||||||
|
|
||||||
= How It Works =
|
= How It Works =
|
||||||
|
|
||||||
With the Event Federation Plugin for WordPress, sharing your events is effortless and automatic!
|
With the Event Bridge for ActivityPub WordPress plugin, sharing your events is effortless and automatic!
|
||||||
Once you create an event on your WordPress site, it is seamlessly shared across the decentralized web using the ActivityPub protocol.
|
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 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.
|
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.
|
||||||
|
|
||||||
![](./.wordpress-org/decentralized-event-calenders.gif)
|
![](./.wordpress-org/decentralized-event-calenders.gif)
|
||||||
|
|
||||||
|
Even platforms that don't 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.
|
||||||
|
|
||||||
|
= Features for Your WordPress Events and the Fediverse =
|
||||||
|
|
||||||
|
**ActivityPub-Enabled Event Sharing:** Your WordPress events are now compatible with the Fediverse, using the ActivityStreams format. This means your events can be easily discovered and followed by users on platforms like Mastodon and other ActivityPub-compatible services.
|
||||||
|
|
||||||
|
**Automatic Event Summaries:** When your event is shared on the Fediverse, platforms like Mastodon that don't fully support events will display a brief HTML summary of key details — such as the event's title, start time, and location. This ensures that even if someone can't view the full event on their platform, they still get the important info at a glance, with a link to your WordPress event page. Advanced users can create custom summaries via a set of shortcodes.
|
||||||
|
|
||||||
|
**Improved Event Discoverability:** Your custom event categories are mapped to a set of default categories used in the Fediverse, helping your events reach a wider audience. This improves the chances that users searching for similar events on other platforms will find yours.
|
||||||
|
|
||||||
|
**Event Reminders for Your Followers:** Often, events are planned well in advance. To keep your followers informed right in time, you can set up reminders that are supposed to trigger the events showing up in their timelines right before the event starts. At the moment this reminder is implemented as a self-boost of your original event post. While this feature may behave differently across various platforms, we are working on a more robust solution that will let you schedule dedicated reminder notes that appear in all followers' timelines.
|
||||||
|
|
||||||
== 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 =
|
||||||
|
|
||||||
* [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/)
|
||||||
* [Events Manager](https://de.wordpress.org/plugins/events-manager/)
|
* [Events Manager](https://de.wordpress.org/plugins/events-manager/)
|
||||||
|
* [WP Event Manager](https://de.wordpress.org/plugins/wp-event-manager/)
|
||||||
|
* [Eventin](https://de.wordpress.org/plugins/wp-event-solution/)
|
||||||
|
* [Modern Events Calendar Lite](https://webnus.net/modern-events-calendar/)
|
||||||
|
* [GatherPress](https://gatherpress.org/)
|
||||||
|
* [EventPrime – Events Calendar, Bookings and Tickets](https://wordpress.org/plugins/eventprime-event-calendar-management/)
|
||||||
|
* [Event Organiser](https://wordpress.org/plugins/event-organiser/)
|
||||||
|
|
||||||
== Configuration ==
|
== Configuration ==
|
||||||
|
|
||||||
If you’re new to the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/), it’s recommended to spend a few minutes reading through its documentation to familiarize yourself with its setup and functionality.
|
If you're new to the [ActivityPub plugin](https://wordpress.org/plugins/activitypub/), it’s recommended to spend a few minutes reading through its documentation to familiarize yourself with its setup and functionality.
|
||||||
|
|
||||||
== 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 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 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/).
|
||||||
|
|
||||||
= 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 don’t 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 don't 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? =
|
||||||
|
|
||||||
|
@ -69,14 +88,14 @@ 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-extensions/issues), if we can spare some free hours we might add it.
|
If you know about coding have a look at the documentation of how to add your plugin or open an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues), if we can spare some free hours we might add it.
|
||||||
|
|
||||||
= What if I experience problems? =
|
= 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-extensions/issues).
|
We're always interested in your feedback. Feel free to reach out to us via [E-Mail](https://event-federation.eu/contact/) or create an [issue](https://code.event-federation.eu/Event-Federation/wordpress-event-bridge-for-activitypub/issues).
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
= [0.1.0] 2024-09-01 =
|
= [0.3.2] 2024-12-12 =
|
||||||
|
|
||||||
* Initial alpha release on WordPress.org
|
* Initial release on https://wordpress.org/
|
||||||
|
|
36
templates/admin-header.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Template for the header and navigation of the admin pages.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/* @var array $args Template arguments. */
|
||||||
|
$args = wp_parse_args(
|
||||||
|
$args,
|
||||||
|
array(
|
||||||
|
'welcome' => '',
|
||||||
|
'settings' => '',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="event-bridge-for-activitypub-settings-header">
|
||||||
|
<div class="event-bridge-for-activitypub-settings-title-section">
|
||||||
|
<h1><?php \esc_html_e( 'Event Bridge for ActivityPub', 'event-bridge-for-activitypub' ); ?></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="event-bridge-for-activitypub-settings-tabs-wrapper" aria-label="<?php \esc_attr_e( 'Secondary menu', 'event-bridge-for-activitypub' ); ?>">
|
||||||
|
<a href="<?php echo \esc_url( admin_url( 'options-general.php?page=event-bridge-for-activitypub' ) ); ?>" class="event-bridge-for-activitypub-settings-tab <?php echo \esc_attr( $args['welcome'] ); ?>">
|
||||||
|
<?php \esc_html_e( 'Welcome', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="<?php echo \esc_url( admin_url( 'options-general.php?page=event-bridge-for-activitypub&tab=settings' ) ); ?>" class="event-bridge-for-activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>">
|
||||||
|
<?php \esc_html_e( 'Settings', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<hr class="wp-header-end">
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Template for ActivityPub Event Extensions settings page.
|
* Template for Event Bridge for ActivityPub settings page.
|
||||||
*
|
*
|
||||||
* This template is used to display and manage settings for the ActivityPub Event Extensions plugin.
|
* This template is used to display and manage settings for the Event Bridge for ActivityPub plugin.
|
||||||
*
|
*
|
||||||
* @package ActivityPub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
* @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.
|
||||||
|
@ -13,6 +13,14 @@
|
||||||
// Exit if accessed directly.
|
// Exit if accessed directly.
|
||||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
\load_template(
|
||||||
|
__DIR__ . '/admin-header.php',
|
||||||
|
true,
|
||||||
|
array(
|
||||||
|
'settings' => 'active',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
use Activitypub\Activity\Extended_Object\Event;
|
use Activitypub\Activity\Extended_Object\Event;
|
||||||
|
|
||||||
if ( ! isset( $args ) || ! array_key_exists( 'event_terms', $args ) ) {
|
if ( ! isset( $args ) || ! array_key_exists( 'event_terms', $args ) ) {
|
||||||
|
@ -25,65 +33,72 @@ if ( ! current_user_can( 'manage_options' ) ) {
|
||||||
|
|
||||||
$event_terms = $args['event_terms'];
|
$event_terms = $args['event_terms'];
|
||||||
|
|
||||||
$default_event_category_strings = array(
|
require_once EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/event-categories.php';
|
||||||
'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_extensions_default_event_category', 'MEETING' );
|
$selected_default_event_category = \get_option( 'event_bridge_for_activitypub_default_event_category', 'MEETING' );
|
||||||
$current_category_mapping = \get_option( 'activitypub_event_extensions_event_category_mappings', array() );
|
$current_category_mapping = \get_option( 'event_bridge_for_activitypub_event_category_mappings', array() );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="activitypub-settings-header">
|
<div class="event-bridge-for-activitypub-settings event-bridge-for-activitypub-settings-page hide-if-no-js">
|
||||||
<div class="activitypub-settings-title-section">
|
|
||||||
<h1><?php \esc_html_e( 'ActivityPub Event Extensions', 'activitypub-event-extensions' ); ?></h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<hr class="wp-header-end">
|
|
||||||
|
|
||||||
<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-extensions' ); ?>
|
<?php \settings_fields( 'event-bridge-for-activitypub' ); ?>
|
||||||
|
<div class="box">
|
||||||
|
<h2> <?php esc_html_e( 'Event Summary Text', 'event-bridge-for-activitypub' ); ?> </h2>
|
||||||
|
<p><?php esc_html_e( 'Many Fediverse applications (e.g., Mastodon) don\'t fully support events, instead they will show a summary text along with the events title and the URL to your Website.', 'event-bridge-for-activitypub' ); ?></p>
|
||||||
|
<p>
|
||||||
|
<label for="event_bridge_for_activitypub_summary_type_preset">
|
||||||
|
<input type="radio" name="event_bridge_for_activitypub_summary_type" id="event_bridge_for_activitypub_summary_type_preset" value="preset" <?php echo \checked( 'preset', \get_option( 'event_bridge_for_activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
|
||||||
|
<?php \esc_html_e( 'Automatic (default)', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
-
|
||||||
|
<span class="description">
|
||||||
|
<?php \esc_html_e( 'Let the plugin compose a summary for you. ', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="event_bridge_for_activitypub_summary_type_custom">
|
||||||
|
<input type="radio" name="event_bridge_for_activitypub_summary_type" id="event_bridge_for_activitypub_summary_type_custom" value="custom" <?php echo \checked( 'custom', \get_option( 'event_bridge_for_activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
|
||||||
|
<?php \esc_html_e( 'Custom', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
-
|
||||||
|
<span class="description">
|
||||||
|
<?php \esc_html_e( 'For advanced users: compose your custom summary via shortcodes.', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<div id="event_bridge_for_activitypub_summary_type_custom-details">
|
||||||
|
<textarea name="event_bridge_for_activitypub_custom_summary" id="event_bridge_for_activitypub_custom_summary" rows="10" cols="50" class="large-text" placeholder="<?php echo wp_kses( EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY, 'post' ); ?>"><?php echo esc_textarea( wp_kses( \get_option( 'event_bridge_for_activitypub_custom_summary', EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY ), 'post' ) ); ?></textarea>
|
||||||
|
<details>
|
||||||
|
<summary><?php esc_html_e( 'See a list Template Tags available for the summary.', 'event-bridge-for-activitypub' ); ?></summary>
|
||||||
|
<div class="description">
|
||||||
|
<dl>
|
||||||
|
<dt><code>[ap_start_time]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events title.', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
<dt><code>[ap_end_time]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events content.', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
<dt><code>[ap_location]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events location.', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
<dt><code>[ap_hashtags]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events tags as hashtags.', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
<dt><code>[ap_excerpt]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events excerpt (may be truncated).', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
<dt><code>[ap_content]</code><dt>
|
||||||
|
<dd><?php \esc_html_e( 'The events description.', 'event-bridge-for-activitypub' ); ?></dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h2> <?php esc_html_e( 'Default ActivityPub Event Category', 'activitypub-event-extensions' ); ?> </h2>
|
<h2> <?php esc_html_e( 'ActivityPub Event Category', 'event-bridge-for-activitypub' ); ?> </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-extensions' ); ?> </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.', 'event-bridge-for-activitypub' ); ?> </p>
|
||||||
<table class="form-table">
|
<table class="form-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"> <?php esc_html_e( 'Default Category', 'activitypub-event-extensions' ); ?> </th>
|
<th scope="row"> <?php esc_html_e( 'Default Category', 'event-bridge-for-activitypub' ); ?> </th>
|
||||||
<td>
|
<td>
|
||||||
<select id="activitypub_event_extensions_default_event_category" name="activitypub_event_extensions_default_event_category">';
|
<select id="event_bridge_for_activitypub_default_event_category" name="event_bridge_for_activitypub_default_event_category">';
|
||||||
<?php
|
<?php
|
||||||
foreach ( $default_event_category_strings as $value => $label ) {
|
foreach ( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES as $value => $label ) {
|
||||||
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $selected_default_event_category, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $selected_default_event_category, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -91,18 +106,16 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if ( ! empty( $event_terms ) ) : ?>
|
<?php if ( ! empty( $event_terms ) ) : ?>
|
||||||
<div class="box">
|
<h3> <?php esc_html_e( 'Advanced Event Category Settings', 'event-bridge-for-activitypub' ); ?> </h3>
|
||||||
<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.', 'event-bridge-for-activitypub' ); ?> </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_extensions_event_category_mappings[<?php echo esc_attr( $event_term->slug ); ?>]">
|
<select name="event_bridge_for_activitypub_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 ) ) {
|
||||||
|
@ -114,13 +127,13 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev
|
||||||
$mapping = 'DEFAULT';
|
$mapping = 'DEFAULT';
|
||||||
}
|
}
|
||||||
if ( 'DEFAULT' === $mapping ) {
|
if ( 'DEFAULT' === $mapping ) {
|
||||||
echo '<option value="' . esc_attr( $mapping ) . '"> -- ' . esc_html( $default_event_category_strings[ $mapping ] ) . ' -- </option>';
|
echo '<option value="' . esc_attr( $mapping ) . '"> -- ' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $mapping ] ) . ' -- </option>';
|
||||||
} else {
|
} else {
|
||||||
echo '<option value="' . esc_attr( $mapping ) . '">' . esc_html( $default_event_category_strings[ $mapping ] ) . '</option>';
|
echo '<option value="' . esc_attr( $mapping ) . '">' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $mapping ] ) . '</option>';
|
||||||
}
|
}
|
||||||
echo '<option value="DEFAULT" ' . selected( $selected_default_event_category, 'DEFAULT', false ) . '> -- ' . esc_html__( 'Default', 'activitypub-event-extensions' ) . ' -- </option>';
|
echo '<option value="DEFAULT" ' . selected( $selected_default_event_category, 'DEFAULT', false ) . '> -- ' . esc_html__( 'Default', 'event-bridge-for-activitypub' ) . ' -- </option>';
|
||||||
foreach ( Event::DEFAULT_EVENT_CATEGORIES as $event_category ) {
|
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( $default_event_category_strings[ $event_category ] ) . '</option>';
|
echo '<option value="' . esc_attr( $event_category ) . '" ' . selected( $mappings[ $event_term->slug ] ?? '', $event_category, false ) . '>' . esc_html( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES[ $event_category ] ) . '</option>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
@ -128,8 +141,12 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</table>
|
</table>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<!-- This disables the setup wizard. -->
|
||||||
|
<div class="hidden">
|
||||||
|
<input type="checkbox" id="event_bridge_for_activitypub_initially_activated" name="event_bridge_for_activitypub_initially_activated"/>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
<?php \submit_button(); ?>
|
<?php \submit_button(); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
237
templates/welcome.php
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Status page for the Event Bridge for ActivityPub.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Event_Bridge_For_ActivityPub\Setup;
|
||||||
|
use Event_Bridge_For_ActivityPub\Admin\Settings_Page;
|
||||||
|
use Event_Bridge_For_ActivityPub\Admin\Health_Check;
|
||||||
|
|
||||||
|
\load_template(
|
||||||
|
__DIR__ . '/admin-header.php',
|
||||||
|
true,
|
||||||
|
array(
|
||||||
|
'welcome' => 'active',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$event_bridge_for_activitypub_status_ok = true;
|
||||||
|
$example_event_post = Health_Check::get_most_recent_event_posts();
|
||||||
|
|
||||||
|
if ( empty( $example_event_post ) ) {
|
||||||
|
$example_event_post = 'https://yoursite.com/events/event-name';
|
||||||
|
$example_event_post_is_dummy = true;
|
||||||
|
} else {
|
||||||
|
$example_event_post = \get_permalink( $example_event_post[0] );
|
||||||
|
$example_event_post_is_dummy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wp_filesystem;
|
||||||
|
WP_Filesystem();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="event-bridge-for-activitypub-settings event-bridge-for-activitypub-settings-page hide-if-no-js">
|
||||||
|
<div class="box">
|
||||||
|
<h2><?php \esc_html_e( 'Status', 'event-bridge-for-activitypub' ); ?></h2>
|
||||||
|
<p><?php \esc_html_e( 'The Event Bridge for ActivityPub detected the following (activated) event plugins:', 'event-bridge-for-activitypub' ); ?></p>
|
||||||
|
<?php foreach ( $active_event_plugins as $active_event_plugin ) { ?>
|
||||||
|
<h3><?php echo esc_html( $active_event_plugin->get_plugin_name() ); ?>:</h3>
|
||||||
|
<ul class="event-bridge-for-activitypub-list">
|
||||||
|
<li>
|
||||||
|
<?php
|
||||||
|
if ( in_array( $active_event_plugin::get_post_type(), get_option( 'activitypub_support_post_types', array() ), true ) ) {
|
||||||
|
echo '✅ ';
|
||||||
|
$status_message_post_type_enabled = sprintf(
|
||||||
|
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
|
||||||
|
_x(
|
||||||
|
'The ActivityPub support for the event post type of the plugin <i>%2$s</i> is enabled in the <a href="%3$s">%1$s settings</a>.',
|
||||||
|
'admin notice',
|
||||||
|
'event-bridge-for-activitypub'
|
||||||
|
),
|
||||||
|
esc_html( get_plugin_data( ACTIVITYPUB_PLUGIN_FILE )['Name'] ),
|
||||||
|
esc_html( $active_event_plugin->get_plugin_name() ),
|
||||||
|
admin_url( 'options-general.php?page=activitypub&tab=settings' )
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$event_bridge_for_activitypub_status_ok = false;
|
||||||
|
echo '❌ ';
|
||||||
|
$status_message_post_type_enabled = sprintf(
|
||||||
|
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
|
||||||
|
_x(
|
||||||
|
'The post type for events of the plugin <i>%2$s</i> is <b>not enabled</b> in the <a href="%3$s">%1$s settings</a>.',
|
||||||
|
'admin notice',
|
||||||
|
'event-bridge-for-activitypub'
|
||||||
|
),
|
||||||
|
esc_html( get_plugin_data( ACTIVITYPUB_PLUGIN_FILE )['Name'] ),
|
||||||
|
esc_html( $active_event_plugin->get_plugin_name() ),
|
||||||
|
admin_url( 'options-general.php?page=activitypub&tab=settings' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$allowed_html = array(
|
||||||
|
'a' => array(
|
||||||
|
'href' => true,
|
||||||
|
'title' => true,
|
||||||
|
),
|
||||||
|
'b' => array(),
|
||||||
|
'i' => array(),
|
||||||
|
);
|
||||||
|
echo \wp_kses( $status_message_post_type_enabled, $allowed_html );
|
||||||
|
?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?php
|
||||||
|
if ( Health_Check::test_if_event_transformer_is_used( $active_event_plugin ) ) {
|
||||||
|
echo '✅ ';
|
||||||
|
esc_html_e( 'The Event Bridge for ActivityPub successfully registered to the ActivityPub plugin.', 'event-bridge-for-activitypub' );
|
||||||
|
} else {
|
||||||
|
$event_bridge_for_activitypub_status_ok = false;
|
||||||
|
echo '❌ ';
|
||||||
|
esc_html_e( 'The Event Bridge for ActivityPub could not register to the ActivityPub plugin.', 'event-bridge-for-activitypub' );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ( get_option( 'event_bridge_for_activitypub_initially_activated', true ) ) : ?>
|
||||||
|
<a href="<?php echo esc_url( admin_url( 'options-general.php?page=' . Settings_Page::SETTINGS_SLUG ) . '&tab=settings' ); ?>" role="button">
|
||||||
|
<button class="button button-primary">
|
||||||
|
<strong>→</strong> <?php \esc_html_e( 'Continue your setup', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<?php else : ?>
|
||||||
|
|
||||||
|
<div class="box">
|
||||||
|
<h2><?php \esc_html_e( 'How to Check if It\'s Working', 'event-bridge-for-activitypub' ); ?></h2>
|
||||||
|
<?php
|
||||||
|
if ( ! $event_bridge_for_activitypub_status_ok ) {
|
||||||
|
echo '<div class="notice-warning"><p>' . \esc_html__( 'Please fix the status issues above first.', 'event-bridge-for-activitypub' ) . '</p></div>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<p><?php esc_html_e( 'Most of the magic happens behind the scenes, but here is how you can verify that your events are ready to be discovered:', 'event-bridge-for-activitypub' ); ?></p>
|
||||||
|
<div class="event-bridge-for-activitypub-settings-accordion">
|
||||||
|
<h4 class="event-bridge-for-activitypub-settings-accordion-heading">
|
||||||
|
<button aria-expanded="false" class="event-bridge-for-activitypub-settings-accordion-trigger" aria-controls="event-bridge-for-activitypub-help-accordion-mastodon" type="button">
|
||||||
|
<span class="title">
|
||||||
|
1.
|
||||||
|
<img src="<?php echo esc_url( plugins_url( '/assets/img/mastodon.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Mastodon Icon" class="event-bridge-for-activitypub-settings-inline-icon">
|
||||||
|
<?php \esc_html_e( 'Using Your Mastodon Account', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</span>
|
||||||
|
<span class="icon"></span>
|
||||||
|
</button>
|
||||||
|
</h4>
|
||||||
|
<div id="event-bridge-for-activitypub-help-accordion-mastodon" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
|
||||||
|
<ol class="event-bridge-for-activitypub-settings-numbered-list">
|
||||||
|
<li><?php \esc_html_e( 'Log into your Mastodon account.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
<li>
|
||||||
|
<?php \esc_html_e( 'In the search bar, type or copy the full URL of one of your event pages. For example:', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
<code class="event-bridge-for-activitypub-settings-example-url"><?php echo \esc_url( $example_event_post ); ?></code>
|
||||||
|
</li>
|
||||||
|
<li><?php \esc_html_e( 'If everything is set up correctly, you\'ll see a post representing your event. It should include the event\'s image, title, and a brief description.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="event-bridge-for-activitypub-settings-accordion-heading">
|
||||||
|
<button aria-expanded="false" class="event-bridge-for-activitypub-settings-accordion-trigger" aria-controls="event-bridge-for-activitypub-help-accordion-mobilizon" type="button">
|
||||||
|
<span class="title">
|
||||||
|
2.
|
||||||
|
<img src="<?php echo esc_url( plugins_url( '/assets/img/mobilizon.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Mastodon Icon" class="event-bridge-for-activitypub-settings-inline-icon">
|
||||||
|
<?php \esc_html_e( 'Using Your Mobilizon Account', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</span>
|
||||||
|
<span class="icon"></span>
|
||||||
|
</button>
|
||||||
|
</h4>
|
||||||
|
<div id="event-bridge-for-activitypub-help-accordion-mobilizon" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
|
||||||
|
<ol class="event-bridge-for-activitypub-settings-numbered-list">
|
||||||
|
<li><?php \esc_html_e( 'Log into your Mobilizon account.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
<li>
|
||||||
|
<?php \esc_html_e( 'In the search bar, type or copy the full URL of one of your event pages. For example:', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
<code class="event-bridge-for-activitypub-settings-example-url"><?php echo \esc_url( $example_event_post ); ?></code>
|
||||||
|
</li>
|
||||||
|
<li><?php \esc_html_e( 'If everything is set up correctly, you\'ll see a full representation of your WordPress event. This will include the event\'s banner image, title, complete description, start and end times, categories, tags, and whether it\'s an online event.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="event-bridge-for-activitypub-settings-accordion-heading">
|
||||||
|
<button aria-expanded="false" class="event-bridge-for-activitypub-settings-accordion-trigger" aria-controls="event-bridge-for-activitypub-help-accordion-fediverse" type="button">
|
||||||
|
<span class="title">
|
||||||
|
3.
|
||||||
|
<img src="<?php echo esc_url( plugins_url( '/assets/img/fediverse.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Mastodon Icon" class="event-bridge-for-activitypub-settings-inline-icon">
|
||||||
|
<?php \esc_html_e( 'Using Any Other Fediverse Application', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
</span>
|
||||||
|
<span class="icon"></span>
|
||||||
|
</button>
|
||||||
|
</h4>
|
||||||
|
<div id="event-bridge-for-activitypub-help-accordion-fediverse" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
|
||||||
|
<p><?php \esc_html_e( 'Of course any other application in the Fediverse should work as well. Most applications support importing external content via searching for the contents full URL.', 'event-bridge-for-activitypub' ); ?></p>
|
||||||
|
<ol class="event-bridge-for-activitypub-settings-numbered-list">
|
||||||
|
<li><?php \esc_html_e( 'Log into your account on any Fediverse app.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
<li>
|
||||||
|
<?php \esc_html_e( 'In the search bar, type or copy the full URL of one of your event pages. For example:', 'event-bridge-for-activitypub' ); ?>
|
||||||
|
<code class="event-bridge-for-activitypub-settings-example-url"><?php echo \esc_url( $example_event_post ); ?></code>
|
||||||
|
</li>
|
||||||
|
<li><?php \esc_html_e( 'If the application which your are using natively supports ActivityPub events, you should see a representation of your WordPress event. If your application is supports receiving ActivityPub events you will get a post which summarizes the event. Keep in mind that some apps may not support events at all.', 'event-bridge-for-activitypub' ); ?></li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="event-bridge-for-activitypub-settings-accordion-heading">
|
||||||
|
<button aria-expanded="false" class="event-bridge-for-activitypub-settings-accordion-trigger" aria-controls="event-bridge-for-activitypub-help-accordion-advanced" type="button">
|
||||||
|
<span class="title">
|
||||||
|
4.
|
||||||
|
<img src="<?php echo esc_url( plugins_url( '/assets/img/activitypub.svg', EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_FILE ) ); ?>" alt="Mastodon Icon" class="event-bridge-for-activitypub-settings-inline-icon">
|
||||||
|
<?php \esc_html_e( 'Advanced: Verifying the ActivityStreams JSON', 'event-bridge-for-activitypub' ); ?></span>
|
||||||
|
<span class="icon"></span>
|
||||||
|
</button>
|
||||||
|
</h4>
|
||||||
|
<div id="event-bridge-for-activitypub-help-accordion-advanced" class="event-bridge-for-activitypub-settings-accordion-panel" hidden="hidden">
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
// Assume $event_url contains the dynamic URL, and '?activitypub' is appended to it.
|
||||||
|
$activitypub_url = esc_url( $example_event_post . '?activitypub' );
|
||||||
|
|
||||||
|
// Prepare the activitypub part wrapped in a <code> element.
|
||||||
|
$activitypub_query = '<nobr><code>' . esc_html( '?activitypub' ) . '</code></nobr>';
|
||||||
|
|
||||||
|
$activitypub_url_html = '<a href="' . esc_url( $activitypub_url ) . '" target="_blank">' . esc_html( $activitypub_url ) . '</a>';
|
||||||
|
|
||||||
|
// Translator comment to explain the placeholder.
|
||||||
|
/* translators: %1$s is the <code>?activitypub</code> string, and %2$s is the full URL of an example event */
|
||||||
|
$raw_string = sprintf( __( 'For more technical users, you can inspect how your event is converted into an ActivityPub object. Simply append %1$s to the end of any single event pages URL to view the raw ActivityStreams JSON data (e.g., %2$s).', 'event-bridge-for-activitypub' ), $activitypub_query, $activitypub_url_html );
|
||||||
|
|
||||||
|
// Allowed HTML tags in the string (only <code> and <a>).
|
||||||
|
$allowed_html = array(
|
||||||
|
'a' => array(
|
||||||
|
'href' => array(),
|
||||||
|
'target' => array(),
|
||||||
|
),
|
||||||
|
'nobr' => array(),
|
||||||
|
'code' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Output the formatted string with the allowed HTML elements.
|
||||||
|
echo wp_kses( $raw_string, $allowed_html );
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box">
|
||||||
|
<h2><?php \esc_html_e( 'Changelog', 'event-bridge-for-activitypub' ); ?></h2>
|
||||||
|
<pre>
|
||||||
|
<?php
|
||||||
|
$changelog = $wp_filesystem->get_contents( EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/CHANGELOG.md' );
|
||||||
|
echo esc_html( substr( $changelog, strpos( $changelog, "\n", 180 ) + 1 ) );
|
||||||
|
?>
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* PHPUnit bootstrap file.
|
* PHPUnit bootstrap file.
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
||||||
|
@ -25,6 +25,21 @@ if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
|
||||||
// Give access to tests_add_filter() function.
|
// Give access to tests_add_filter() function.
|
||||||
require_once "{$_tests_dir}/includes/functions.php";
|
require_once "{$_tests_dir}/includes/functions.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to manually load an event plugin.
|
||||||
|
*
|
||||||
|
* @param string $plugin_file The main plugin file of the event plugin.
|
||||||
|
*/
|
||||||
|
function _manually_load_event_plugin( $plugin_file ) {
|
||||||
|
$plugin_dir = ABSPATH . '/wp-content/plugins/';
|
||||||
|
require_once $plugin_dir . $plugin_file;
|
||||||
|
update_option( 'purchase_history_table_structure_migration_done', true );
|
||||||
|
$current = get_option( 'active_plugins', array() );
|
||||||
|
$current[] = $plugin_file;
|
||||||
|
sort( $current );
|
||||||
|
update_option( 'active_plugins', $current );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually load the plugin being tested and its integrations.
|
* Manually load the plugin being tested and its integrations.
|
||||||
*/
|
*/
|
||||||
|
@ -35,17 +50,21 @@ function _manually_load_plugin() {
|
||||||
require_once $plugin_dir . 'activitypub/activitypub.php';
|
require_once $plugin_dir . 'activitypub/activitypub.php';
|
||||||
|
|
||||||
// Capture the --filter argument.
|
// Capture the --filter argument.
|
||||||
$activitypub_event_extension_integration_filter = null;
|
$event_bridge_for_activitypub_integration_filter = null;
|
||||||
foreach ( $_SERVER['argv'] as $arg ) {
|
foreach ( $_SERVER['argv'] as $arg ) {
|
||||||
if ( strpos( $arg, '--filter=' ) === 0 ) {
|
if ( strpos( $arg, '--filter=' ) === 0 ) {
|
||||||
$activitypub_event_extension_integration_filter = substr( $arg, strlen( '--filter=' ) );
|
$event_bridge_for_activitypub_integration_filter = substr( $arg, strlen( '--filter=' ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hot fixes for eventin.
|
||||||
|
update_option( 'purchase_history_table_structure_migration_done', true );
|
||||||
|
update_option( 'etn_wizard', 'active' );
|
||||||
|
|
||||||
$plugin_file = null;
|
$plugin_file = null;
|
||||||
// See if we want to run integration tests for a specific event-plugin.
|
// See if we want to run integration tests for a specific event-plugin.
|
||||||
switch ( $activitypub_event_extension_integration_filter ) {
|
switch ( $event_bridge_for_activitypub_integration_filter ) {
|
||||||
case 'the_events_calendar':
|
case 'the_events_calendar':
|
||||||
$plugin_file = 'the-events-calendar/the-events-calendar.php';
|
$plugin_file = 'the-events-calendar/the-events-calendar.php';
|
||||||
break;
|
break;
|
||||||
|
@ -55,30 +74,51 @@ function _manually_load_plugin() {
|
||||||
case 'events_manager':
|
case 'events_manager':
|
||||||
$plugin_file = 'events-manager/events-manager.php';
|
$plugin_file = 'events-manager/events-manager.php';
|
||||||
break;
|
break;
|
||||||
|
case 'eventin':
|
||||||
|
$plugin_file = 'wp-event-solution/eventin.php';
|
||||||
|
break;
|
||||||
|
case 'modern_events_calendar_lite':
|
||||||
|
$plugin_file = 'modern-events-calendar-lite/modern-events-calendar-lite.php';
|
||||||
|
break;
|
||||||
case 'gatherpress':
|
case 'gatherpress':
|
||||||
$plugin_file = 'gatherpress/gatherpress.php';
|
$plugin_file = 'gatherpress/gatherpress.php';
|
||||||
break;
|
break;
|
||||||
|
case 'wp_event_manager':
|
||||||
|
$plugin_file = 'wp-event-manager/wp-event-manager.php';
|
||||||
|
break;
|
||||||
|
case 'eventprime':
|
||||||
|
$plugin_file = 'eventprime-event-calendar-management/event-prime.php';
|
||||||
|
break;
|
||||||
|
case 'event_organiser':
|
||||||
|
$plugin_file = 'event-organiser/event-organiser.php';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $plugin_file ) {
|
if ( $plugin_file ) {
|
||||||
// Manually load the event plugin.
|
_manually_load_event_plugin( $plugin_file );
|
||||||
require_once $plugin_dir . $plugin_file;
|
} else {
|
||||||
$current = get_option( 'active_plugins', array() );
|
// For all other tests we mainly use the Events Calendar as a reference.
|
||||||
$current[] = $plugin_file;
|
_manually_load_event_plugin( 'the-events-calendar/the-events-calendar.php' );
|
||||||
sort( $current );
|
_manually_load_event_plugin( 'very-simple-event-list/vsel.php' );
|
||||||
update_option( 'active_plugins', $current );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hot fix that allows using Events Manager within unit tests, because the em_init() is later not run as admin.
|
// Hot fix that allows using Events Manager within unit tests, because the em_init() is later not run as admin.
|
||||||
if ( 'events_manager' === $activitypub_event_extension_integration_filter ) {
|
if ( 'events_manager' === $event_bridge_for_activitypub_integration_filter ) {
|
||||||
require_once $plugin_dir . 'events-manager/em-install.php';
|
require_once $plugin_dir . 'events-manager/em-install.php';
|
||||||
em_create_events_table();
|
em_create_events_table();
|
||||||
em_create_events_meta_table();
|
em_create_events_meta_table();
|
||||||
em_create_locations_table();
|
em_create_locations_table();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 'modern_events_calendar_lite' === $event_bridge_for_activitypub_integration_filter ) {
|
||||||
|
require_once $plugin_dir . 'modern-events-calendar-lite/app/libraries/factory.php';
|
||||||
|
$mec_factory = new MEC_factory();
|
||||||
|
$mec_factory->install();
|
||||||
|
}
|
||||||
|
|
||||||
// At last manually load our WordPress plugin.
|
// At last manually load our WordPress plugin.
|
||||||
require dirname( __DIR__ ) . '/activitypub-event-extensions.php';
|
require dirname( __DIR__ ) . '/event-bridge-for-activitypub.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
||||||
|
|
193
tests/test-class-activitypub-event-bridge-shortcodes.php
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test file for Activitypub Shortcodes.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Activitypub\Shortcodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for Activitypub Shortcodes.
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \Activitypub\Shortcodes
|
||||||
|
*/
|
||||||
|
class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! class_exists( '\Tribe__Events__Main' ) ) {
|
||||||
|
self::markTestSkipped( 'The Events Calendar plugin is needed to test Event Shortcodes' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the shortcode for rendering the events start time.
|
||||||
|
*/
|
||||||
|
public function test_start_time() {
|
||||||
|
// Create a The Events Calendar Event without content.
|
||||||
|
$wp_object = tribe_events()
|
||||||
|
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'] )
|
||||||
|
->create();
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformer->register_shortcodes();
|
||||||
|
|
||||||
|
$summary = '[ap_start_time]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '🗓️ Start: December 1, 2024 3:00 pm', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_start_time icon="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'Start: December 1, 2024 3:00 pm', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_start_time icon="false" label="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'December 1, 2024 3:00 pm', $summary );
|
||||||
|
|
||||||
|
$transformer->unregister_shortcodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the shortcode for rendering the events end time.
|
||||||
|
*/
|
||||||
|
public function test_end_time() {
|
||||||
|
// Create a The Events Calendar Event without content.
|
||||||
|
$wp_object = tribe_events()
|
||||||
|
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'] )
|
||||||
|
->create();
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformer->register_shortcodes();
|
||||||
|
|
||||||
|
$summary = '[ap_end_time]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '⏳ End: December 1, 2024 4:00 pm', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_end_time icon="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'End: December 1, 2024 4:00 pm', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_end_time icon="false" label="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'December 1, 2024 4:00 pm', $summary );
|
||||||
|
|
||||||
|
$transformer->unregister_shortcodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the shortcode for rendering the events location when no location is set.
|
||||||
|
*/
|
||||||
|
public function test_location_when_no_location_is_set() {
|
||||||
|
// Create a The Events Calendar Event without content.
|
||||||
|
$wp_object = tribe_events()
|
||||||
|
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'] )
|
||||||
|
->create();
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformer->register_shortcodes();
|
||||||
|
|
||||||
|
$summary = '[ap_location]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '', $summary );
|
||||||
|
|
||||||
|
$transformer->unregister_shortcodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the shortcode for rendering the events location when location is set.
|
||||||
|
*/
|
||||||
|
public function test_location_when_location_is_set() {
|
||||||
|
// Create Venue.
|
||||||
|
$venue = tribe_venues()->set_args( Test_The_Events_Calendar::MOCKUP_VENUS['minimal_venue'] )->create();
|
||||||
|
// Create a The Events Calendar Event.
|
||||||
|
$wp_object = tribe_events()
|
||||||
|
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['complex_event'] )
|
||||||
|
->set( 'venue', $venue->ID )
|
||||||
|
->create();
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformer->register_shortcodes();
|
||||||
|
|
||||||
|
$summary = '[ap_location]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '📍 Location: Minimal Venue', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_location icon="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'Location: Minimal Venue', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_location icon="false" label="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( 'Minimal Venue', $summary );
|
||||||
|
|
||||||
|
$transformer->unregister_shortcodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the shortcode for rendering the events location when location with detailed address is set.
|
||||||
|
*/
|
||||||
|
public function test_location_when_detailed_location_is_set() {
|
||||||
|
// Create Venue.
|
||||||
|
$venue = tribe_venues()->set_args( Test_The_Events_Calendar::MOCKUP_VENUS['complex_venue'] )->create();
|
||||||
|
// Create a The Events Calendar Event.
|
||||||
|
$wp_object = tribe_events()
|
||||||
|
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['complex_event'] )
|
||||||
|
->set( 'venue', $venue->ID )
|
||||||
|
->create();
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformer->register_shortcodes();
|
||||||
|
|
||||||
|
$summary = '[ap_location]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '📍 Location: Complex Venue, Venue address, Venue zip, Venue city, Venue country', $summary );
|
||||||
|
|
||||||
|
$summary = '[ap_location country="false"]';
|
||||||
|
$summary = do_shortcode( $summary );
|
||||||
|
$this->assertEquals( '📍 Location: Complex Venue, Venue address, Venue zip, Venue city', $summary );
|
||||||
|
|
||||||
|
$transformer->unregister_shortcodes();
|
||||||
|
}
|
||||||
|
}
|
153
tests/test-class-plugin-event-organiser.php
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test class for the integration of the Event Organiser.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_Event_Organiser extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! function_exists( 'eo_get_events' ) ) {
|
||||||
|
self::markTestSkipped( 'Event Organiser plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Run the install script just in time which makes sure the custom tables exist and more.
|
||||||
|
eventorganiser_install();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_transformer_class() {
|
||||||
|
// We only test for one event plugin being active at the same time,
|
||||||
|
// even though we support multiple onces in theory.
|
||||||
|
// But testing all combinations is beyond scope.
|
||||||
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||||
|
|
||||||
|
// Enable ActivityPub support for the event plugin.
|
||||||
|
$this->assertContains( 'event', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
$event_data = array(
|
||||||
|
'start' => new DateTime( '+10 days 15:00:00', eo_get_blog_timezone() ),
|
||||||
|
'end' => new DateTime( '+10 days 16:00:00', eo_get_blog_timezone() ),
|
||||||
|
'all_day' => 0,
|
||||||
|
'schedule' => 'once',
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_data = array(
|
||||||
|
'post_title' => 'Unit Test Event',
|
||||||
|
'post_content' => 'Unit Test description.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_id = eo_insert_event( $post_data, $event_data );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( get_post( $post_id ) );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event_Organiser::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation to ActivityPub for basic event.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_basic_event() {
|
||||||
|
// Mock Event.
|
||||||
|
$event_data = array(
|
||||||
|
'start' => new DateTime( '+10 days 15:00:00', eo_get_blog_timezone() ),
|
||||||
|
'end' => new DateTime( '+10 days 16:00:00', eo_get_blog_timezone() ),
|
||||||
|
'all_day' => 0,
|
||||||
|
'schedule' => 'once',
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_data = array(
|
||||||
|
'post_title' => 'Unit Test Event',
|
||||||
|
'post_content' => 'Unit Test description.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_id = eo_insert_event( $post_data, $event_data );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $post_id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'Unit Test Event', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Unit Test description.', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation to ActivityPub for event with location.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_event_with_location() {
|
||||||
|
// Create venue.
|
||||||
|
$venue_args = array(
|
||||||
|
'description' => 'This is a test venue for the Fediverse.',
|
||||||
|
'address' => 'Fediverse-Street 1337',
|
||||||
|
'city' => 'Fediverse-Town',
|
||||||
|
'state' => 'Fediverse-Sate',
|
||||||
|
'postcode' => '1337',
|
||||||
|
'country' => 'Fediverse-Country',
|
||||||
|
'latitude' => 7.076668,
|
||||||
|
'longitude' => 15.421371,
|
||||||
|
);
|
||||||
|
$venue_name = 'Fediverse Venue';
|
||||||
|
$venue = eo_insert_venue( $venue_name, $venue_args );
|
||||||
|
|
||||||
|
// Mock Event.
|
||||||
|
$event_data = array(
|
||||||
|
'start' => new DateTime( '+10 days 15:00:00', eo_get_blog_timezone() ),
|
||||||
|
'end' => new DateTime( '+10 days 16:00:00', eo_get_blog_timezone() ),
|
||||||
|
'all_day' => 0,
|
||||||
|
'schedule' => 'once',
|
||||||
|
);
|
||||||
|
$post_data = array(
|
||||||
|
'post_title' => 'Unit Test Event',
|
||||||
|
'post_content' => 'Unit Test description.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
);
|
||||||
|
$post_id = eo_insert_event( $post_data, $event_data );
|
||||||
|
wp_set_object_terms( $post_id, $venue['term_id'], 'event-venue' );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $post_id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'Unit Test Event', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Unit Test description.', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( $venue_args['description'], wp_strip_all_tags( $event_array['location']['content'] ) );
|
||||||
|
$this->assertEquals( $venue_args['address'], $event_array['location']['address']['streetAddress'] );
|
||||||
|
$this->assertEquals( $venue_args['city'], $event_array['location']['address']['addressLocality'] );
|
||||||
|
$this->assertEquals( $venue_args['state'], $event_array['location']['address']['addressRegion'] );
|
||||||
|
$this->assertEquals( $venue_args['country'], $event_array['location']['address']['addressCountry'] );
|
||||||
|
$this->assertEquals( $venue_args['postcode'], $event_array['location']['address']['postalCode'] );
|
||||||
|
$this->assertEquals( $venue_name, $event_array['location']['name'] );
|
||||||
|
}
|
||||||
|
}
|
175
tests/test-class-plugin-eventin.php
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Tests for WP Event Solution.
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases for WP Event Solution.
|
||||||
|
*/
|
||||||
|
class Test_Eventin extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Basic Mock-up event.
|
||||||
|
*/
|
||||||
|
private function get_mockup_event(): array {
|
||||||
|
return array(
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_title' => 'Eventin Test Event Title',
|
||||||
|
'post_content' => 'Eventin Test Event Description',
|
||||||
|
'etn_start_date' => \gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ),
|
||||||
|
'etn_end_date' => \gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ),
|
||||||
|
'etn_start_time' => \gmdate( 'H:i', strtotime( '+10 days 15:00:00' ) ),
|
||||||
|
'etn_end_time' => \gmdate( 'H:i', strtotime( '+10 days 16:00:00' ) ),
|
||||||
|
'event_timezone' => 'Europe/Vienna',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! class_exists( '\Wpeventin' ) ) {
|
||||||
|
self::markTestSkipped( 'Eventin plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_eventin_transformer_class() {
|
||||||
|
// We only test for one event plugin being active at the same time,
|
||||||
|
// even though we support multiple onces in theory.
|
||||||
|
// But testing all combinations is beyond scope.
|
||||||
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||||
|
|
||||||
|
// Enable ActivityPub support for the event plugin.
|
||||||
|
$this->assertContains( 'etn', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
// Create a Eventin Event without content.
|
||||||
|
$event = new \Etn\Core\Event\Event_Model();
|
||||||
|
$event->create( $this->get_mockup_event() );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( get_post( $event->id ) );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Eventin::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_eventin_test_minimal_event() {
|
||||||
|
// Create a Eventin Event without content.
|
||||||
|
$event = new \Etn\Core\Event\Event_Model();
|
||||||
|
$event->create( $this->get_mockup_event() );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $event->id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Title', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Description', wp_strip_all_tags( $event_array['content'] ) );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 15:00:00' ) ), $event_array['startTime'] );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 16:00:00' ) ), $event_array['endTime'] );
|
||||||
|
$this->assertEquals( 'Europe/Vienna', $event_array['timezone'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
$this->assertEquals( false, $event_array['isOnline'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_eventin_test_online_event_with_custom_link() {
|
||||||
|
// Create a Eventin Event without content.
|
||||||
|
$event = new \Etn\Core\Event\Event_Model();
|
||||||
|
$args = array_merge(
|
||||||
|
$this->get_mockup_event(),
|
||||||
|
array(
|
||||||
|
'event_type' => 'online',
|
||||||
|
'location' => array(
|
||||||
|
'integration' => 'custom_url',
|
||||||
|
'custom_url' => 'https://jit.si/eventmeeting',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$event->create( $args );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $event->id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Title', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Description', wp_strip_all_tags( $event_array['content'] ) );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 15:00:00' ) ), $event_array['startTime'] );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 16:00:00' ) ), $event_array['endTime'] );
|
||||||
|
$this->assertEquals( 'Europe/Vienna', $event_array['timezone'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
$this->assertEquals( true, $event_array['isOnline'] );
|
||||||
|
$this->assertContains(
|
||||||
|
array(
|
||||||
|
'type' => 'Link',
|
||||||
|
'mediaType' => 'text/html',
|
||||||
|
'name' => 'https://jit.si/eventmeeting',
|
||||||
|
'href' => 'https://jit.si/eventmeeting',
|
||||||
|
),
|
||||||
|
$event_array['attachment']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_eventin_test_online_event_with_physical_location() {
|
||||||
|
// Create a Eventin Event without content.
|
||||||
|
$event = new \Etn\Core\Event\Event_Model();
|
||||||
|
$args = array_merge(
|
||||||
|
$this->get_mockup_event(),
|
||||||
|
array(
|
||||||
|
'event_type' => 'offline',
|
||||||
|
'location' => array(
|
||||||
|
'address' => 'The NlNet center',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$event->create( $args );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $event->id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Title', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Eventin Test Event Description', wp_strip_all_tags( $event_array['content'] ) );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 15:00:00' ) ), $event_array['startTime'] );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '+10 days 16:00:00' ) ), $event_array['endTime'] );
|
||||||
|
$this->assertEquals( 'Europe/Vienna', $event_array['timezone'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $event->id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
$this->assertEquals( false, $event_array['isOnline'] );
|
||||||
|
$this->assertEquals( 'The NlNet center', $event_array['location']['address'] );
|
||||||
|
$this->assertEquals( 'The NlNet center', $event_array['location']['name'] );
|
||||||
|
}
|
||||||
|
}
|
186
tests/test-class-plugin-eventprime.php
Normal file
|
@ -0,0 +1,186 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Class SampleTest
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_EventPrime extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Mockup venues of certain complexity.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $mockup_venue = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mockup events for tests.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $mockup_events = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! class_exists( '\Eventprime_Basic_Functions' ) ) {
|
||||||
|
self::markTestSkipped( 'The EventPrime Calendar management plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aeb = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aeb->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
|
||||||
|
$this->setup_mockup_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup mockup events.
|
||||||
|
*/
|
||||||
|
private function setup_mockup_data() {
|
||||||
|
$this->mockup_events = array(
|
||||||
|
'minimal_event' => array(
|
||||||
|
'name' => 'EventPrime Event title',
|
||||||
|
'description' => 'EventPrime event description',
|
||||||
|
'status' => 'Publish',
|
||||||
|
'em_event_type' => '',
|
||||||
|
'em_venue' => '',
|
||||||
|
'em_organizer' => '',
|
||||||
|
'em_performer' => '',
|
||||||
|
'em_start_date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
'em_end_date' => strtotime( '+10 days 16:00:00' ),
|
||||||
|
'em_enable_booking' => 'bookings_off',
|
||||||
|
'em_ticket_price' => 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->mockup_venue = array(
|
||||||
|
'name' => 'Test Venue',
|
||||||
|
'address' => 'Fediverse-street 1337, 1234 Fediverse-town',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_the_events_calendar_transformer_class() {
|
||||||
|
// We only test for one event plugin being active at the same time,
|
||||||
|
// even though we support multiple onces in theory.
|
||||||
|
// But testing all combinations is beyond scope.
|
||||||
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||||
|
|
||||||
|
// Enable ActivityPub support for the event plugin.
|
||||||
|
$this->assertContains( 'em_event', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
// Create an EventPrime Event without content.
|
||||||
|
$ep_functions = new Eventprime_Basic_Functions();
|
||||||
|
|
||||||
|
$post_id = $ep_functions->insert_event_post_data( $this->mockup_events['minimal_event'] );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\EventPrime::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_transformation_of_minimal_event() {
|
||||||
|
// Create an EventPrime Event without content.
|
||||||
|
$ep_functions = new Eventprime_Basic_Functions();
|
||||||
|
|
||||||
|
$post_id = $ep_functions->insert_event_post_data( $this->mockup_events['minimal_event'] );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'EventPrime Event title', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'EventPrime event description', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertTrue( $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( 'allow_all', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_transformation_of_minimal_event_with_venue() {
|
||||||
|
// Create an EventPrime Event without content.
|
||||||
|
$ep_functions = new Eventprime_Basic_Functions();
|
||||||
|
|
||||||
|
$venue_term_id = wp_insert_term( $this->mockup_venue['name'], 'em_venue' )['term_id'];
|
||||||
|
add_term_meta( $venue_term_id, 'em_address', $this->mockup_venue['address'], true );
|
||||||
|
add_term_meta( $venue_term_id, 'em_display_address_on_frontend', true, true );
|
||||||
|
|
||||||
|
$event_data = $this->mockup_events['minimal_event'];
|
||||||
|
$event_data['em_venue'] = $venue_term_id;
|
||||||
|
|
||||||
|
$post_id = $ep_functions->insert_event_post_data( $event_data );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'EventPrime Event title', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'EventPrime event description', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertTrue( $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( 'allow_all', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( $this->mockup_venue['name'], $event_array['location']['name'] );
|
||||||
|
$this->assertEquals( $this->mockup_venue['address'], $event_array['location']['address'] );
|
||||||
|
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation of minimal event with venue which has a hidden address.
|
||||||
|
*/
|
||||||
|
public function test_transformation_of_minimal_event_with_venue_with_hidden_address() {
|
||||||
|
// Create an EventPrime Event without content.
|
||||||
|
$ep_functions = new Eventprime_Basic_Functions();
|
||||||
|
|
||||||
|
$venue_term_id = wp_insert_term( $this->mockup_venue['name'], 'em_venue' )['term_id'];
|
||||||
|
add_term_meta( $venue_term_id, 'em_address', $this->mockup_venue['address'], true );
|
||||||
|
add_term_meta( $venue_term_id, 'em_display_address_on_frontend', false, true );
|
||||||
|
|
||||||
|
$event_data = $this->mockup_events['minimal_event'];
|
||||||
|
$event_data['em_venue'] = $venue_term_id;
|
||||||
|
|
||||||
|
$post_id = $ep_functions->insert_event_post_data( $event_data );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertArrayNotHasKey( 'address', $event_array['location'] );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Class SampleTest
|
* Class SampleTest
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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_Extensions\Setup::get_instance();
|
$aec = \Event_Bridge_For_ActivityPub\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_Extensions\Setup::get_instance()->get_active_event_plugins();
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\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' => 'published',
|
'post_status' => 'publish',
|
||||||
'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_Extensions\Activitypub\Transformer\Events_Manager::class, $transformer );
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\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 = 'published';
|
$event->force_status = 'publish';
|
||||||
$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_array['content'] );
|
$this->assertEquals( 'Event description', wp_strip_all_tags( $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 = 'published';
|
$event->force_status = 'publish';
|
||||||
$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_array['content'] );
|
$this->assertEquals( 'Event description', wp_strip_all_tags( $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 = 'published';
|
$event->force_status = 'publish';
|
||||||
$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_array['content'] );
|
$this->assertEquals( 'Event description', wp_strip_all_tags( $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'] );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Class SampleTest
|
* Class SampleTest
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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_Extensions\Setup::get_instance();
|
$aec = \Event_Bridge_For_ActivityPub\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_Extensions\Setup::get_instance()->get_active_event_plugins();
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\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,6 +49,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',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$event = new \GatherPress\Core\Event( $post_id );
|
$event = new \GatherPress\Core\Event( $post_id );
|
||||||
|
@ -64,7 +65,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_Extensions\Activitypub\Transformer\GatherPress::class, $transformer );
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\GatherPress::class, $transformer );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +78,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' => 'published',
|
'post_status' => 'publish',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$event = new \GatherPress\Core\Event( $post_id );
|
$event = new \GatherPress\Core\Event( $post_id );
|
||||||
|
@ -94,7 +95,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.', $event_array['content'] );
|
$this->assertEquals( 'Unit Test description.', wp_strip_all_tags( $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'] );
|
||||||
|
|
185
tests/test-class-plugin-modern-events-calendar-lite.php
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Tests or Modern Events Calendar Lite
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_Modern_Events_Calendar_Lite extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* The MEC main instance.
|
||||||
|
*
|
||||||
|
* @var \MEC_main|null
|
||||||
|
*/
|
||||||
|
protected $mec_main;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! class_exists( '\MEC' ) ) {
|
||||||
|
self::markTestSkipped( 'Modern Events Calendar Lite is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
$this->mec_main = \MEC::getInstance( 'app.libraries.main' );
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_modern_events_calendar_lite_transformer_class() {
|
||||||
|
// We only test for one event plugin being active at the same time,
|
||||||
|
// even though we support multiple onces in theory.
|
||||||
|
// But testing all combinations is beyond scope.
|
||||||
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||||
|
|
||||||
|
// Enable ActivityPub support for the event plugin.
|
||||||
|
$this->assertContains( 'mec-events', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
// Insert a new Event.
|
||||||
|
$event = array(
|
||||||
|
'title' => 'MEC Test Event',
|
||||||
|
'status' => 'publish',
|
||||||
|
'start_time_hour' => '3',
|
||||||
|
'start_time_minutes' => '00',
|
||||||
|
'start_time_ampm' => 'PM',
|
||||||
|
'start' => '2025-01-01',
|
||||||
|
'end' => '2025-01-01',
|
||||||
|
'end_time_hour' => '4',
|
||||||
|
'end_time_minutes' => '00',
|
||||||
|
'end_time_ampm' => 'PM',
|
||||||
|
'repeat_status' => 0,
|
||||||
|
'repeat_type' => 'daily',
|
||||||
|
'interval' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_id = $this->mec_main->save_event( $event );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Modern_Events_Calendar_Lite::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the transformation of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_modern_events_calendar_lite_minimal_event() {
|
||||||
|
$start_timestamp = strtotime( '+10 days 15:00:00' );
|
||||||
|
$end_timestamp = strtotime( '+10 days 16:00:00' );
|
||||||
|
|
||||||
|
// Insert a new Event.
|
||||||
|
$event = array(
|
||||||
|
'title' => 'MEC Test Event',
|
||||||
|
'status' => 'publish',
|
||||||
|
'content' => 'This is the content of the MEC!',
|
||||||
|
'start_time_hour' => gmdate( 'h', $start_timestamp ),
|
||||||
|
'start_time_minutes' => gmdate( 'i', $start_timestamp ),
|
||||||
|
'start_time_ampm' => gmdate( 'A', $start_timestamp ),
|
||||||
|
'start' => gmdate( 'Y-m-d', $start_timestamp ),
|
||||||
|
'end' => gmdate( 'Y-m-d', $end_timestamp ),
|
||||||
|
'end_time_hour' => gmdate( 'h', $end_timestamp ),
|
||||||
|
'end_time_minutes' => gmdate( 'i', $end_timestamp ),
|
||||||
|
'end_time_ampm' => gmdate( 'A', $end_timestamp ),
|
||||||
|
'repeat_status' => 0,
|
||||||
|
'repeat_type' => 'daily',
|
||||||
|
'interval' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_id = $this->mec_main->save_event( $event );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer to make the ActivityStreams representation of the event.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();
|
||||||
|
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'MEC Test Event', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'This is the content of the MEC!', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertTrue( $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( 'allow_all', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( get_permalink( $wp_object ), $event_array['externalParticipationUrl'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the transformation of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_modern_events_calendar_lite_event_with_location() {
|
||||||
|
$start_timestamp = strtotime( '+10 days 15:00:00' );
|
||||||
|
$end_timestamp = strtotime( '+10 days 16:00:00' );
|
||||||
|
|
||||||
|
// Add new location.
|
||||||
|
$location = array(
|
||||||
|
'name' => 'MEC Location',
|
||||||
|
'latitude' => '52.356370',
|
||||||
|
'longitude' => '4.955760',
|
||||||
|
'address' => 'Stichting NLnet, Science Park 400, 1098 XH Amsterdam',
|
||||||
|
'url' => 'https://nlnet.nl/',
|
||||||
|
);
|
||||||
|
|
||||||
|
$location_id = $this->mec_main->save_location( $location );
|
||||||
|
|
||||||
|
// Insert a new Event.
|
||||||
|
$event = array(
|
||||||
|
'title' => 'MEC Test Event',
|
||||||
|
'status' => 'publish',
|
||||||
|
'content' => 'This is the content of the MEC!',
|
||||||
|
'start_time_hour' => gmdate( 'h', $start_timestamp ),
|
||||||
|
'start_time_minutes' => gmdate( 'i', $start_timestamp ),
|
||||||
|
'start_time_ampm' => gmdate( 'A', $start_timestamp ),
|
||||||
|
'start' => gmdate( 'Y-m-d', $start_timestamp ),
|
||||||
|
'end' => gmdate( 'Y-m-d', $end_timestamp ),
|
||||||
|
'end_time_hour' => gmdate( 'h', $end_timestamp ),
|
||||||
|
'end_time_minutes' => gmdate( 'i', $end_timestamp ),
|
||||||
|
'end_time_ampm' => gmdate( 'A', $end_timestamp ),
|
||||||
|
'repeat_status' => 0,
|
||||||
|
'repeat_type' => 'daily',
|
||||||
|
'interval' => 1,
|
||||||
|
'location_id' => $location_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
$post_id = $this->mec_main->save_event( $event );
|
||||||
|
|
||||||
|
$wp_object = get_post( $post_id );
|
||||||
|
|
||||||
|
// Call the transformer to make the ActivityStreams representation of the event.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $wp_object )->to_object()->to_array();
|
||||||
|
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'MEC Test Event', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'This is the content of the MEC!', wp_strip_all_tags( $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 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertTrue( $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( 'allow_all', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( get_permalink( $wp_object ), $event_array['externalParticipationUrl'] );
|
||||||
|
$this->assertArrayHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
$this->assertEquals( $location['address'], $event_array['location']['address'] );
|
||||||
|
$this->assertEquals( $location['name'], $event_array['location']['name'] );
|
||||||
|
$this->assertEquals( $location['latitude'], $event_array['location']['latitude'] );
|
||||||
|
$this->assertEquals( $location['longitude'], $event_array['location']['longitude'] );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Class SampleTest
|
* Class SampleTest
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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. Let\'s connect!',
|
'content' => 'Come to my event!',
|
||||||
'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. Let\'s connect!',
|
'content' => 'Come to my event!',
|
||||||
'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_Extensions\Setup::get_instance();
|
$aec = \Event_Bridge_For_ActivityPub\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_Extensions\Setup::get_instance()->get_active_event_plugins();
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\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_Extensions\Activitypub\Transformer\The_Events_Calendar::class, $transformer );
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\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( '', $event_array['content'] );
|
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $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_extensions_default_event_category', 'MUSIC' );
|
update_option( 'event_bridge_for_activitypub_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_extensions_event_category_mappings', array( 'theatre' => 'THEATRE' ) );
|
update_option( 'event_bridge_for_activitypub_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( '', $event_array['content'] );
|
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $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( '', $event_array['content'] );
|
$this->assertEquals( 'Come to my event!', wp_strip_all_tags( $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'] );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Class SampleTest
|
* Class SampleTest
|
||||||
*
|
*
|
||||||
* @package Activitypub_Event_Extensions
|
* @package Event_Bridge_For_ActivityPub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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_Extensions\Setup::get_instance();
|
$aec = \Event_Bridge_For_ActivityPub\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_Extensions\Setup::get_instance()->get_active_event_plugins();
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\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.
|
||||||
|
@ -44,7 +44,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
||||||
$wp_post_id = wp_insert_post(
|
$wp_post_id = wp_insert_post(
|
||||||
array(
|
array(
|
||||||
'post_title' => 'VSEL Test Event',
|
'post_title' => 'VSEL Test Event',
|
||||||
'post_status' => 'published',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'event',
|
'post_type' => 'event',
|
||||||
'meta_input' => array(
|
'meta_input' => array(
|
||||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
@ -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_Extensions\Activitypub\Transformer\VS_Event_List::class, $transformer );
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\VS_Event_List::class, $transformer );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
||||||
$wp_post_id = wp_insert_post(
|
$wp_post_id = wp_insert_post(
|
||||||
array(
|
array(
|
||||||
'post_title' => 'VSEL Test Event',
|
'post_title' => 'VSEL Test Event',
|
||||||
'post_status' => 'published',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'event',
|
'post_type' => 'event',
|
||||||
'meta_input' => array(
|
'meta_input' => array(
|
||||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
@ -102,7 +102,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
||||||
$wp_post_id = wp_insert_post(
|
$wp_post_id = wp_insert_post(
|
||||||
array(
|
array(
|
||||||
'post_title' => 'VSEL Test Event',
|
'post_title' => 'VSEL Test Event',
|
||||||
'post_status' => 'published',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'event',
|
'post_type' => 'event',
|
||||||
'meta_input' => array(
|
'meta_input' => array(
|
||||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
@ -147,7 +147,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
||||||
$wp_post_id = wp_insert_post(
|
$wp_post_id = wp_insert_post(
|
||||||
array(
|
array(
|
||||||
'post_title' => 'VSEL Test Event',
|
'post_title' => 'VSEL Test Event',
|
||||||
'post_status' => 'published',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'event',
|
'post_type' => 'event',
|
||||||
'meta_input' => array(
|
'meta_input' => array(
|
||||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
@ -173,16 +173,16 @@ 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_extensions_default_event_category', 'MUSIC' );
|
update_option( 'event_bridge_for_activitypub_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_extensions_event_category_mappings', array( 'theatre' => 'THEATRE' ) );
|
update_option( 'event_bridge_for_activitypub_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(
|
||||||
array(
|
array(
|
||||||
'post_title' => 'VSEL Test Event',
|
'post_title' => 'VSEL Test Event',
|
||||||
'post_status' => 'published',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'event',
|
'post_type' => 'event',
|
||||||
'meta_input' => array(
|
'meta_input' => array(
|
||||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
|
182
tests/test-class-plugin-wp-event-manager.php
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Class SampleTest
|
||||||
|
*
|
||||||
|
* @package Event_Bridge_For_ActivityPub
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_WP_Event_Manager extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Override the setup function, so that tests don't run if the Events Calendar is not active.
|
||||||
|
*/
|
||||||
|
public function set_up() {
|
||||||
|
parent::set_up();
|
||||||
|
|
||||||
|
if ( ! function_exists( 'wp_event_manager_notify_new_user' ) ) {
|
||||||
|
self::markTestSkipped( 'WP Event Manager plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||||
|
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
|
||||||
|
$aec->activate_activitypub_support_for_active_event_plugins();
|
||||||
|
|
||||||
|
// Delete all posts afterwards.
|
||||||
|
_delete_all_posts();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the right transformer gets applied.
|
||||||
|
*/
|
||||||
|
public function test_transformer_class() {
|
||||||
|
// We only test for one event plugin being active at the same time,
|
||||||
|
// even though we support multiple onces in theory.
|
||||||
|
// But testing all combinations is beyond scope.
|
||||||
|
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
|
||||||
|
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||||
|
|
||||||
|
// Enable ActivityPub support for the event plugin.
|
||||||
|
$this->assertContains( 'event_listing', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
// Insert a new Event.
|
||||||
|
$wp_post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'WP Event Manager TestEvent',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'event_listing',
|
||||||
|
'meta_input' => array(
|
||||||
|
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$wp_object = get_post( $wp_post_id );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \Event_Bridge_For_ActivityPub\Activitypub\Transformer\WP_Event_Manager::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the transformation to ActivityStreams of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_minimal_event() {
|
||||||
|
// Insert a new Event.
|
||||||
|
$wp_post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'WP Event Manager TestEvent',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'event_listing',
|
||||||
|
'post_content' => 'Come to my WP Event Manager event!',
|
||||||
|
'meta_input' => array(
|
||||||
|
'_event_start_date' => strtotime( '+10 days 15:00:00' ),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Transform the event to ActivityStreams.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $wp_post_id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'WP Event Manager TestEvent', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Come to my WP Event Manager event!', wp_strip_all_tags( $event_array['content'] ) );
|
||||||
|
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
|
||||||
|
$this->assertArrayNotHasKey( 'endTime', $event_array );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( esc_url( get_permalink( $wp_post_id ) ), $event_array['externalParticipationUrl'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the transformation to ActivityStreams of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_full_online_event() {
|
||||||
|
// Insert a new Event.
|
||||||
|
$wp_post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'WP Event Manager TestEvent',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'event_listing',
|
||||||
|
'post_content' => 'Come to my WP Event Manager event!',
|
||||||
|
'meta_input' => array(
|
||||||
|
'_event_start_date' => \gmdate( 'Y-m-d H:i:s', strtotime( '+10 days 15:00:00' ) ),
|
||||||
|
'_event_end_date' => \gmdate( 'Y-m-d H:i:s', strtotime( '+10 days 16:00:00' ) ),
|
||||||
|
'_event_video_url' => 'https://event-federation.eu/meeting-room',
|
||||||
|
'_event_online' => 'yes',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Transform the event to ActivityStreams.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $wp_post_id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'WP Event Manager TestEvent', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Come to my WP Event Manager event!', wp_strip_all_tags( $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' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( true, $event_array['isOnline'] );
|
||||||
|
$this->assertEquals( esc_url( get_permalink( $wp_post_id ) ), $event_array['externalParticipationUrl'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||||
|
$this->assertContains(
|
||||||
|
array(
|
||||||
|
'type' => 'Link',
|
||||||
|
'name' => __( 'Video URL', 'event-bridge-for-activitypub' ),
|
||||||
|
'href' => 'https://event-federation.eu/meeting-room',
|
||||||
|
'mediaType' => 'text/html',
|
||||||
|
),
|
||||||
|
$event_array['attachment']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the transformation to ActivityStreams of minimal event.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_event_with_location() {
|
||||||
|
// Insert a new Event.
|
||||||
|
$wp_post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'WP Event Manager TestEvent',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'event_listing',
|
||||||
|
'post_content' => 'Come to my WP Event Manager event!',
|
||||||
|
'meta_input' => array(
|
||||||
|
'_event_start_date' => \gmdate( 'Y-m-d H:i:s', strtotime( '+10 days 15:00:00' ) ),
|
||||||
|
'_event_end_date' => \gmdate( 'Y-m-d H:i:s', strtotime( '+10 days 16:00:00' ) ),
|
||||||
|
'_event_location' => 'Some text location',
|
||||||
|
'_event_online' => 'no',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Transform the event to ActivityStreams.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $wp_post_id ) )->to_object()->to_array();
|
||||||
|
|
||||||
|
// Check that the event ActivityStreams representation contains everything as expected.
|
||||||
|
$this->assertEquals( 'Event', $event_array['type'] );
|
||||||
|
$this->assertEquals( 'WP Event Manager TestEvent', $event_array['name'] );
|
||||||
|
$this->assertEquals( 'Come to my WP Event Manager event!', wp_strip_all_tags( $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' ) ) . 'T16:00:00Z', $event_array['endTime'] );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ), $event_array['commentsEnabled'] );
|
||||||
|
$this->assertEquals( comments_open( $wp_post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||||
|
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||||
|
$this->assertEquals( false, $event_array['isOnline'] );
|
||||||
|
$this->assertEquals( esc_url( get_permalink( $wp_post_id ) ), $event_array['externalParticipationUrl'] );
|
||||||
|
$this->assertArrayHasKey( 'location', $event_array );
|
||||||
|
$this->assertEquals( 'Some text location', $event_array['location']['address'] );
|
||||||
|
}
|
||||||
|
}
|