Title: _mce_set_direction
Published: April 25, 2014
Last modified: May 20, 2026

---

# _mce_set_direction( array $mce_init ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Sets the localized direction for MCE plugin.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#description)󠁿

Will only set the direction to ‘rtl’, if the WordPress locale has the text direction
set to ‘rtl’.

Fills in the ‘directionality’ setting, enables the ‘directionality’ plugin, and 
adds the ‘ltr’ button to ‘toolbar1’, formerly ‘theme_advanced_buttons1’ array keys.
These keys are then returned in the $mce_init (TinyMCE settings) array.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#parameters)󠁿

 `$mce_init`arrayrequired

MCE settings array.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#return)󠁿

 array Direction set for `'rtl'`, if needed by locale.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#source)󠁿

    ```php
    function _mce_set_direction( $mce_init ) {
    	if ( is_rtl() ) {
    		$mce_init['directionality'] = 'rtl';
    		$mce_init['rtl_ui']         = true;

    		if ( ! empty( $mce_init['plugins'] ) && ! str_contains( $mce_init['plugins'], 'directionality' ) ) {
    			$mce_init['plugins'] .= ',directionality';
    		}

    		if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) {
    			$mce_init['toolbar1'] .= ',ltr';
    		}
    	}

    	return $mce_init;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/functions.php#L4782)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/functions.php#L4782-L4797)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#related)󠁿

| Uses | Description | 
| [is_rtl()](https://developer.wordpress.org/reference/functions/is_rtl/)`wp-includes/l10n.php` |

Determines whether the current locale is right-to-left (RTL).

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_mce_set_direction/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_mce_set_direction%2F)
before being able to contribute a note or feedback.