3

I am building a custom theme WordPress instance, which needs to be Arabic at the public face and English on Admin site, but with RTL (flush right) in editing fields. My theme takes care of the public face, but I need help with themeing the admin side.

I know there is a way to make the blog all Arabic, but I wanted all the admin labels and category names to stay English. I only want all admin text entry fields to become RTL. Oh, and plugins-generated text entry fields too, but I suspect that's more difficult.

I know it is a CSS change, but not sure where to start with such partial customization of the interface.

1 Answer 1

2

Good question. I was able to make the whole admin RTL with a little plugin (I wrote it as a must-use plugin, but should work in the in the standard plugin folder as well). It's a very simple version, see the output here:

RTL Admin v0.1 screen output

This is the plugin code (my file-name: rtl-admin.php):

<?php
/**
 * RTL Admin Wordpress Plugin
 *
 * @-wp-header Plugin Name: RTL Admin
 * @-wp-header Author: hakre
 * @-wp-header Version: 0.1
 * @-wp-header Author URI: http://hakre.wordpress.com/
 *
 * @author hakre <hakre.wordpress.com>
 * 
 * Copyright 2010  hakre <hakre.wordpress.com>
 *  
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *  
 * 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
 */

class RTLAdminPlugin {
 private static $instance;
 public static function bootstrap() {
  defined('WP_ADMIN') && WP_ADMIN 
  && (self::$instance === null) 
  && (self::$instance = new RTLAdminPlugin());
 }
 public function __construct() {
  $r = add_filter('admin_init', array($this, 'admin_init'));
 }
 public function admin_init() {
  $GLOBALS['wp_locale']->text_direction = rtl;
 }
} // class

RTLAdminPlugin::bootstrap();

return;
#EOF;
3
  • This is not quite it, as I don't want the whole admin interface switch direction, just edit fields. But it is helpful as a start. Aug 24, 2010 at 0:42
  • I don't think that all edit fields are using the same API, this might be especially the case for plugins. I think this needs some CSS override than for input fields only. This is textboxes only, right? Or is that dropdown and lists as well?
    – hakre
    Aug 24, 2010 at 14:03
  • Textboxes only. Dropdowns will be in English and I will convert them in the theme lookups. Aug 24, 2010 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.