add license and readme
Some checks failed
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Failing after 6s

This commit is contained in:
André Menrath 2023-12-04 19:27:57 +01:00
parent 788f1b13da
commit 49aeff105f
7 changed files with 31 additions and 39 deletions

View file

@ -0,0 +1,5 @@
This is a WordPress plugin that contains several example custom transformers for the [WordPress ActivityPub plugin](https://wordpress.org/plugins/activitypub/). It works like an add-on for it.
Note that this plugin does not yet work with the latest release of the ActivityPub plugin. A pull request is already open: https://github.com/Automattic/wordpress-activitypub/pull/569
But if you want to test it you likely need the latest development branch of the ActivityPub plugin which you can find here: https://code.event-federation.eu/Event-Federation/wordpress-activitypub/src/branch/dev/extendable-transformers

View file

@ -7,10 +7,12 @@
* Author: André Menrath
* Author URI: https://graz.social/@linos
* Text Domain: activitypub-event-transformers
* License: AGPL-3.0-or-later
*
* ActivityPub tested up to: 1.2.0
*
* @package activitypub-event-transformer
* @license AGPL-3.0-or-later
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -18,9 +20,9 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
* Register Tribe Transformer.
* Register Event Transformers.
*
* Include fransformer file and register transformer class.
* Include fransformer class file and register the transformer class.
*
* @since 1.0.0
* @param \Activitypub\Transformer\Transformer_Factory $transformers_manager ActivtiyPub transformers manager.
@ -34,17 +36,4 @@ function register_event_transformers( $transformers_manager ) {
$transformers_manager->register( new \VS_Event() );
}
add_filter(
'activitypub_json_context',
function ( $context ) {
$context[2]['commentsEnabled'] = array(
'@id' => 'pt:commentsEnabled',
'@type' => 'sc:Boolean',
);
return $context;
},
10,
2
);
add_action( 'activitypub_transformers_register', 'register_event_transformers' );

View file

@ -3,6 +3,7 @@
* ActivityPub Object of type Event.
*
* @package activity-event-transformers
* @license AGPL-3.0-or-later
*/
use function Activitypub\snake_to_camel_case;
@ -33,7 +34,6 @@ class Event extends \Activitypub\Activity\Base_Object {
* repliesModerationOption.
*
* @context https://joinpeertube.org/ns#commentsEnabled
*
* @see https://docs.joinpeertube.org/api/activitypub#video
* @see https://docs.joinmobilizon.org/contribute/activity_pub/
* @var bool|null
@ -48,7 +48,6 @@ class Event extends \Activitypub\Activity\Base_Object {
/**
* @context https://joinmobilizon.org/ns#repliesModerationOption
*
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#repliesmoderation
* @var string
*/
@ -56,7 +55,6 @@ class Event extends \Activitypub\Activity\Base_Object {
/**
* @context https://joinmobilizon.org/ns#anonymousParticipationEnabled
*
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#anonymousparticipationenabled
* @var bool
*/

View file

@ -4,6 +4,7 @@
* Activity Streams Event object type
*
* @package activity-event-transformers
* @license AGPL-3.0-or-later
*/
/**

View file

@ -4,6 +4,7 @@
* derived from https://schema.org/PostalAddress.
*
* @package activity-event-transformers
* @license AGPL-3.0-or-later
*/
/**

View file

@ -3,6 +3,7 @@
* ActivityPub Tribe Transformer
*
* @package activity-event-transformers
* @license AGPL-3.0-or-later
*/
if ( ! defined( 'ABSPATH' ) ) {

View file

@ -3,6 +3,7 @@
* ActivityPub Transformer for VS Event.
*
* @package activity-event-transformers
* @license AGPL-3.0-or-later
*/
require_once __DIR__ . '/../object/class-event.php';
@ -78,23 +79,11 @@ class VS_Event extends \Activitypub\Transformer\Base {
* @returns array The Place.
*/
public function get_event_location( $post_id ) {
$object = new Place();
$object->set_type( 'Place' );
$address = get_post_meta( $post_id, 'event-location', true );
$object->set_name( $address );
$object->set_address( $address );
return $object;
}
/**
* Test
*
* @param string $context context.
* @return string $context context.
*/
private function add_pt_comments_enabled_context( $context ) {
$test = $context;
return $context;
return ( new Place() )
->set_type( 'Place' )
->set_name( $address )
->set_address( $address );
}
/**
@ -111,24 +100,31 @@ class VS_Event extends \Activitypub\Transformer\Base {
private function get_event_link() {
$event_link = get_post_meta( $this->wp_post->ID, 'event-link', true );
if ( $event_link ) {
return array(
return [
'type' => 'Link',
'name' => 'Website',
'href' => \esc_url( get_post_meta( $post_id, 'event-location', true ) ),
'mediaType' => 'text/html',
);
];
}
}
/**
* Extends the get_attachments function to also add the event Link.
* Overrides/extends the get_attachments function to also add the event Link.
*/
protected function get_attachments() {
$attachments = parent::get_attachments();
$attachments[] = $this->get_event_link();
$event_link = $this->get_event_link();
if ( $event_link ) {
$attachments[] = $this->get_event_link();
}
return $attachments;
}
private function get_category() {
return 'MEETING';
}
/**
* Transforms the VS Event WP_Post object to an ActivityPub Event Object.
*
@ -192,7 +188,8 @@ class VS_Event extends \Activitypub\Transformer\Base {
->set_replies_moderation_option( 'allow_all' )
->set_join_mode( 'external' )
->set_external_participation_url( $this->get_url() )
->set_ical_status( 'CONFIRMED' );
->set_status( 'CONFIRMED' )
->set_category( 'MEETING' );
return $object;
}