Assets::get_full_path( string $src, bool $url = false )

Transforms a relative asset path into a full path.

Description

The method also automatically handles loading a minified vs non-minified file.

See also

Parameters

$src

(string) (Required) Relative asset path.

$url

(bool) (Optional) Whether to return the URL instead of the path.

Default value: false

Return

(string|bool) Full asset path or URL, depending on the $url parameter, or false if the path is requested for a full $src URL.

Source

File: src/assets.php

	public function get_full_path( $src, $url = false ) {
		if ( preg_match( '/^(http|https):\/\//', $src ) || 0 === strpos( $src, '//' ) ) {
			if ( $url ) {
				return $src;
			}

			return false;
		}

		if ( '.js' !== substr( $src, -3 ) && '.css' !== substr( $src, -4 ) ) {
			if ( $url ) {
				return call_user_func( $this->url_callback, $src );
			}

			return call_user_func( $this->path_callback, $src );
		}

		return parent::get_full_path( $src, $url );
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.