WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7994 closed defect (bug) (fixed)

Language files for TinyMCE dialogs aren't loaded for official TinyMCE plugins (like advlink)

Reported by: johnconners Owned by: azaozz
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.7
Component: TinyMCE Keywords:
Focuses: Cc:

Description

I use a WordPress plugin I've written that adds a few TinyMCE plugins not installed as standard by WP. I noticed that [9353] prevents the strings being loaded for the plugins that have popups. Attached is a screenshot of the advlink popup in action showing the problem.

Unwinding [9353] corrects the problem so I can confirm that's the changeset that introduces the behaviour.

The advlink plugin (along the other TinyMCE plugins that have popup dialogs I've looked at) have in the 'langs' subfolder 'en_dlg.js'. If I rename that file to 'en.js' and reload WP then when I click the link button while editing a post the language strings are loaded properly.

I can see in [9353] that while en.js is searched for, en_dlg.js isn't. Worth noting that some plugins have both en.js and en_dlg.js.

Attachments (1)

advlink-no-language-loaded.png (14.4 KB) - added by johnconners 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 azaozz6 years ago

  • Owner changed from anonymous to azaozz
  • Status changed from new to assigned

There is a filter

apply_filters('mce_external_languages', array());

for loading languages for external TinyMCE plugins that can be used also to ensure en.js and en_dlg.js are loaded when the selected translation is not available. Unfortunately it seems only a few WordPress plugins are using it.

Will add the check for [language]_dlg.js to the current function to cover the rest.

comment:2 johnconners6 years ago

Ah cool, wasn't sure if it was a bug or as intended. I did notice the mce_external_languages filter and that was my next port of call but thought I'd mention it anyway!

comment:3 azaozz6 years ago

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

(In [9469]) Remove outdated TinyMCE files, fix loading of translations for default plugins, fixes #7994

comment:4 ev3rywh3re6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Ha! About drove myself mad with this one

$path = preg_replace( '|.+?' . basename(WP_PLUGIN_URL) . '|', '', $plugurl );

Might a tad greedy. I can make changes to my plugins for it, but you make a WordPress plugin and organize TinyMCE Plugins into a subdirectory that has a name something like "tinymce_plugins" then the preg_replace will strip out everything up to plugins.

http://thesite.com/wp-content/plugins/tiny_mce_test/tinymce_plugins/xhtmlxtras

Becomes:

/home/thesite/wp-content/plugins/xhtmlxtras/langs/

A large hunk of the path "tiny_mce_test/tinymce_plugins/" gets parsed out.

comment:5 azaozz6 years ago

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

(In [9497]) Fix path when loading translations for default TinyMCE plugins from the plugins directory, fixes #7994

comment:6 azaozz6 years ago

Switching back to replacing WP_PLUGIN_URL with WP_PLUGIN_DIR should fix this. Still this is the fall-back method of loading translations in TinyMCE, the preferred method is to use the 'mce_external_languages' filter.

comment:7 ev3rywh3re6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

One more you should be aware of! The realpath function will strip that ending "/" you added to the $path.

$path = WP_PLUGIN_DIR . $path . '/langs/';

if ( function_exists('realpath') )
    $path = realpath($path);

Becomes: WP_PLUGIN_DIR/$path/langs

Wasn't sure how you wanted to handle that or I would have added a patch. To either remove the slash and add slashes to the later is_file statements. Or add the slash to $path after realpath.

comment:8 azaozz6 years ago

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

(In [9499]) Add slash to the path when loading translations for default TinyMCE plugins from the plugins directory, fixes #7994

comment:9 azaozz6 years ago

Only tested it briefly the first time, seemed to work well, but perhaps the translation js was in the browser's cache.

comment:10 jacobsantos6 years ago

  • Milestone changed from 2.8 to 2.7
Note: See TracTickets for help on using tickets.