Manages the assets

Adds the possibility to load a javascript or a css in the middle in a template part without having the need to check if the asset can be loaded in the head or in the foot of the page.

Uses ob_start and a placeholder for the assets. It's a singleton beacause it has to be run only once

author etessore
version 1.0.0
package classes

 Methods

Adds a css to the current set

add_css(string $handle, string | bool $src, array $deps, string | bool $ver, string $media) : \DefaultAssets
see http://codex.wordpress.org/Function_Reference/wp_register_style

Parameters

$handle

string

Name of the stylesheet.

$src

stringbool

Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.

$deps

array

Array of handles of any stylesheet that this stylesheet depends on. (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.

$ver

stringbool

String specifying the stylesheet version number. Set to NULL to disable. Used to ensure that the correct version is sent to the client regardless of caching.

$media

string

The media for which this stylesheet has been defined.

Returns

\DefaultAssets$this for chainability

Adds a javascript to the current set

add_js(string $handle, string $src, array $deps, string | bool $ver, bool $in_footer) : \DefaultAssets
see http://codex.wordpress.org/Function_Reference/wp_register_script

Parameters

$handle

string

Script name

$src

string

Script url

$deps

array

(optional) Array of script names on which this script depends

$ver

stringbool

(optional) Script version (used for cache busting), set to NULL to disable

$in_footer

bool

(optional) Whether to enqueue the script before or before

Returns

\DefaultAssets$this for chainability

This is called on wordpress init Tries to load asset from the child theme, if the asset file doesn't exists it loads from the parent theme

callback() 

Disables the loading of assets from template part

disable_automatic_manager() : \DefaultAssets

Returns

\DefaultAssets$this for chainability

Enables the loading of assets from template part

enable_automatic_manager() : \DefaultAssets

Returns

\DefaultAssets$this for chainability

Retrieves the singleton instance for this feature

get_instance() : \AutomaticAssetsManager
Static

Returns

\AutomaticAssetsManagerunique instance

Hooks the assets registration into wordpress init hook

hook() : \DefaultAssets

Returns

\DefaultAssets$this for chainability

Called by wordpress right before the page start

obstart_init() 

Replaces the temporarily markers inserted on first page execution with the real list of html markup for the needed assets

obstart_replace_assets_marker() 

Prints a marker for the top javascript

on_wp_print_scripts() 

Prints a marker for the top css

on_wp_print_styles() 

Register some assets and hooks into WP

__construct() 

 Properties

 

$assets : \arrary
 

$base_dir : array
 

$instance 
 

$status : boolean

 Constants

 

Placeholder for the bottom javascript

BOTTOM_JS_MARKER : string
 

Placeholder for the css

CSS_MARKER : string
 

Placeholder for the top javascripts

TOP_JS_MARKER : \stirng