PHP Class Themosis\Asset\Asset

Afficher le fichier Open project: themosis/framework Class Usage Examples

Protected Properties

Свойство Type Description
$action Themosis\Hook\ActionBuilder
$allowedAreas array Allowed areas.
$area string The default area where to load assets.
$args array WordPress properties of an asset.
$filter Themosis\Hook\FilterBuilder
$html Themosis\Html\HtmlBuilder
$instances array A list of all Asset instances.
$instantiated array A list of enqueued assets.
$key string Asset key name.
$type string Type of the asset.

Méthodes publiques

Méthode Description
__construct ( string $type, array $args, Themosis\Hook\IHook $action, HtmlBuilder $html, Themosis\Hook\IHook $filter ) Build an Asset instance.
addAttributes ( array $atts ) : Asset Add attributes to the asset opening tag.
getArea ( ) : string Return the asset area.
getArgs ( string $name = '' ) : array | string Return the asset properties. If $name isset, return its value.
getKey ( ) : string Return the asset key.
getType ( ) : string Return the asset type.
inline ( string $data, string $position = 'after' ) : Asset Add inline code before or after the loaded asset.
install ( ) Install the appropriate asset depending of its area.
isQueued ( ) : boolean Tells if an asset is queued or not.
localize ( string $objectName, mixed $data ) : Asset Localize data for the linked asset.
remove ( ) : Asset Remove a declared asset.
to ( string $area ) : Asset Allow the developer to define where to load the asset.

Méthodes protégées

Méthode Description
orderInstances ( ) Manipulate the static::$instances variable in order to separate each asset in its area.
parse ( array $args ) : mixed Parse defined asset properties.
parseMixed ( $mixed ) : string | boolean Parse the mixed argument.
parseVersion ( string | boolean | null $version ) : mixed Parse the version number.
register ( Asset $asset ) Register the asset.
registerInline ( Asset $asset ) Register inline code.
registerInstance ( ) Register asset instances.
registerScript ( Asset $asset ) Register a 'script' asset.
registerStyle ( Asset $asset ) Register a 'style' asset.

Method Details

__construct() public méthode

Build an Asset instance.
public __construct ( string $type, array $args, Themosis\Hook\IHook $action, HtmlBuilder $html, Themosis\Hook\IHook $filter )
$type string
$args array
$action Themosis\Hook\IHook
$html Themosis\Html\HtmlBuilder
$filter Themosis\Hook\IHook

addAttributes() public méthode

Add attributes to the asset opening tag.
public addAttributes ( array $atts ) : Asset
$atts array The asset attributes to add.
Résultat Asset

getArea() public méthode

Return the asset area.
public getArea ( ) : string
Résultat string

getArgs() public méthode

If nothing is defined, return all properties.
public getArgs ( string $name = '' ) : array | string
$name string The argument name.
Résultat array | string

getKey() public méthode

Return the asset key.
public getKey ( ) : string
Résultat string

getType() public méthode

Return the asset type.
public getType ( ) : string
Résultat string

inline() public méthode

Default to "after".
public inline ( string $data, string $position = 'after' ) : Asset
$data string The inline code to output.
$position string Accepts "after" or "before" as values. Note that position is only working for JS assets.
Résultat Asset

install() public méthode

Install the appropriate asset depending of its area.
public install ( )

isQueued() public méthode

Tells if an asset is queued or not.
public isQueued ( ) : boolean
Résultat boolean

localize() public méthode

Output JS object right before the script output.
public localize ( string $objectName, mixed $data ) : Asset
$objectName string The name of the JS variable that will hold the data.
$data mixed Any data to attach to the JS variable: string, boolean, object, array, ...
Résultat Asset

orderInstances() protected méthode

Manipulate the static::$instances variable in order to separate each asset in its area.
protected orderInstances ( )

parse() protected méthode

Parse defined asset properties.
protected parse ( array $args ) : mixed
$args array The asset properties.
Résultat mixed

parseMixed() protected méthode

Parse the mixed argument.
protected parseMixed ( $mixed ) : string | boolean
$mixed
Résultat string | boolean

parseVersion() protected méthode

Parse the version number.
protected parseVersion ( string | boolean | null $version ) : mixed
$version string | boolean | null
Résultat mixed

register() protected méthode

Register the asset.
protected register ( Asset $asset )
$asset Asset

registerInline() protected méthode

Register inline code.
protected registerInline ( Asset $asset )
$asset Asset

registerInstance() protected méthode

Register asset instances.
protected registerInstance ( )

registerScript() protected méthode

Register a 'script' asset.
protected registerScript ( Asset $asset )
$asset Asset

registerStyle() protected méthode

Register a 'style' asset.
protected registerStyle ( Asset $asset )
$asset Asset

remove() public méthode

Remove a declared asset.
public remove ( ) : Asset
Résultat Asset

to() public méthode

Only 'admin', 'login' and 'customizer' are accepted. If none of those values are used, simply keep the default front-end area.
public to ( string $area ) : Asset
$area string Specify where to load the asset: 'admin', 'login' or 'customizer'.
Résultat Asset

Property Details

$action protected_oe property

protected ActionBuilder,Themosis\Hook $action
Résultat Themosis\Hook\ActionBuilder

$allowedAreas protected_oe property

Allowed areas.
protected array $allowedAreas
Résultat array

$area protected_oe property

The default area where to load assets.
protected string $area
Résultat string

$args protected_oe property

WordPress properties of an asset.
protected array $args
Résultat array

$filter protected_oe property

protected FilterBuilder,Themosis\Hook $filter
Résultat Themosis\Hook\FilterBuilder

$html protected_oe property

protected HtmlBuilder,Themosis\Html $html
Résultat Themosis\Html\HtmlBuilder

$instances protected_oe static_oe property

A list of all Asset instances.
protected static array $instances
Résultat array

$instantiated protected_oe static_oe property

A list of enqueued assets.
protected static array $instantiated
Résultat array

$key protected_oe property

Asset key name.
protected string $key
Résultat string

$type protected_oe property

Type of the asset.
protected string $type
Résultat string