Opened 13 years ago
Closed 13 years ago
#20119 closed enhancement (fixed)
Use json_encode() to properly encode the translated strings for TinyMCE
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | TinyMCE | Keywords: | |
Focuses: | Cc: |
Description
Similar to $wp_scripts->localize(). It's better/safer to use json_encode when outputting translated strings for use in JS.
Change History (4)
#2
follow-up:
↓ 3
@
13 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Question, is this necessary at this point?
8 if ( ! class_exists( '_WP_Editors' ) ) 9 require( ABSPATH . WPINC . '/class-wp-editor.php' );
If this file is directly referenced, class-wp-editor.php will not be enough to prevent a fatal error.
I'm curious mainly because a direct reference could otherwise pose problems for servers that do not have JSON compiled into PHP. (If it weren't for the fact that it would trip over, for example, __
.)
#3
in reply to:
↑ 2
@
13 years ago
Replying to nacin:
... If this file is directly referenced, class-wp-editor.php will not be enough to prevent a fatal error.
Yes, perhaps we can remove that and/or add if ( ! defined('ABSPATH') ) exit;
to make sure it's never loaded directly.
In a default TinyMCE configuration tinymce/langs
would contain all the different [locale].js files. However in WP we've always used our translation methods and outputted the translated strings from PHP and wp-langs.php has always required to run inside WordPress.
Thinking more about it, the translations function should probably be a part of _WP_Editors rather than being in a separate file in tinymce/langs
.
Regarding installs on servers without JSON compiled into PHP: thinking they have already worked that out either by loading class-json.php or by updating their PHP installation.
In [19993]: