Skip to content

Instantly share code, notes, and snippets.

@rxnlabs
Created October 3, 2018 13:08
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 rxnlabs/e40e6eab5e066035b60b299d094fc6ed to your computer and use it in GitHub Desktop.
Save rxnlabs/e40e6eab5e066035b60b299d094fc6ed to your computer and use it in GitHub Desktop.
WordPress - Enable Jetpack development mode if WP_DEBUG is true and Jetpack is NOT connected to WordPress.com. Useful if you want to test out Jetpack modules without needing to be connected to WordPress.com or if doing development from a localhost site
<?php
/**
* Enable Jetpack development mode if WP_DEBUG is true and jetpack is not active/connected to WordPress.com
* See: https://jetpack.com/support/development-mode/
*/
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
if ( method_exists( '\\Jetpack', 'is_active' ) && is_callable( array( '\\Jetpack', 'is_active' ) ) ) {
$jetpack_reflection = new \ReflectionMethod( '\\Jetpack', 'is_active' );
if ( $jetpack_reflection->isStatic() && ! \Jetpack::is_active() ) {
if ( ! defined( 'JETPACK_DEV_DEBUG' ) ) {
define( 'JETPACK_DEV_DEBUG', true );
}
add_filter( 'jetpack_development_mode', '__return_true' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment