$data['mtime'] ) { // Import the translations from the MO file. if ( ! $mo->import_from_file( $mofile ) ) { return false; } // Create an array with the mtime, file, entries, and headers. $data = [ 'mtime' => $mtime, 'file' => $mofile, 'entries' => $mo->entries, 'headers' => $mo->headers, ]; // Export the data to a PHP file. $val = var_export( $data, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export // Replace Translation_Entry with \Soderlind\Plugin\A_Faster_Load_Textdomain\Translation_Entry. $val = str_replace( 'Translation_Entry::', '\Soderlind\Plugin\A_Faster_Load_Textdomain\Translation_Entry::', $val ); // Write the data to the cache file using WP_Filesystem if available, otherwise use file_put_contents. if ( ! WP_Filesystem() ) { file_put_contents( $cache_file, 'put_contents( $cache_file, '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 ); }