diff --git a/wp-includes/js/quicktags.dev.js b/wp-includes/js/quicktags.dev.js
index eed3b92ec6..10f87db690 100644
--- a/wp-includes/js/quicktags.dev.js
+++ b/wp-includes/js/quicktags.dev.js
@@ -264,6 +264,12 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
html += theButtons['fullscreen'].html(name + '_');
}
+
+ if ( 'rtl' == document.getElementsByTagName('html')[0].dir ) {
+ theButtons['textdirection'] = new qt.TextDirectionButton();
+ html += theButtons['textdirection'].html(name + '_');
+ }
+
ed.toolbar.innerHTML = html;
ed.theButtons = theButtons;
}
@@ -605,6 +611,21 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
fullscreen.on();
};
+ qt.TextDirectionButton = function() {
+ qt.Button.call(this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection)
+ };
+ qt.TextDirectionButton.prototype = new qt.Button();
+ qt.TextDirectionButton.prototype.callback = function(e, c) {
+ var isRTL = ( 'rtl' == document.getElementsByTagName('html')[0].dir ),
+ currentDirection = c.style.direction;
+
+ if ( ! currentDirection )
+ currentDirection = ( isRTL ) ? 'rtl' : 'ltr';
+
+ c.style.direction = ( 'rtl' == currentDirection ) ? 'ltr' : 'rtl';
+ c.focus();
+ }
+
// ensure backward compatibility
edButtons[10] = new qt.TagButton('strong','b','','','b');
edButtons[20] = new qt.TagButton('em','i','','','i'),
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index f44307761f..2811e3521c 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -79,7 +79,9 @@ function wp_default_scripts( &$scripts ) {
'enterImageURL' => __('Enter the URL of the image'),
'enterImageDescription' => __('Enter a description of the image'),
'fullscreen' => __('fullscreen'),
- 'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') )
+ 'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
+ 'textdirection' => esc_attr( __('text direction') ),
+ 'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
) );
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );