Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created August 31, 2012 05:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjangda/3549265 to your computer and use it in GitHub Desktop.
Save mjangda/3549265 to your computer and use it in GitHub Desktop.
Manually load Jetpack modules (e.g. for dev or offline environments); drop this in your mu-plugins folder
<?php
// TODO: don't run if Jetpack is active
add_action( 'plugins_loaded', function() {
if ( ! file_exists( WP_PLUGIN_DIR . '/jetpack/' ) )
return;
$modules = array(
'modules/contact-form.php',
'modules/shortcodes.php',
'modules/widgets.php',
'modules/comments.php',
'modules/carousel.php',
'modules/custom-css.php',
'modules/sharedaddy.php',
'modules/gravatar-hovercards.php',
'modules/minileven.php',
'class.jetpack-user-agent.php',
);
foreach ( $modules as $module ) {
require_once( WP_PLUGIN_DIR . '/jetpack/' . $module );
}
}, 99 );
@jkereako
Copy link

jkereako commented Mar 6, 2013

This is pure gold, I can finally develop locally with the ShareDaddy plugin.

Is this in the VIP documentation?

  • Jeff Kereakoglow

EDIT: I added a condition to check if the class "Jetpack" exists, because although the Jetpack files may exist, the plugin may not be activated, and if it's not, the function above will throw a fatal error.

if ( ! file_exists( WP_PLUGIN_DIR . '/jetpack/' ) || ! class_exists( 'Jetpack' ) ) {
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment