public function block_script_load($source)
{
// Bail if disabled.
if (!$this->enabled()) {
return $source;
}
// Parse the URL being passed to pull out the host.
$parsed = parse_url($source, PHP_URL_HOST);
// First run the filter to allow a source host to get through.
if (false === apply_filters('airplane_mode_parse_script', true, $parsed)) {
return $source;
}
// If we don't share the same URL as the site itself, return null. Otherwise return the URL.
return isset($parsed) && false === strpos(home_url(), $parsed) ? new Airplane_Mode_WP_Error('airplane_mode_enabled', __('Airplane Mode blocked script', 'airplane-mode'), array('return' => '', 'src' => $source)) : $source;
}