daily pastebin goal
11%
SHARE
TWEET

Frontend in English

a guest Mar 25th, 2014 39 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. <?php
  2. /*
  3. Plugin Name: Frontend in English
  4. Description: Admin is displayed in the installed language, but the rest of the site is shown in default English
  5. Version: 0.001
  6. Author: Nikolay Bachiyski, Dero
  7. Author URI: http://nikolay.bg/
  8. Tags: translation, translations, i18n, admin, english, localization, backend
  9. */
  10.  
  11. function frontend_in_english_add_hooks() {
  12.         add_filter( 'locale', 'frontend_in_english_locale' );
  13. }
  14. add_action( 'plugins_loaded', 'frontend_in_english_add_hooks' );
  15.  
  16. function frontend_in_english_locale( $locale ) {
  17.         if ( frontend_in_english_should_use_english() ) {
  18.                 return 'en_US';
  19.         }
  20.         return $locale;
  21. }
  22.  
  23. function frontend_in_english_should_use_english() {
  24.         // frontend AJAX calls are mistakend for admin calls, because the endpoint is wp-admin/admin-ajax.php
  25.         return frontend_in_english_is_frontend() || frontend_in_english_is_frontend_ajax();
  26. }
  27.  
  28. function frontend_in_english_is_frontend() {
  29.         return
  30.                 ! is_admin() && ! frontend_in_english_is_tiny_mce() && ! frontend_in_english_is_login_page();
  31. }
  32.  
  33. function frontend_in_english_is_frontend_ajax() {
  34.         return defined( 'DOING_AJAX' ) && DOING_AJAX && false === strpos( wp_get_referer(), '/wp-admin/' );
  35. }
  36.  
  37. function frontend_in_english_is_tiny_mce() {
  38.         return false !== strpos( $_SERVER['REQUEST_URI'], '/wp-includes/js/tinymce/');
  39. }
  40.  
  41. function frontend_in_english_is_login_page() {
  42.         return false !== strpos( $_SERVER['REQUEST_URI'], '/wp-login.php' );
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top