Overview
  • Namespace
  • Class

Namespaces

  • MatthiasWeb
    • RealMediaLibrary
      • api
      • attachment
      • base
      • comp
        • complexquery
      • folder
      • general
      • metadata
      • order
      • rest
      • usersettings
  • None

Classes

  • Assets
  • Base
  • Core

Class Assets

Base asset management class for frontend scripts and styles.

MatthiasWeb\RealMediaLibrary\base\Base
Extended by MatthiasWeb\RealMediaLibrary\base\Assets

Direct known subclasses

MatthiasWeb\RealMediaLibrary\general\Assets

Abstract
Namespace: MatthiasWeb\RealMediaLibrary\base
Located at base/Assets.class.php

Methods summary

abstract public
# enqueue_scripts_and_styles( string $type )

Enqueue scripts and styles depending on the type. You can check the type through the $type parameter. In this function you can include your external libraries from public/lib, too.

Enqueue scripts and styles depending on the type. You can check the type through the $type parameter. In this function you can include your external libraries from public/lib, too.

Parameters

$type
The type (see Assets constants)
public
# enqueueScript( string $handle, string $src = '', array $deps = array(), boolean $in_footer = false, boolean $isLib = false )

Registers the script if $src provided (does NOT overwrite), and enqueues it. Use this wrapper method instead of wp_enqueue_script if you want to use the cachebuster for the given src. If the src is not found in the cachebuster (inc/others/cachebuster.php) it falls back to RML_VERSION.

Registers the script if $src provided (does NOT overwrite), and enqueues it. Use this wrapper method instead of wp_enqueue_script if you want to use the cachebuster for the given src. If the src is not found in the cachebuster (inc/others/cachebuster.php) it falls back to RML_VERSION.

Parameters

$handle
Name of the script. Should be unique.
$src
The src relative to public/dist or public/dev folder (when $isLib is false)
$deps
An array of registered script handles this script depends on.
$in_footer
Whether to enqueue the script before instead of in the .
$isLib
If true the public/lib/ folder is used.

See

https://developer.wordpress.org/reference/functions/wp_enqueue_script/ For parameters
public
# enqueueLibraryScript( $handle, $src = '', $deps = array(), $in_footer = false )

Wrapper for Assets::enqueueScript() method with $isLib = true.

Wrapper for Assets::enqueueScript() method with $isLib = true.

See

Assets::enqueueScript()
public
# enqueueStyle( string $handle, string $src = '', array $deps = array(), string $media = 'all', boolean $isLib = false )

Enqueue a CSS stylesheet. Use this wrapper method instead of wp_enqueue_style if you want to use the cachebuster for the given src. If the src is not found in the cachebuster (inc/others/cachebuster.php) it falls back to RML_VERSION.

Enqueue a CSS stylesheet. Use this wrapper method instead of wp_enqueue_style if you want to use the cachebuster for the given src. If the src is not found in the cachebuster (inc/others/cachebuster.php) it falls back to RML_VERSION.

Parameters

$handle
Name of the style. Should be unique.
$src
The src relative to public/dist or public/dev folder (when $isLib is false)
$deps
An array of registered style handles this style depends on.
$media
The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
$isLib
If true the public/lib/ folder is used.

See

https://developer.wordpress.org/reference/functions/wp_enqueue_style/ For parameters
public
# enqueueLibraryStyle( $handle, $src = '', $deps = array(), $media = 'all' )

Wrapper for Assets::enqueueStyle() method with $isLib = true.

Wrapper for Assets::enqueueStyle() method with $isLib = true.

See

Assets::enqueueStyle()
public
# getCachebusterVersion( string $src, boolean $isLib = false )

Get the cachebuster entry for a given file. If the $src begins with public/lib/ it will use the inc/others/cachebuster-lib.php cachebuster instead of inc/others/cachebuster.php.

Get the cachebuster entry for a given file. If the $src begins with public/lib/ it will use the inc/others/cachebuster-lib.php cachebuster instead of inc/others/cachebuster.php.

Parameters

$src
The src relative to public/ folder
$isLib
If true the cachebuster-lib.php cachebuster is used

See

inc/others/cachebuster.php

Returns

string RML_VERSION or cachebuster timestamp
public
# getPluginsUrl( string $asset, boolean $isLib = false )

Wrapper for plugins_url. It respects the public folder depending on the SCRIPTS_DEBUG constant.

Wrapper for plugins_url. It respects the public folder depending on the SCRIPTS_DEBUG constant.

Parameters

$asset
The file name relative to the public folder path (dist or dev)
$isLib
If true the public/lib/ folder is used.

See

MatthiasWeb\RealMediaLibrary\base\Assets::getPublicFolder()

Returns

string
public
# getPublicFolder( boolean $isLib = false )

Gets a public folder depending on the debug mode relative to the plugins folder with trailing slash.

Gets a public folder depending on the debug mode relative to the plugins folder with trailing slash.

Parameters

$isLib
If true the public/lib/ folder is returned.

Returns

string
public
# isScriptDebug( )

Check if SCRIPT_DEBUG is set to true.

Check if SCRIPT_DEBUG is set to true.

Returns

boolean

Methods inherited from MatthiasWeb\RealMediaLibrary\base\Base

debug(), getCore(), getTableName()

Constants summary

string TYPE_ADMIN

Enqueue scripts and styles in admin pages.

Enqueue scripts and styles in admin pages.

# 'admin_enqueue_scripts'
string TYPE_FRONTEND

Enqueue scripts and styles in frontend pages.

Enqueue scripts and styles in frontend pages.

# 'wp_enqueue_scripts'
string LIB_CACHEBUSTER_REGEX

The regex to get the library folder name of public/lib files.

The regex to get the library folder name of public/lib files.

# '/^public\/lib\/([^\/]+)/'
API documentation generated by ApiGen