These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class Jetpack_Comments_Sync { |
||
4 | |||
5 | static $sync = array(); |
||
0 ignored issues
–
show
|
|||
6 | static $delete = array(); |
||
0 ignored issues
–
show
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. ![]() |
|||
7 | |||
8 | static $jetpack_sync = null; |
||
0 ignored issues
–
show
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. ![]() |
|||
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
|
|||
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 | } |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.