Skip to content

Instantly share code, notes, and snippets.

@jwwicks
Last active January 9, 2019 01:36
Show Gist options
  • Save jwwicks/9dc60f07cdcaf3bfb104312e00e266de to your computer and use it in GitHub Desktop.
Save jwwicks/9dc60f07cdcaf3bfb104312e00e266de to your computer and use it in GitHub Desktop.
<?php
/**
* @package Wordpress JetPack Theme Hooks
* @author jwwicks
* @copyright Copyright (C) 2017 jwwicks
* @license GNU/GPLv2 and later
*
* http://www.gnu.org/licenses/gpl-2.0.html
*
* Note: Place the code below in your functions.php theme file
*/
/**
* Enable JetPack Development mode selectively based on subdomain
*
* www.domain.com - production mode
* develop.domain.com - development mode
* staging.domain.com - development mode
*
*/
if(!function_exists('onEnableJetPackDevelopmentMode')){
function onEnableJetPackDevelopmentMode($is_development_mode){
$parts = explode('.', $_SERVER['SERVER_NAME']);
/* Assumes www.domain.com format
adjust array as needed below to suit your setup
*/
if(in_array($parts[0], array('develop', 'staging'))){
$is_development_mode = true;
}
return $is_development_mode;
}
}
add_filter('jetpack_development_mode', 'onEnableJetPackDevelopmentMode', 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment