Skip to content

Instantly share code, notes, and snippets.

@timwhitlock
Last active April 11, 2024 10:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save timwhitlock/8d4d2fa35c0ab312d040223ef6990e5b to your computer and use it in GitHub Desktop.
Save timwhitlock/8d4d2fa35c0ab312d040223ef6990e5b to your computer and use it in GitHub Desktop.
Prevents WordPress from automatically updating translation files in the global languages directory
<?php
/*
Plugin Name: Disable auto translation updates
Description: Prevents WordPress from automatically updating translation files in the global languages directory.
Author: Tim Whitlock
Version: 1.0
*/
/**
* https://developer.wordpress.org/advanced-administration/upgrade/upgrading/#configuration-via-filters
*/
if( function_exists('add_filter') ){
add_filter( 'auto_update_translation', '__return_false' );
}
@timwhitlock
Copy link
Author

timwhitlock commented Mar 9, 2017

Placing this file in the mu-plugins directory will prevent WordPress auto updates from overwriting translation files in the global "languages" directory at wp-content/languages.

This applies to core translations directly inside the folder, plus theme and plugin translations inside "languages/themes" and "languages/plugins" respectively.

Note that translation files inside the actual themes and plugins will be overwritten regardless.

@timwhitlock
Copy link
Author

timwhitlock commented Apr 11, 2024

The auto_update_translation filter is documented as auto_update_{type} https://developer.wordpress.org/reference/hooks/auto_update_type/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment