38 lines
1.1 KiB
Markdown
38 lines
1.1 KiB
Markdown
# Widget Structure
|
|
|
|
To create a custom ActivityPub Transformer start by creating a class that extends the `\Activitypub\Transformer\Base` class and fill in all the required methods.
|
|
|
|
Each transformer needs to have a few basic settings — a unique name that will identify the transformer, a label that will be used as the title when being displayed in the settings section, and a list of supported post types that the transformer can use as an input.
|
|
|
|
## Widget Class
|
|
|
|
First, we need to create a class that extends the `\Activitypub\Transformer\Base` class:
|
|
|
|
```php
|
|
class Acivitypub_Test_Transformer extends \Activitypub\Transformer\Base {
|
|
}
|
|
```
|
|
|
|
## Transformer Methods
|
|
|
|
A simple transformer skeleton class will look as follows:
|
|
|
|
```php
|
|
class Acivitypub_Test_Transformer extends \Activitypub\Transformer\Base {
|
|
public function get_name() {}
|
|
|
|
public function get_label() {}
|
|
|
|
public function get_object_type() {}
|
|
|
|
public function supported_post_types() {}
|
|
|
|
public function to_object() {}
|
|
|
|
// TODO
|
|
}
|
|
```
|
|
|
|
The `\Activitypub\Transformer\Base` class has many more methods, but the vast majority of your needs are covered by the methods mentioned above.
|
|
|
|
// TODO
|