Created
February 8, 2013 07:33
-
-
Save yoren/4737296 to your computer and use it in GitHub Desktop.
WordPress: use Jetpack’s ShareDaddy plugin without connecting to WordPress.com
This file contains 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 | |
/** | |
* @link http://wpgarage.com/plugins/how-to-use-jetpacks-sharedaddy-without-connecting-to-wordpress-com/ | |
* Modify plugin file - jetpack-sharedaddy.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; | |
// 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 ); | |
// Ensures Jetpack's top level menu doesn't show up. Remove line to display. | |
add_action( 'admin_menu', 'hack_remove_jetpac_menu', 999 ); | |
} | |
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' ) ); | |
} | |
function hack_remove_jetpac_menu() { | |
remove_menu_page( 'jetpack' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment