Usage
nebula()->is_dev($strict)
Parameters
$strict
(Optional) (Boolean) User must be logged in
Default: false
Parameter Notes
Passing $strict as true bypasses the IP address condition and requires the user to be logged in and a developer.
Examples
<?php if ( is_dev() ){
//Something for developers only.
} ?>
Additional Notes
Developers and clients IP addresses and email domains can be added in Nebula Options under the Administration tab.
Source File
Located in /libs/Utilities/Utilities.php on line 245.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_is_dev"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one? public function is_dev($strict=false){
$override = apply_filters('pre_is_dev', null, $strict);
if ( isset($override) ){return $override;}
if ( empty($strict) ){
$dev_ips = ( !empty($this->get_option('dev_ip')) )? $this->get_option('dev_ip') : '';
if ( !empty($dev_ips) ){
$dev_ips = explode(',', $dev_ips);
if ( !empty($dev_ips) ){
foreach ( $dev_ips as $dev_ip ){
$dev_ip = wp_privacy_anonymize_ip(trim($dev_ip));
if ( !empty($dev_ip) && $dev_ip[0] !== '/' && $dev_ip === $this->get_ip_address() ){
return true;
}
if ( !empty($dev_ip) && $dev_ip[0] === '/' && preg_match($dev_ip, $this->get_ip_address()) ){
return true;
}
}
}
}
}
//Check if the current user's email domain matches any of the dev email domains from Nebula Options
if ( is_user_logged_in() ){
$current_user = wp_get_current_user();
if ( !empty($current_user->user_email) ){
$current_user_domain = explode('@', $current_user->user_email)[1];
$dev_email_domains = ( $this->get_option('dev_email_domain') )? $this->get_option('dev_email_domain') : ''; //Ensure correct type
if ( !empty($dev_email_domains) ){
$dev_email_domains = explode(',', $dev_email_domains);
foreach ( $dev_email_domains as $dev_email_domain ){
if ( trim($dev_email_domain) === $current_user_domain ){
return true;
}
}
}
}
}
return false;
}
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
add_filter('pre_is_dev', 'my_custom_is_dev', 10, 2); //The last integer must be 1 more than the actual parameters
function my_custom_is_dev($null, $strict){ //$null is required, but can be ignored
//Write your own code here
return true; //Return true to prevent the original function from running afterwords
}
You can completely disable this PHP function with a single line actions:
add_filter('pre_is_dev', '__return_false');