Airplane_Mode_Core::block_style_load PHP Method

block_style_load() public method

Check the URL of a stylesheet and remove any that are not on the local URL.
public block_style_load ( string $source ) : string
$source string The source URL of the CSS sheet.
return string $source The same URL, or null.
        public function block_style_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_style', 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 style', 'airplane-mode'), array('return' => '', 'src' => $source)) : $source;
        }