Make WordPress Core

Changeset 30296


Ignore:
Timestamp:
11/10/2014 02:07:00 AM (10 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-editor.php

    r30294 r30296  
    737737    }
    738738
    739     public static function wp_mce_translation() {
     739    /**
     740     * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n().
     741     * Can be used directly (_WP_Editors::wp_mce_translation()) by passing the same locale as set in the TinyMCE init object.
     742     *
     743     * @param string $mce_locale The locale used for the editor.
     744     * @param bool $json_only optional Whether to include the Javascript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone().
     745     * @return The translation object, JSON encoded.
     746     */
     747    public static function wp_mce_translation( $mce_locale = '', $json_only = false ) {
    740748
    741749        $mce_translation = array(
     
    963971         */
    964972
    965         $baseurl = self::$baseurl;
    966         $mce_locale = self::$mce_locale;
     973        if ( ! $mce_locale ) {
     974            $mce_locale = self::$mce_locale;
     975        }
    967976
    968977        /**
     
    9921001            $mce_translation['_dir'] = 'rtl';
    9931002        }
     1003
     1004        if ( $json_only ) {
     1005            return wp_json_encode( $mce_translation );
     1006        }
     1007
     1008        $baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' );
    9941009
    9951010        return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
Note: See TracChangeset for help on using the changeset viewer.