PHP Class Inpsyde\MultilingualPress\Asset\AssetManager

Since: 3.0.0
Datei anzeigen Open project: inpsyde/multilingual-press Class Usage Examples

Public Methods

Method Description
add_script_data ( Inpsyde\MultilingualPress\Asset\Script | string $script, string $object_name, array $data ) : Inpsyde\MultilingualPress\Asset\Script | null Adds the given data to the given script, and handles it in case the script has been enqueued already.
enqueue_script ( Inpsyde\MultilingualPress\Asset\Script | string $script, boolean $in_footer = true ) : boolean Enqueues the script with the given handle.
enqueue_script_with_data ( Inpsyde\MultilingualPress\Asset\Script | string $script, string $object_name, array $data, boolean $in_footer = true ) : boolean Enqueues the script with the given handle.
enqueue_style ( Inpsyde\MultilingualPress\Asset\Style | string $style ) : boolean Enqueues the style with the given handle.
get_script ( string $handle ) : Inpsyde\MultilingualPress\Asset\Script Returns the script with the given handle.
get_style ( string $handle ) : Inpsyde\MultilingualPress\Asset\Style Returns the style with the given handle.
register_script ( Inpsyde\MultilingualPress\Asset\Script $script ) : static Register the given script.
register_style ( Inpsyde\MultilingualPress\Asset\Style $style ) : static Register the given style.

Private Methods

Method Description
enqueue ( callable $callback ) : void Either executes the given callback or hooks it to the appropriate enqueue action, depending on the context.
get_enqueue_action ( ) : string Returns the appropriate action for enqueueing assets.
handle_script_data ( Inpsyde\MultilingualPress\Asset\Script $script ) : void Handles potential data that has been added to the script after it was enqueued, and then clears the data.

Method Details

add_script_data() public method

Adds the given data to the given script, and handles it in case the script has been enqueued already.
Since: 3.0.0
public add_script_data ( Inpsyde\MultilingualPress\Asset\Script | string $script, string $object_name, array $data ) : Inpsyde\MultilingualPress\Asset\Script | null
$script Inpsyde\MultilingualPress\Asset\Script | string Script object or handle.
$object_name string The name of the JavaScript variable holding the data.
$data array The data to be made available for the script.
return Inpsyde\MultilingualPress\Asset\Script | null Script object if it exists, null if not.

enqueue_script() public method

Enqueues the script with the given handle.
Since: 3.0.0
public enqueue_script ( Inpsyde\MultilingualPress\Asset\Script | string $script, boolean $in_footer = true ) : boolean
$script Inpsyde\MultilingualPress\Asset\Script | string Script object or handle.
$in_footer boolean Optional. Enqueue in the footer? Defaults to true.
return boolean Whether or not the script was enqueued successfully.

enqueue_script_with_data() public method

Enqueues the script with the given handle.
Since: 3.0.0
public enqueue_script_with_data ( Inpsyde\MultilingualPress\Asset\Script | string $script, string $object_name, array $data, boolean $in_footer = true ) : boolean
$script Inpsyde\MultilingualPress\Asset\Script | string Script object or handle.
$object_name string The name of the JavaScript variable holding the data.
$data array The data to be made available for the script.
$in_footer boolean Optional. Enqueue in the footer? Defaults to true.
return boolean Whether or not the script was enqueued successfully.

enqueue_style() public method

Enqueues the style with the given handle.
Since: 3.0.0
public enqueue_style ( Inpsyde\MultilingualPress\Asset\Style | string $style ) : boolean
$style Inpsyde\MultilingualPress\Asset\Style | string Style object or handle.
return boolean Whether or not the style was enqueued successfully.

get_script() public method

Returns the script with the given handle.
Since: 3.0.0
public get_script ( string $handle ) : Inpsyde\MultilingualPress\Asset\Script
$handle string Script handle.
return Inpsyde\MultilingualPress\Asset\Script Script object.

get_style() public method

Returns the style with the given handle.
Since: 3.0.0
public get_style ( string $handle ) : Inpsyde\MultilingualPress\Asset\Style
$handle string Script handle.
return Inpsyde\MultilingualPress\Asset\Style Style object.

register_script() public method

Register the given script.
Since: 3.0.0
public register_script ( Inpsyde\MultilingualPress\Asset\Script $script ) : static
$script Inpsyde\MultilingualPress\Asset\Script Script object.
return static Asset manager instance.

register_style() public method

Register the given style.
Since: 3.0.0
public register_style ( Inpsyde\MultilingualPress\Asset\Style $style ) : static
$style Inpsyde\MultilingualPress\Asset\Style Style object.
return static Asset manager instance.