Completed
Push — add/sync-rest-comments ( 1da85c )
by
unknown
09:46
created

Jetpack_Comments_Sync::get_comment_ids_to_sync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
class Jetpack_Comments_Sync {
4
5
	static $sync = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $sync.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
6
	static $delete = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $delete.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
7
8
	static $jetpack_sync = null;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $jetpack_sync.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
9
10
	static function init() {
11
12
		$jetpack = Jetpack::init();
13
		self::$jetpack_sync = $jetpack->sync;
14
15
		add_action( 'wp_insert_comment',         array( __CLASS__, 'wp_insert_comment' ),         10, 2 );
16
		add_action( 'transition_comment_status', array( __CLASS__, 'transition_comment_status' ), 10, 3 );
17
		add_action( 'edit_comment',              array( __CLASS__, 'edit_comment' ) );
18
		add_action( 'delete_comment',              array( __CLASS__, 'delete_comment' ) );
19
	}
20
	static function sync( $comment_id ) {
21
		self::$sync[] = $comment_id;
22
	}
23
	static function get_comment_ids_to_sync() {
24
		return array_unique( self::$sync );
25
	}
26
27
	static function get_comment_ids_to_delete() {
28
		return array_unique( self::$delete );
29
	}
30
31
	static function wp_insert_comment( $comment_id, $comment ) {
0 ignored issues
show
Unused Code introduced by
The parameter $comment is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
		self::sync( $comment_id );
33
	}
34
35
	static function transition_comment_status( $new_status, $old_status, $comment ) {
36
		self::sync( $comment->comment_ID );
37
	}
38
39
	static function edit_comment( $comment_id ) {
40
		self::sync( $comment_id );
41
	}
42
43
	static function delete_comment( $comment_id ) {
44
		self::$delete[] = $comment_id;
45
	}
46
47
}