Make WordPress Core

Opened 6 years ago

Closed 23 months ago

#34007 closed defect (bug) (worksforme)

WordPress symlink (windows) and tinymce plugins languages

Reported by: Hrohh Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3.1
Component: TinyMCE Keywords:
Focuses: javascript, administration Cc:


Hi, I have problem with loading tinymce plugins languages on symlinked wordpress. Because in wp-config.php users have option to set

define( 'WP_CONTENT_DIR', CONFIG_PATH . '/wp-content' );
define( 'WP_PLUGIN_DIR', CONFIG_PATH . '/wordpress/wp-content/plugins' );

so my workaround is replace
in wp-includes/class-wp-editor.php

I know, that isnt bullet proof, but it works

// Try to load langs/[locale].js and langs/[locale]_dlg.js
if ( ! in_array( $name, $loaded_langs, true ) ) {
-	$path = str_replace( content_url(), '', $plugurl );
-	$path = WP_CONTENT_DIR . $path . '/langs/';
+	$path = str_replace(site_url() . '/', '',$plugurl);
+	$path = str_replace('\\', '/', ABSPATH) . $path . '/langs/';

and with my ugly filter

function isSymbolicLink($target) {
    if (defined('PHP_WINDOWS_VERSION_BUILD')) {
        if(file_exists($target) && readlink($target) != $target) {
            return true;
    } elseif (is_link($target)) {
        return true;
    return false;
add_filter( 'plugins_url', 'plugins_url_for_wpmu_plugins', 9999, 3);
function plugins_url_for_wpmu_plugins( $url, $path, $plugin ) {
	if ( isSymbolicLink(ABSPATH)) {
		return str_replace('plugins/' . str_replace('\\', '/', ABSPATH) . 'wp-content/','',$url); 
	} else {
		$changes = str_replace('/wordpress/wp-content/','/wp-content/',$url); 
		return str_replace('wp-content/','wordpress/wp-content/',$changes);

Change History (2)

#1 @azaozz
6 years ago

Hi @Hrohh, thanks for the bug report.

It is generally better to not use langs/[locale].js and langs/[locale]_dlg.js. The later is a left-over from TinyMCE 3.x anyway.

Using langs/[locale].js will load another (usually very small) file making the overall load time longer. It seems better to paste all translated strings right into the plugin JS file and load the appropriate strings depending on the editor.settings.locale on editor.on( 'preInit', ... ).

#2 @azaozz
23 months ago

  • Resolution set to worksforme
  • Status changed from new to closed
  • Summary changed from Wordpress symlink (windows) and tinymce plugins languages to WordPress symlink (windows) and tinymce plugins languages

The best way to add translated strings to TinyMCE is to use the wp_mce_translation filter (in PHP). Note that you only need to translate strings that are not already translated by default.

Closing as worksforme. Feel free to reopen with a better solution/other ideas.

Note: See TracTickets for help on using tickets.