Created
October 3, 2018 13:08
-
-
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
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 | |
/** | |
* 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