Invalidate the cache for .mo files.
This function deletes the cache entries related to .mo files when triggered by specific actions, such as the completion of an upgrade process.
$upgraderWP_Upgraderrequired
$hook_extraarrayrequired
action string'update'.type string'plugin', 'theme', 'translation', or 'core'.bulk boolplugins arraythemes arraytranslations arraylanguage stringtype string'plugin', 'theme', or 'core'.slug string'default' for core translations.version stringpublic function invalidate_mo_files_cache( $upgrader, $hook_extra ) {
if (
! isset( $hook_extra['type'] ) ||
'translation' !== $hook_extra['type'] ||
array() === $hook_extra['translations']
) {
return;
}
$translation_types = array_unique( wp_list_pluck( $hook_extra['translations'], 'type' ) );
foreach ( $translation_types as $type ) {
switch ( $type ) {
case 'plugin':
wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
break;
case 'theme':
wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
break;
default:
wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
break;
}
}
}
| Version | Description |
|---|---|
| 6.5.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache