Completed
Push — fix/inline-docs-410 ( f96891...63b75c )
by
unknown
43:24 queued 33:40
created

Jetpack_Sync_Module_Terms   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 44
rs 10
wmc 6
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 11 1
A save_term_handler() 0 16 2
A set_taxonomy_whitelist() 0 3 1
A set_defaults() 0 3 1
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;
0 ignored issues
show
Bug introduced by
The property default_taxonomy_whitelist cannot be accessed from this context as it is declared private in class Jetpack_Sync_Defaults.

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.

Loading history...
45
	}
46
}