failed ) { // If the cache directory could not be created, return false. return false; } // Get the cached data for the MO file. $data = $cache_handler->get_cache_data( $mofile ); // Get the last modification time of the MO file. $mtime = filemtime( $mofile ); // Create a new instance of the MO class. $mo = new \MO(); // If there's no cached data or the MO file has been modified since the last cache update... if ( ! $data || ! isset( $data['mtime'] ) || $mtime > $data['mtime'] ) { // ...try to import the MO file. if ( ! $mo->import_from_file( $mofile ) ) { return false; } // Prepare the data to be cached. $data = [ 'mtime' => $mtime, // The last modification time of the MO file. 'file' => $mofile, // The path to the MO file. 'entries' => $mo->entries, // The entries from the MO file. 'headers' => $mo->headers, // The headers from the MO file. ]; // Update the cached data. $cache_handler->update_cache_data( $mofile, $data, __NAMESPACE__ . '\Translation_Entry' ); } else { // If the cached data is up-to-date, use it to set the entries and headers of the MO object. $mo->entries = $data['entries']; $mo->headers = $data['headers']; } // Merge the translations with the existing translations for the domain. if ( isset( $l10n[ $domain ] ) ) { $mo->merge_with( $l10n[ $domain ] ); } // Set the translations for the domain. $l10n[ $domain ] = &$mo; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited // Return true to indicate success. return true; } if ( version_compare( $GLOBALS['wp_version'], '6.3' ) >= 0 ) { \add_filter( 'pre_load_textdomain', __NAMESPACE__ . '\a_faster_load_textdomain', 1, 4 ); } else { \add_filter( 'override_load_textdomain', __NAMESPACE__ . '\a_faster_load_textdomain', 0, 3 ); } if ( version_compare( $GLOBALS['wp_version'], '6.5', '>=' ) ) { // admin messages. \add_action( 'admin_notices', function () { ?>

A faster load_textdomain is not needed in WordPress 6.5 and later, please deactivate the plugin.', 'a-faster-load-textdomain' ); ?>

built into WordPress core.', 'a-faster-load-textdomain' ); ?>

.l10n.php format, use the Performant Translations plugin', 'a-faster-load-textdomain' ); ?>