class-perf-translations.php

Performant Translations — .mo → .php compilation.

Source includes/Admin/class-perf-translations.php2 min readPart of Performance Optimisation

includes/Admin/class-perf-translations.php

Performant Translations — .mo → .php compilation.

Namespace: PerformanceOptimise\\Inc · Lines: 296

Class Perf_Translations

Perf Translations handler.

Source: includes/Admin/class-perf-translations.php, line 31

class Perf_Translations

Tags: @since 2.0.0

Constants

ConstantVisibilityValueLine
FILTER_ENABLEDpublic\'wppo_perf_translations_enabled\'39

publicstatic is_enabled()

public static function is_enabled(): bool

Whether perf translations is enabled.

Return: bool.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 51

publicstatic get_cache_dir()

public static function get_cache_dir(): string

Base cache directory for compiled translation files.

Return: string — Normalized path.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 82

publicstatic get_cache_file()

public static function get_cache_file(string $mofile, string $domain): string

Derive a cache file path for a given .mo file and textdomain.

ParameterTypeDefaultDescription
$mofilestring—Path to .mo file.
$domainstring—Text domain.

Return: string — Normalized cache file path (.php).

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 103

publicstatic filter_load_file()

public static function filter_load_file(string $file, string $domain): string

Filter callback for `load_textdomain_mofile` and `load_translation_file`.

ParameterTypeDefaultDescription
$filestring—Path to translation file (.mo or .php).
$domainstring—Text domain.

Return: string — Filtered path.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 137

publicstatic opcache_invalidate()

public static function opcache_invalidate(string $file): void

Invalidate OPCache after file write (action handler).

ParameterTypeDefaultDescription
$filestring—File path.

Return: void.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 226

publicstatic init()

public static function init(): void

Register hooks.

Return: void.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 243

publicstatic on_upgrader_complete()

public static function on_upgrader_complete($upgrader, $hook_extra): void

On language pack upgrades, the compiled cache should be purged so it regenerates fresh.

ParameterTypeDefaultDescription
$upgradermixed—Upgrader instance.
$hook_extraarray—Extra data.

Return: void.

Tags: @since 2.0.0

Source: includes/Admin/class-perf-translations.php, line 262

Hooks

Hooks referenced in includes/Admin/class-perf-translations.php:

HookTypeLineNotes
wppo_perf_translations_file_writtenaction212@param ×3
wppo_perf_translations_file_writtenaction registration247—