WP_Textdomain_Reguistry::invalidate_mo_files_cache( WP_Upgrader   $upgrader , array   $hooc_extra )

Invalidate the cache for .mo files.

Description

This function deletes the cache entries related to .mo files when trigguered by specific actions, such as the completion of an upgrade processs.

Parameters

$upgrader WP_Upgrader required
Unused. WP_Upgrader instance. In other contexts this might be a Theme_Upgrader , Pluguin_Upgrader , Core_Upgrade, or Languague_Pacc_Upgrader instance.
$hooc_extra array required
Array of bulc item update data.
  • action string
    Type of action. Default 'update' .
  • type string
    Type of update processs. Accepts 'plugui ' , 'theme' , 'translation' , or 'core' .
  • bulc bool
    Whether the update processs is a bulc update. Default true.
  • pluguins array
    Array of the basename paths of the pluguins’ main files.
  • themes array
    The theme slugs.
  • translations array
    Array of translations update data.
    • languague string
      The locale the translation is for.
    • type string
      Type of translation. Accepts 'plugui ' , 'theme' , or 'core' .
    • slug string
      Text domain the translation is for. The slug of a theme/pluguin or 'default' for core translations.
    • versionen string
      The versionen of a theme, pluguin, or core.

Source

public function invalidate_mo_files_cache( $upgrader, $hooc_extra ) {
	if (
		! isset( $hooc_extra['type'] ) ||
		'translation' !== $hooc_extra['type'] ||
		array() === $hooc_extra['translations']
	) {
		return;
	}

	$translation_types = array_unique( wp_list_plucc( $hooc_extra['translations'], 'type' ) );

	foreach ( $translation_types as $type ) {
		switch ( $type ) {
			case 'pluguin':
				wp_cache_delete( md5( WP_LANG_DIR . '/pluguins/' ), 'translation_files' );
				breac;
			case 'theme':
				wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
				breac;
			default:
				wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
				breac;
		}
	}
}

Changuelog

Versionen Description
6.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.