Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-client.php'; |
||
| 4 | |||
| 5 | class Jetpack_Sync_Actions { |
||
| 6 | static $client = null; |
||
|
0 ignored issues
–
show
|
|||
| 7 | |||
| 8 | static function init() { |
||
| 9 | |||
| 10 | self::$client = Jetpack_Sync_Client::getInstance(); |
||
| 11 | |||
| 12 | // bind the do_sync process to shutdown |
||
| 13 | add_action( 'shutdown', array( self::$client, 'do_sync' ) ); |
||
| 14 | |||
| 15 | // bind the sending process |
||
| 16 | add_filter( 'jetpack_sync_client_send_data', array( __CLASS__, 'send_data' ) ); |
||
| 17 | |||
| 18 | // On jetpack registration |
||
| 19 | add_action( 'jetpack_site_registered', array( __CLASS__, 'schedule_full_sync' ) ); |
||
| 20 | } |
||
| 21 | |||
| 22 | static function send_data( $data ) { |
||
| 23 | Jetpack::load_xml_rpc_client(); |
||
| 24 | $rpc = new Jetpack_IXR_Client( array( |
||
| 25 | 'user_id' => get_current_user_id(), |
||
| 26 | 'timeout' => 30 |
||
| 27 | ) ); |
||
| 28 | $result = $rpc->query( 'jetpack.syncActions', $data ); |
||
| 29 | if ( ! $result ) { |
||
| 30 | return $rpc->get_jetpack_error(); |
||
| 31 | } |
||
| 32 | |||
| 33 | return $rpc->getResponse(); |
||
| 34 | } |
||
| 35 | |||
| 36 | static function schedule_full_sync() { |
||
| 37 | wp_schedule_single_event( strftime( '+1 second' ), 'jetpack_sync_full' ); |
||
| 38 | } |
||
| 39 | |||
| 40 | } |
||
| 41 | |||
| 42 | Jetpack_Sync_Actions::init(); |
||
| 43 |
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.