Title: WP_Textdomain_Registry::invalidate_mo_files_cache
Published: April 3, 2024
Last modified: April 28, 2025

---

# WP_Textdomain_Registry::invalidate_mo_files_cache( WP_Upgrader $upgrader, array $hook_extra )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#wp--skip-link--target)

Invalidate the cache for .mo files.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#parameters)󠁿

 `$upgrader`[WP_Upgrader](https://developer.wordpress.org/reference/classes/wp_upgrader/)
required

Unused. [WP_Upgrader](https://developer.wordpress.org/reference/classes/wp_upgrader/)
instance. In other contexts this might be a [Theme_Upgrader](https://developer.wordpress.org/reference/classes/theme_upgrader/),
[Plugin_Upgrader](https://developer.wordpress.org/reference/classes/plugin_upgrader/),
Core_Upgrade, or [Language_Pack_Upgrader](https://developer.wordpress.org/reference/classes/language_pack_upgrader/)
instance.

`$hook_extra`arrayrequired

Array of bulk item update data.

 * `action` string
 * Type of action. Default `'update'`.
 * `type` string
 * Type of update process. Accepts `'plugin'`, `'theme'`, `'translation'`, or `'
   core'`.
 * `bulk` bool
 * Whether the update process is a bulk update. Default true.
 * `plugins` array
 * Array of the basename paths of the plugins’ main files.
 * `themes` array
 * The theme slugs.
 * `translations` array
 *  Array of translations update data.
    - `language` string
    - The locale the translation is for.
    - `type` string
    - Type of translation. Accepts `'plugin'`, `'theme'`, or `'core'`.
    - `slug` string
    - Text domain the translation is for. The slug of a theme/plugin or `'default'`
      for core translations.
    - `version` string
    - The version of a theme, plugin, or core.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#source)󠁿

    ```php
    public 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;
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-textdomain-registry.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-textdomain-registry.php#L252)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-textdomain-registry.php#L252-L276)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_cache_delete()](https://developer.wordpress.org/reference/functions/wp_cache_delete/)`wp-includes/cache.php` |

Removes the cache contents matching key and group.

  | 
| [wp_list_pluck()](https://developer.wordpress.org/reference/functions/wp_list_pluck/)`wp-includes/functions.php` |

Plucks a certain field out of each object or array in an array.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/invalidate_mo_files_cache/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_textdomain_registry%2Finvalidate_mo_files_cache%2F)
before being able to contribute a note or feedback.