Completed
Push — add/google-maps/api-key ( 5599f7...90239a )
by
unknown
26:57 queued 16:47
created

Jetpack_Sync_Module_Meta   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 7
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 10 4
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] &&
26
		     ! 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...
27
		     ! wp_startswith( $args[2], '_wpas_skip_' )
28
		) {
29
			return false;
30
		}
31
32
		return $args;
33
	}
34
}
35