A simple plugin to run JetPack locally

We don’t need to modify the wp-config.php file as before with:

define ('JETPACK_DEV_DEBUG', true);

to run JetPack in the development mode.

By using the jetpack_development_mode filter described here, we can construct this simple plugin:

<?php
/**
 * Plugin Name: Run JetPack locally
 * Plugin URI:  https://github.com/birgire/run-jetpack-locally
 * Author:      birgire
 * Version:     0.0.3
 */

// Activate the development mode:
add_filter( 
    'jetpack_development_mode', 
    '__return_true', 
    PHP_INT_MAX 
);

to make your life easier 😉 and it’s available on GitHub.

This class method of the JetPack class contains the filter:

 
	/**
	 * Is Jetpack in development (offline) mode?
	 */
	public static function is_development_mode() {
		$development_mode = false;

		if ( defined( 'JETPACK_DEV_DEBUG' ) ) {
			$development_mode = JETPACK_DEV_DEBUG;
		}

		elseif ( site_url() && false === strpos( site_url(), '.' ) ) {
			$development_mode = true;
		}

		return apply_filters( 'jetpack_development_mode', $development_mode );
	}

Leave a Reply

Your email address will not be published. Required fields are marked *