|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wordlift\Vocabulary\Data\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Wordlift\Vocabulary\Api\Entity_Rest_Endpoint; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* This class is created to provide compatibility for the legacy matches stored on the db, |
|
9
|
|
|
* for saving the data from match entity endpoint, this wont be used. |
|
10
|
|
|
* @since 3.30.0 |
|
11
|
|
|
* @author Naveen Muthusamy <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class Legacy_Entity extends Entity { |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* This function is called when default entity doesnt find any data. |
|
17
|
|
|
* @return array |
|
18
|
|
|
*/ |
|
19
|
|
|
public function get_jsonld_data() { |
|
20
|
|
|
$tag = get_term( $this->term_id ); |
|
21
|
|
|
|
|
22
|
|
|
return array( |
|
23
|
|
|
'@id' => get_term_link( $tag->term_id ) . '#id', |
|
24
|
|
|
'@type' => get_term_meta( $tag->term_id, Entity_Rest_Endpoint::TYPE_META_KEY, true ), |
|
25
|
|
|
'name' => $tag->name, |
|
26
|
|
|
'description' => ! empty( $tag->description ) ?: get_term_meta( $tag->term_id, Entity_Rest_Endpoint::DESCRIPTION_META_KEY, true ), |
|
27
|
|
|
'sameAs' => get_term_meta( $tag->term_id, Entity_Rest_Endpoint::SAME_AS_META_KEY ), |
|
28
|
|
|
'alternateName' => get_term_meta( $tag->term_id, Entity_Rest_Endpoint::ALTERNATIVE_LABEL_META_KEY ) |
|
29
|
|
|
); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* This function is never used. |
|
34
|
|
|
* |
|
35
|
|
|
* @param \WP_REST_Request $request |
|
36
|
|
|
* |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
|
|
public function save_jsonld_data( $request ) { |
|
40
|
|
|
return false; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function clear_data() { |
|
44
|
|
|
delete_term_meta( $this->term_id, Entity_Rest_Endpoint::SAME_AS_META_KEY ); |
|
45
|
|
|
delete_term_meta( $this->term_id, Entity_Rest_Endpoint::ALTERNATIVE_LABEL_META_KEY ); |
|
46
|
|
|
delete_term_meta( $this->term_id, Entity_Rest_Endpoint::DESCRIPTION_META_KEY ); |
|
47
|
|
|
delete_term_meta( $this->term_id, Entity_Rest_Endpoint::TYPE_META_KEY ); |
|
48
|
|
|
delete_term_meta( $this->term_id, Entity_Rest_Endpoint::EXTERNAL_ENTITY_META_KEY ); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|