AssetsOptimization
in package

Table of Contents

$alreadyoptimized  : bool
Flag to indicate if CSS is already minified
$instance  : AssetsOptimization
__construct()  : mixed
AssetsOptimization constructor.
buffer_end()  : string
Processes/optimizes the output-buffered content and returns it.
buffer_start()  : void
Setup output buffering if needed.
filter_css()  : mixed
filter_test()  : mixed
getInstance()  : AssetsOptimization
is_valid_buffer()  : bool
Returns true if given markup is considered valid/processable/optimizable.
load_assets_on_demand()  : mixed
mbstring_available()  : bool
Returns true when mbstring is available.
move_css_to_head()  : mixed
should_buffer()  : bool
Returns true if all the conditions to start output buffering are satisfied.
strlen()  : int
Attempts to return the number of characters in the given $string if mbstring is available. Returns the number of bytes (instead of characters) as fallback.
strpos()  : int|false
Multibyte-capable strpos() if support is available on the server.
substr_replace()  : string
Our wrapper around implementations of \substr_replace() that attempts to not break things horribly if at all possible.
inject_in_html()  : void
Injects/replaces the given payload markup into `$html` at the specified location.

Properties

$alreadyoptimized

Flag to indicate if CSS is already minified

private bool $alreadyoptimized = false

$instance

private static AssetsOptimization $instance = null

Methods

__construct()

AssetsOptimization constructor.

public __construct() : mixed
Return values
mixed

buffer_end()

Processes/optimizes the output-buffered content and returns it.

public buffer_end(string $html) : string

If the content is not processable, it is returned unmodified.

Parameters
$html : string

Buffered content.

Return values
string

buffer_start()

Setup output buffering if needed.

public buffer_start() : void
Return values
void

filter_css()

public filter_css(mixed $html) : mixed
Parameters
$html : mixed
Return values
mixed

filter_test()

public filter_test(mixed $html) : mixed
Parameters
$html : mixed
Return values
mixed

is_valid_buffer()

Returns true if given markup is considered valid/processable/optimizable.

public is_valid_buffer(string $content) : bool
Parameters
$content : string

Markup.

Return values
bool

load_assets_on_demand()

public load_assets_on_demand() : mixed
Return values
mixed

mbstring_available()

Returns true when mbstring is available.

public mbstring_available() : bool
Return values
bool

move_css_to_head()

public move_css_to_head() : mixed
Return values
mixed

should_buffer()

Returns true if all the conditions to start output buffering are satisfied.

public should_buffer() : bool
Return values
bool

strlen()

Attempts to return the number of characters in the given $string if mbstring is available. Returns the number of bytes (instead of characters) as fallback.

public strlen(string $string[, string|null $encoding = null ]) : int
Parameters
$string : string

String.

$encoding : string|null = null

Encoding.

Return values
int

Number of characters or bytes in given $string (characters if/when supported, bytes otherwise).

strpos()

Multibyte-capable strpos() if support is available on the server.

public strpos(string $haystack, string $needle, int $offset[, string|null $encoding = null ]) : int|false

If not, it falls back to using \strpos().

Parameters
$haystack : string

Haystack.

$needle : string

Needle.

$offset : int

Offset.

$encoding : string|null = null

Encoding. Default null.

Return values
int|false

substr_replace()

Our wrapper around implementations of \substr_replace() that attempts to not break things horribly if at all possible.

public substr_replace(string $string, string $replacement, int $start[, int|null $length = null ][, string|null $encoding = null ]) : string

Uses mbstring if available, before falling back to regular substr_replace() (which works just fine in the majority of cases).

Parameters
$string : string

String.

$replacement : string

Replacement.

$start : int

Start offset.

$length : int|null = null

Length.

$encoding : string|null = null

Encoding.

Return values
string

inject_in_html()

Injects/replaces the given payload markup into `$html` at the specified location.

protected inject_in_html(string $payload, array<string|int, mixed> $where, mixed $html) : void

If the specified tag cannot be found, the payload is appended into $html along with a warning wrapped inside tags.

Parameters
$payload : string

Markup to inject.

$where : array<string|int, mixed>

Array specifying the tag name and method of injection. Index 0 is the tag name (i.e., </body>). Index 1 specifies ?'before', 'after' or 'replace'. Defaults to 'before'.

$html : mixed
Return values
void

Search results