From d4ea449d3d36ff63b3a3ca0a97d8ddc7444655bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Wed, 22 Nov 2023 18:37:43 +0100 Subject: [PATCH] add draft for example transformer --- Transformers/index.md | 8 +- Transformers/the-events-calendar-example.md | 115 ++++++++++++++++++++ 2 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 Transformers/the-events-calendar-example.md diff --git a/Transformers/index.md b/Transformers/index.md index 306de25..1652fba 100644 --- a/Transformers/index.md +++ b/Transformers/index.md @@ -6,18 +6,18 @@ The WordPress ActivityPub plugin comes with a built-in transformer which lets yo Other plugins can register new transformers and unregister existing ones. -* [Add New Transformer](./add-transformer/) -* [Remove Transformer](./remove-transformer/) +* [Add New Transformer](./add-transformer.md/) +* [Remove Transformer](./remove-transformer.md/) ## Creating New Transformers Learn more about transformer anatomy and how to create your own: -* [Transformer Structure](./transformer-structure/) +* [Transformer Structure](./transformer-structure.md/) ## Code Examples See the following examples to see how easy it is. -* [The Events Calendar](./simple-example/) +* [The Events Calendar](./the-events-calendar-example.md/) diff --git a/Transformers/the-events-calendar-example.md b/Transformers/the-events-calendar-example.md new file mode 100644 index 0000000..b7e5d79 --- /dev/null +++ b/Transformers/the-events-calendar-example.md @@ -0,0 +1,115 @@ +## Folder Structure +You need at least two files. One file for the transformer itself and one file for registering it. +``` +activitypub-tribe-transformer/ +| +├─ activitypub/ +| └─ transformer/ +| └─ tribe.php +| +└─ activitypub-tribe-transformer.php +``` + +## Plugin Files +**activitypub-tribe-transformer-php** +```php +register( new \Tribe() ); +} + +add_action( 'activitypub_transformers_register', 'register_tribe_transformer' ); +``` + +**activtiypub/transformer/tribe.php** +```php +