Conditions | 12 |
Paths | 6 |
Total Lines | 66 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
12 | static function init() { |
||
13 | /** |
||
14 | * Fires on every request before default loading sync listener code. |
||
15 | * Return false to not load sync listener code that monitors common |
||
16 | * WP actions to be serialized |
||
17 | * |
||
18 | * @since 4.2.0 |
||
19 | * |
||
20 | * @param bool should we load sync listener code for this request |
||
21 | */ |
||
22 | if ( apply_filters( 'jetpack_sync_listener_should_load', |
||
23 | ( |
||
24 | $_SERVER['REQUEST_METHOD'] !== 'GET' |
||
25 | || |
||
26 | defined( 'PHPUNIT_JETPACK_TESTSUITE' ) |
||
27 | ) |
||
28 | ) ) { |
||
29 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |
||
30 | self::$listener = Jetpack_Sync_Listener::getInstance(); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Fires on every request before default loading sync sender code. |
||
35 | * Return false to not load sync sender code that serializes pending |
||
36 | * data and sends it to WPCOM for processing. |
||
37 | * |
||
38 | * @since 4.2.0 |
||
39 | * |
||
40 | * @param bool should we load sync sender code for this request |
||
41 | */ |
||
42 | if ( ! apply_filters( 'jetpack_sync_sender_should_load', |
||
43 | ( |
||
44 | $_SERVER['REQUEST_METHOD'] === 'POST' |
||
45 | || |
||
46 | current_user_can( 'manage_options' ) |
||
47 | || |
||
48 | is_admin() |
||
49 | || |
||
50 | defined( 'PHPUNIT_JETPACK_TESTSUITE' ) |
||
51 | ) |
||
52 | && |
||
53 | ( Jetpack::is_active() || defined( 'PHPUNIT_JETPACK_TESTSUITE' ) ) |
||
54 | && |
||
55 | !( Jetpack::is_development_mode() || Jetpack::is_staging_site() ) |
||
56 | |||
57 | ) ) { |
||
58 | return; |
||
59 | } |
||
60 | |||
61 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-sender.php'; |
||
62 | self::$sender = Jetpack_Sync_Sender::getInstance(); |
||
63 | |||
64 | // bind the do_sync process to shutdown |
||
65 | add_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
||
66 | |||
67 | // bind the sending process |
||
68 | add_filter( 'jetpack_sync_send_data', array( __CLASS__, 'send_data' ), 10, 2 ); |
||
69 | |||
70 | // On jetpack registration |
||
71 | add_action( 'jetpack_site_registered', array( __CLASS__, 'schedule_full_sync' ) ); |
||
72 | |||
73 | // Schedule a job to send DB checksums once an hour |
||
74 | if ( ! wp_next_scheduled ( 'jetpack_send_db_checksum' ) ) { |
||
75 | wp_schedule_event( time(), 'hourly', 'jetpack_send_db_checksum' ); |
||
76 | } |
||
77 | } |
||
78 | |||
109 |
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.