|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Sync_Module_Terms extends Jetpack_Sync_Module { |
|
4
|
|
|
private $taxonomy_whitelist; |
|
5
|
|
|
|
|
6
|
|
|
function name() { |
|
7
|
|
|
return "terms"; |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
function init_listeners( $callable ) { |
|
11
|
|
|
add_action( 'created_term', array( $this, 'save_term_handler' ), 10, 3 ); |
|
12
|
|
|
add_action( 'edited_term', array( $this, 'save_term_handler' ), 10, 3 ); |
|
13
|
|
|
add_action( 'jetpack_sync_save_term', $callable, 10, 4 ); |
|
14
|
|
|
add_action( 'delete_term', $callable, 10, 4 ); |
|
15
|
|
|
add_action( 'set_object_terms', $callable, 10, 6 ); |
|
16
|
|
|
add_action( 'deleted_term_relationships', $callable, 10, 2 ); |
|
17
|
|
|
|
|
18
|
|
|
//full sync |
|
19
|
|
|
add_action( 'jetpack_full_sync_terms', $callable, 10, 2 ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
function save_term_handler( $term_id, $tt_id, $taxonomy ) { |
|
23
|
|
|
if ( class_exists( 'WP_Term' ) ) { |
|
24
|
|
|
$term_object = WP_Term::get_instance( $term_id, $taxonomy ); |
|
25
|
|
|
} else { |
|
26
|
|
|
$term_object = get_term_by( 'id', $term_id, $taxonomy ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Fires when the client needs to sync a new term |
|
31
|
|
|
* |
|
32
|
|
|
* @since 4.2.0 |
|
33
|
|
|
* |
|
34
|
|
|
* @param object the Term object |
|
35
|
|
|
*/ |
|
36
|
|
|
do_action( 'jetpack_sync_save_term', $term_object ); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function set_taxonomy_whitelist( $taxonomies ) { |
|
40
|
|
|
$this->taxonomy_whitelist = $taxonomies; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function set_defaults() { |
|
44
|
|
|
$this->taxonomy_whitelist = Jetpack_Sync_Defaults::$default_taxonomy_whitelist; |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
} |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.