name, string $value, ...$args ) { $output = apply_filters( 'rocket_' . $name, $value, ...$args ); if ( ! is_string( $output ) ) { return $value; } return $output; } /** * Check if the URLs is ignored. * * @param string $url URL to check. * @param array $ignored_urls List of ignored URLs. * * @return bool */ protected function is_url_ignored( string $url, array $ignored_urls ): bool { foreach ( $ignored_urls as $ignored_url ) { if ( strpos( $url, $ignored_url ) !== false ) { return true; } } return false; } /** * Complete the URL if necessary. * * @param string $url URL to complete. * * @return string */ protected function make_url_complete( string $url ): string { $host = wp_parse_url( $url, PHP_URL_HOST ); if ( $host || $this->is_relative( $url ) ) { return $url; } return rocket_get_home_url() . '/' . trim( $url, '/ ' ); } /** * Check if the URL is external. * * @param string $url URL to check. * * @return bool */ protected function is_url_external( string $url ): bool { $host = wp_parse_url( $url, PHP_URL_HOST ); if ( ! $host ) { return false; } $home_host = wp_parse_url( rocket_get_home_url(), PHP_URL_HOST ); return $host !== $home_host; } /** * Check if the URL is relative. * * @param string $url URL to check. * @return bool */ protected function is_relative( string $url ): bool { return preg_match( '/^\./', $url ); } }