| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Name: Monitor |
| 4 |
* Module Description: Jetpack Monitor will keep tabs on your site, and alert you the moment that downtime is detected. |
| 5 |
* Sort Order: 55 |
| 6 |
* First Introduced: 2.6 |
| 7 |
* Requires Connection: Yes |
| 8 |
* Auto Activate: No |
| 9 |
*/ |
| 10 |
|
| 11 |
function jetpack_monitor_toggle() { |
| 12 |
$jetpack = Jetpack::init(); |
| 13 |
|
| 14 |
if ( ! $jetpack->current_user_is_connection_owner() ) { |
| 15 |
Jetpack::state( 'module', 'monitor' ); |
| 16 |
Jetpack::state( 'error', 'master_user_required' ); |
| 17 |
|
| 18 |
// Technically this call to `wp_safe_redirect` is not required because |
| 19 |
// `Jetpack::activate_module` already sets up a redirect. However, this |
| 20 |
// might not stay the case forever so it's clearer to do it here as well. |
| 21 |
wp_safe_redirect( Jetpack::admin_url( 'page=jetpack' ) ); |
| 22 |
die; |
| 23 |
} |
| 24 |
|
| 25 |
$jetpack->sync->register( 'noop' ); |
| 26 |
|
| 27 |
if ( false !== strpos( current_filter(), 'jetpack_activate_module_' ) ) { |
| 28 |
Jetpack::check_privacy( __FILE__ ); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
add_action( 'jetpack_activate_module_monitor', 'jetpack_monitor_toggle' ); |
| 33 |
add_action( 'jetpack_deactivate_module_monitor', 'jetpack_monitor_toggle' ); |
| 34 |
|
| 35 |
|