How to use WordPress JetPack Plugin Offline
WordPress JetPack plugin needs no introduction. Visit the official WordPress plugins page and you can find it right at the top, a featured plugin that is also a part of the most popular plugins. It is powerful, packed with brilliant features, easy to use and free! The only problem is that it doesn’t work offline.
If you are developing on a local server, JetPack is only enabled when it detects that the URL lacks a period. That means if you use anything other than localhost, say 192.168.1.2 then it won’t work. Today we show you what you need to enable JetPack offline.
Enable JetPack Plugin offline
To enable WordPress JetPack’s features on a local server we have to put it in Development Mode. We do this by defining a constant JETPACK_DEV_DEBUG in our wp-config file. This tells JetPack to enable all features which does not require a connection to WordPress.com servers. Add the following line of code to your wp-config.php file.
define( 'JETPACK_DEV_DEBUG', true);
Development mode is automatically enabled when localhost is detected as the server address. JetPack’s Development mode can also be enabled using a plugin. The plugin needs to use
add_filter( 'jetpack_development_mode', '__return_true' );
If you visit the JetPack settings page now (Dashboard > JetPack) you will notice that development mode has been enabled.
JetPack is now working offline. Take a look at the features and you will notice that only a handful of features can be enabled. That’s because the other features require a connection to WordPress.com. On top of that, some of the enabled features will offer limited functionality.
Enable all JetPack Plugin features
To enable all features, all we have to do is make our local server accessible online. I know it sounds like trouble but it is not. Actually, it’s very easy.
The first thing you will need is to have node.js installed on your computer. Download node.js and install it. Once node.js is installed, we need to install a node.js package called localtunnel which creates a proxy that makes our local server accessible from any location. Open your command line or terminal and type the following code
npm install -g localtunnel
This will install localtunnel. When localtunnel is installed, start your local web server and type the following code in your command line
lt --port 80
Please note that I am assuming that your local server is running on standard port 80. If not then you need to change it to your local server port number. This command basically creates a proxy connection to your local server and gives you the address where your server is available. You will get an address which will look something like this
your url is: https://uqkrcnvgbe.localtunnel.me
This is the address where your site is available online. By default, localtunnel creates a random subdomain. If you want you can choose your own subdomain. Use the following code and replace layerpoint with your subdomain. Subdomains must be lowercase and between 4 and 20 alphanumeric characters.
lt --port 80 --subdomain layerpoint
Now you will need to change your WordPress home and site URL. The easiest way to do that is using phpMyAdmin. Open phpMyAdmin and locate wp_options table in WordPress database. Change siteurl and home to the address that localtunnel gave you.
Finally, visit the new URL, login to your Dashboard, go to JetPack settings page and login to JetPack with your WordPress.com account. You should now be able to use all JetPack features.
Don’t forget to change the address when you are done testing. On a live site, you don’t need this trick. You can connect without any hacks.
We hope you found this useful. Let us know in the comments section below.