| Conditions | 10 |
| Paths | 3 |
| Total Lines | 46 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 11 | static function init() { |
||
| 12 | /** |
||
| 13 | * Fires on every request before default loading sync code. |
||
| 14 | * Return false to not load sync code and hook sync actions. |
||
| 15 | * |
||
| 16 | * @since 4.2.0 |
||
| 17 | * |
||
| 18 | * @param bool should we load sync code for this request |
||
| 19 | */ |
||
| 20 | if ( ! apply_filters( 'jetpack_sync_should_load', |
||
| 21 | ( |
||
| 22 | $_SERVER['REQUEST_METHOD'] === 'POST' |
||
| 23 | || |
||
| 24 | current_user_can( 'manage_options' ) |
||
| 25 | || |
||
| 26 | is_admin() |
||
| 27 | || |
||
| 28 | defined( 'PHPUNIT_JETPACK_TESTSUITE' ) |
||
| 29 | ) |
||
| 30 | && |
||
| 31 | ( Jetpack::is_active() || defined( 'PHPUNIT_JETPACK_TESTSUITE' ) ) |
||
| 32 | && |
||
| 33 | !( Jetpack::is_development_mode() || Jetpack::is_staging_site() ) |
||
| 34 | |||
| 35 | ) ) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-client.php'; |
||
| 40 | |||
| 41 | self::$client = Jetpack_Sync_Client::getInstance(); |
||
| 42 | |||
| 43 | // bind the do_sync process to shutdown |
||
| 44 | add_action( 'shutdown', array( self::$client, 'do_sync' ) ); |
||
| 45 | |||
| 46 | // bind the sending process |
||
| 47 | add_filter( 'jetpack_sync_client_send_data', array( __CLASS__, 'send_data' ), 10, 2 ); |
||
| 48 | |||
| 49 | // On jetpack registration |
||
| 50 | add_action( 'jetpack_site_registered', array( __CLASS__, 'schedule_full_sync' ) ); |
||
| 51 | |||
| 52 | // Schedule a job to send DB checksums once an hour |
||
| 53 | if ( ! wp_next_scheduled ( 'jetpack_send_db_checksum' ) ) { |
||
| 54 | wp_schedule_event( time(), 'hourly', 'jetpack_send_db_checksum' ); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 88 |
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.