Created
January 30, 2013 09:10
-
-
Save maor/4671835 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hack_jetpack_offline_mode() { | |
if ( ! file_exists( WP_PLUGIN_DIR . '/jetpack/' ) || class_exists( 'Jetpack' ) ) | |
return; | |
require_once( WP_PLUGIN_DIR . '/jetpack/jetpack.php' ); | |
// Disable Jetpack's notification messages | |
hack_disable_jetpack_notices(); | |
// List of modules we'd like to activate | |
$modules = array( | |
'sharedaddy', | |
); | |
foreach ( $modules as $module ) { | |
require Jetpack::get_module_path( $module ); | |
do_action( 'jetpack_module_loaded_' . $module ); | |
} | |
} | |
add_action( 'plugins_loaded', 'hack_jetpack_offline_mode', 99 ); | |
function hack_disable_jetpack_notices() { | |
global $jetpack_hijacked_instance; | |
// Halt the default Jetpack initialization | |
remove_action( 'init', array( 'Jetpack', 'init' ) ); | |
// Hijack Jetpack's instance (which usually gets lost in global space) | |
$jetpack_hijacked_instance = Jetpack::init(); | |
// Remove responsible functions | |
add_action( 'admin_init', 'hack_shut_off_notices_for_jetpack', 20 ); | |
} | |
function hack_shut_off_notices_for_jetpack() { | |
global $jetpack_hijacked_instance; | |
remove_action( 'load-index.php', array( $jetpack_hijacked_instance, 'prepare_connect_notice' ) ); | |
remove_action( 'load-plugins.php', array( $jetpack_hijacked_instance, 'prepare_connect_notice' ) ); | |
// Ensures Jetpack's top level menu doesn't show up. Remove line to display. | |
remove_menu_page( 'jetpack' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment