\DevOwl\DeliverAnonymousAssetAnonymousAssetBuilder

Use this to create your database tables and to create the instances of `DeliverAnonymousAsset`.

Summary

Methods
Properties
Constants
__construct()
build()
ready()
getHash()
updateHash()
readFileAndCorrectSourceMap()
dbDelta()
forceRecreation()
getTableName()
getOptionNamePrefix()
isOldBehaviorEnabled()
No public properties found
TABLE_NAME
OPTION_NAME_SERVE_HASH_SUFFIX
OPTION_NAME_SERVE_NEXT_HASH_SUFFIX
GENERATE_NEXT_HASH
MAX_SEO_REDIRECTS
No protected methods found
No protected properties found
N/A
No private methods found
$table_name
$optionNamePrefix
$oldBehaviorEnabled
$pool
N/A

Constants

TABLE_NAME

TABLE_NAME ='asset_seo_redirect'

OPTION_NAME_SERVE_HASH_SUFFIX

OPTION_NAME_SERVE_HASH_SUFFIX ='-serve-hash'

OPTION_NAME_SERVE_NEXT_HASH_SUFFIX

OPTION_NAME_SERVE_NEXT_HASH_SUFFIX ='-serve-next-hash'

GENERATE_NEXT_HASH

GENERATE_NEXT_HASH =60 * 60 * 24 * 7

MAX_SEO_REDIRECTS

MAX_SEO_REDIRECTS =4

Properties

$table_name

$table_name :

Type

$optionNamePrefix

$optionNamePrefix :

Type

$oldBehaviorEnabled

$oldBehaviorEnabled :boolean

If `true`, it also checks the home url + first relative path for a MD5 hash for backwards-compatibility (to not break caches).

Type

boolean

Methods

__construct()

__construct(string  $table_name,string  $optionNamePrefix,boolean  $oldBehaviorEnabled = false)

C'tor.

Parameters

string $table_name

You can use it in conjunction with TABLE_NAME constant

string $optionNamePrefix
boolean $oldBehaviorEnabled

Deprecated

build()

build(string  $handle,string  $file,string  $id = null)

Create an anonymous asset. Do not forget to make it `->ready()` after you enqueued it! This must be done in `wp` hook as it is the first available hook.

Parameters

string $handle
string $file
string $id

If you pass an ID, the instance will be hold in this class pool and you can use this::ready()

ready()

ready(string  $id,boolean  $condition = true)

Make a handle ready. Do not forget to `->build()` it previously!

Parameters

string $id
boolean $condition

getHash()

getHash(string  $handle,boolean  $allowRecreate = true)

Get the currently used hash for the file or update it.

Parameters

string $handle
boolean $allowRecreate

updateHash()

updateHash()

Generate a new hash for the current served JS file.

readFileAndCorrectSourceMap()

readFileAndCorrectSourceMap(string  $path)

Read a JavaScript file and update the sourceMappingUrl parameter in the file content to the correct one - it allows you to serve any file via any URL with the correct source map URL.

Parameters

string $path

dbDelta()

dbDelta()

Make sure the database table is created.

forceRecreation()

forceRecreation()

Force recreation of asset files.

getTableName()

getTableName()

Getter.

getOptionNamePrefix()

getOptionNamePrefix()

Getter.

isOldBehaviorEnabled()

isOldBehaviorEnabled()

Getter.