| 1 |
<?php |
| 2 |
/** |
| 3 |
* Term Transformer Class file. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub\Transformer; |
| 9 |
|
| 10 |
/** |
| 11 |
* Term Transformer Class. |
| 12 |
*/ |
| 13 |
class Term extends Base { |
| 14 |
/** |
| 15 |
* Transforms the WP_Term object to an OrderedCollection. |
| 16 |
* |
| 17 |
* @see \Activitypub\Activity\Base_Object |
| 18 |
* |
| 19 |
* @return \Activitypub\Activity\Base_Object|\WP_Error The OrderedCollection or WP_Error on failure. |
| 20 |
*/ |
| 21 |
public function to_object() { |
| 22 |
$base_object = new \Activitypub\Activity\Base_Object(); |
| 23 |
$base_object->{'@context'} = 'https://www.w3.org/ns/activitystreams'; |
| 24 |
$base_object->set_type( 'OrderedCollection' ); |
| 25 |
$base_object->set_id( \get_term_link( $this->item ) ); |
| 26 |
|
| 27 |
return $base_object; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Get the OrderedCollection ID (term link). |
| 32 |
* |
| 33 |
* @return string The OrderedCollection ID (term link). |
| 34 |
*/ |
| 35 |
public function to_id() { |
| 36 |
return \get_term_link( $this->item ); |
| 37 |
} |
| 38 |
} |
| 39 |
|