Skip to content

Instantly share code, notes, and snippets.

@cfg
Created March 12, 2013 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfg/5144185 to your computer and use it in GitHub Desktop.
Save cfg/5144185 to your computer and use it in GitHub Desktop.
Remove WordPress JetPack notifications.
<?php
/**
* Disable JetPack notifications which throw errors in Chrome:
* Unsafe JavaScript attempt to access frame with URL https://public-api.wordpress.com/rest/?notes_iframe=jetpack#http://example.com/wp-admin/edit.php?mode=excerpt from frame with URL http://bgrwp.cfgdev.com/wordpress/wp-admin/edit.php?mode=excerpt. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of 'https'. Protocols must match.
*
* @author Corey Gilmore <corey@bgr.com>
*
*/
function x_remove_jetpack_notifications() {
if( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;
if( !has_filter( 'show_admin_bar', '__return_true' ) && !is_user_logged_in() )
return;
if( !class_exists('Jetpack_Notifications') )
return;
$notes = Jetpack_Notifications::init();
if( $priority = has_filter( 'admin_bar_menu', array( &$notes, 'admin_bar_menu') ) )
remove_action( 'admin_bar_menu', array( &$notes, 'admin_bar_menu'), $priority );
if( $priority = has_filter( 'wp_head', array( &$notes, 'styles_and_scripts') ) )
remove_action( 'wp_head', array( &$notes, 'styles_and_scripts'), $priority );
if( $priority = has_filter( 'admin_head', array( &$notes, 'styles_and_scripts') ) )
remove_action( 'admin_head', array( &$notes, 'styles_and_scripts'), $priority );
}
add_action( 'init', 'x_remove_jetpack_notifications', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment