TinyMCE: enable direct calls to `_WP_Editors::wp_mce_translation()`. When using TinyMCE directly, this makes it easier to load the translation of the default strings. Fixes #30293.
Built from https://develop.svn.wordpress.org/trunk@30296 git-svn-id: http://core.svn.wordpress.org/trunk@30295 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
383c75db29
commit
5f27bdc78d
|
@ -736,7 +736,15 @@ final class _WP_Editors {
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function wp_mce_translation() {
|
/**
|
||||||
|
* Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n().
|
||||||
|
* Can be used directly (_WP_Editors::wp_mce_translation()) by passing the same locale as set in the TinyMCE init object.
|
||||||
|
*
|
||||||
|
* @param string $mce_locale The locale used for the editor.
|
||||||
|
* @param bool $json_only optional Whether to include the Javascript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone().
|
||||||
|
* @return The translation object, JSON encoded.
|
||||||
|
*/
|
||||||
|
public static function wp_mce_translation( $mce_locale = '', $json_only = false ) {
|
||||||
|
|
||||||
$mce_translation = array(
|
$mce_translation = array(
|
||||||
// Default TinyMCE strings
|
// Default TinyMCE strings
|
||||||
|
@ -962,8 +970,9 @@ final class _WP_Editors {
|
||||||
* Url
|
* Url
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$baseurl = self::$baseurl;
|
if ( ! $mce_locale ) {
|
||||||
$mce_locale = self::$mce_locale;
|
$mce_locale = self::$mce_locale;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter translated strings prepared for TinyMCE.
|
* Filter translated strings prepared for TinyMCE.
|
||||||
|
@ -992,6 +1001,12 @@ final class _WP_Editors {
|
||||||
$mce_translation['_dir'] = 'rtl';
|
$mce_translation['_dir'] = 'rtl';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $json_only ) {
|
||||||
|
return wp_json_encode( $mce_translation );
|
||||||
|
}
|
||||||
|
|
||||||
|
$baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' );
|
||||||
|
|
||||||
return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
|
return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
|
||||||
"tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n";
|
"tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-alpha-30295';
|
$wp_version = '4.1-alpha-30296';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue