function dismiss_jetpack_notice()
{
if (!isset($_GET['jetpack-notice'])) {
return;
}
switch ($_GET['jetpack-notice']) {
case 'dismiss':
if (check_admin_referer('jetpack-deactivate') && !is_plugin_active_for_network(plugin_basename(JETPACK__PLUGIN_DIR . 'jetpack.php'))) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
deactivate_plugins(JETPACK__PLUGIN_DIR . 'jetpack.php', false, false);
wp_safe_redirect(admin_url() . 'plugins.php?deactivate=true&plugin_status=all&paged=1&s=');
}
break;
case 'jetpack-manage-opt-out':
if (check_admin_referer('jetpack_manage_banner_opt_out')) {
// Don't show the banner again
Jetpack_Options::update_option('dismissed_manage_banner', true);
// redirect back to the page that had the notice
if (wp_get_referer()) {
wp_safe_redirect(wp_get_referer());
} else {
// Take me to Jetpack
wp_safe_redirect(admin_url('admin.php?page=jetpack'));
}
}
break;
case 'jetpack-protect-multisite-opt-out':
if (check_admin_referer('jetpack_protect_multisite_banner_opt_out')) {
// Don't show the banner again
update_site_option('jetpack_dismissed_protect_multisite_banner', true);
// redirect back to the page that had the notice
if (wp_get_referer()) {
wp_safe_redirect(wp_get_referer());
} else {
// Take me to Jetpack
wp_safe_redirect(admin_url('admin.php?page=jetpack'));
}
}
break;
case 'jetpack-manage-opt-in':
if (check_admin_referer('jetpack_manage_banner_opt_in')) {
// This makes sure that we are redirect to jetpack home so that we can see the Success Message.
$redirection_url = Jetpack::admin_url();
remove_action('jetpack_pre_activate_module', array(Jetpack_Admin::init(), 'fix_redirect'));
// Don't redirect form the Jetpack Setting Page
$referer_parsed = parse_url(wp_get_referer());
// check that we do have a wp_get_referer and the query paramater is set orderwise go to the Jetpack Home
if (isset($referer_parsed['query']) && false !== strpos($referer_parsed['query'], 'page=jetpack_modules')) {
// Take the user to Jetpack home except when on the setting page
$redirection_url = wp_get_referer();
add_action('jetpack_pre_activate_module', array(Jetpack_Admin::init(), 'fix_redirect'));
}
// Also update the JSON API FULL MANAGEMENT Option
Jetpack::activate_module('manage', false, false);
// Special Message when option in.
Jetpack::state('optin-manage', 'true');
// Activate the Module if not activated already
// Redirect properly
wp_safe_redirect($redirection_url);
}
break;
}
}