Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#20119 closed enhancement (fixed)

Use json_encode() to properly encode the translated strings for TinyMCE

Reported by: azaozz's profile azaozz Owned by: azaozz's profile azaozz
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)

#1 @azaozz
12 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [19993]:

Use json_encode when outputting translated strings for use in TinyMCE, fixes #20119

#2 follow-up: @nacin
12 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 @azaozz
12 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.

#4 @nacin
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [20601]:

Bail from wp-langs.php if we don't already have a WordPress environment. fixes #20119.

Note: See TracTickets for help on using tickets.