Skip to content

Instantly share code, notes, and snippets.

@entr
Last active August 29, 2015 14:17
Show Gist options
  • Save entr/f8c2f69b6e9f545696f7 to your computer and use it in GitHub Desktop.
Save entr/f8c2f69b6e9f545696f7 to your computer and use it in GitHub Desktop.
WP Admin Locale
<?php
/*
Plugin Name: WP Admin locale
Description: Force en_US locale in WP Admin
Plugin URI: https://gist.github.com/f8c2f69b6e9f545696f7.git
Author: WPTailor
Author URI: http://wptailor.com/
Version: 0.1
License: GPL2
*/
/*
Copyright (C) 2015 WPTailor info@wptailor.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
defined('ABSPATH') or exit;
function force_admin_locale( $locale ) {
/**
* We don't filter locale on options-general.php
* because it's used in `Site Language` select.
* Bail if doing ajax also.
*/
if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/options-general.php' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! apply_filters( 'force_admin_locale', true ) )
return $locale;
if ( function_exists( 'is_admin' ) && is_admin() ) {
$locale = apply_filters( 'force_admin_locale_code', 'en_US' );
}
return $locale;
}
add_filter('locale', 'force_admin_locale' );
add_filter('plugin_locale', 'force_admin_locale' );
{
"name": "wptailor/admin-locale",
"description": "Force en_US locale in WP Admin",
"type": "wordpress-plugin",
"authors": [
{
"name": "WPTailor",
"email": "info@wptailor.com"
}
],
"require": {
"php": ">=5.3.2",
"composer/installers": "~1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment