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

Jetpack_Sync_Module_Meta   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 13 2
A filter_meta() 0 7 3
1
<?php
2
3
class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module {
4
	private $meta_types = array( 'post', 'comment' );
5
6
	public function name() {
7
		return "meta";
8
	}
9
10
	public function init_listeners( $callable ) {
11
		$whitelist_handler = array( $this, 'filter_meta' );
12
13
		foreach ( $this->meta_types as $meta_type ) {
14
			add_action( "added_{$meta_type}_meta", $callable, 10, 4 );
15
			add_action( "updated_{$meta_type}_meta", $callable, 10, 4 );
16
			add_action( "deleted_{$meta_type}_meta", $callable, 10, 4 );
17
18
			add_filter( "jetpack_sync_before_enqueue_added_{$meta_type}_meta", $whitelist_handler );
19
			add_filter( "jetpack_sync_before_enqueue_updated_{$meta_type}_meta", $whitelist_handler );
20
			add_filter( "jetpack_sync_before_enqueue_deleted_{$meta_type}_meta", $whitelist_handler );
21
		}
22
	}
23
24
	function filter_meta( $args ) {
25
		if ( $args[2][0] === '_' && ! in_array( $args[2], Jetpack_Sync_Defaults::$default_whitelist_meta_keys ) ) {
0 ignored issues
show
Bug introduced by
The property default_whitelist_meta_keys 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...
26
			return false;
27
		} 
28
29
		return $args;
30
	}
31
}