WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#18150 closed defect (bug) (duplicate)

languages files for tinymce external plugin don't work properly in the theme files

Reported by: kaptinlin Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: TinyMCE Keywords: has-patch dev-feedback
Focuses: Cc:

Description

When adding a external tinymce plugin by using mce_external_plugins hook in the theme's function.php file

It will not load language files in TINYMCE_PLUGIN_PATH/langs/ folder.

Then i look into the code of \wp-admin\includes\post.php file.

In line 1498 of version 3.2.1

The code is below

$path = str_replace( WP_PLUGIN_URL, '', $plugurl );
$path = WP_PLUGIN_DIR . $path . '/langs/';

It just replace the url of plugin folder with the real path.

When you echo the $path , you will see

'D:\wamp\www\wordpress/wp-content/pluginshttp://localhost/wordpress/wp-content/themes/theme_name/tinymce/langs/'

The correct one should be

'D:\wamp\www\wordpress/wp-content/themes/theme_name/tinymce/langs/'

So i add some code to fix it. Just replace the line 1498-1499 of \wp-admin\includes\post.php (version 3.2.1) with the code below.

if(false !== strpos($plugurl, WP_PLUGIN_URL)){
		$path = str_replace( WP_PLUGIN_URL, '', $plugurl );
		$path = WP_PLUGIN_DIR . $path . '/langs/';
}else{
		$path = str_replace( get_template_directory_uri(), '', $plugurl );
		$path =  get_template_directory(). $path . '/langs/';
}

It works perfect.

Attachments (2)

post.zip (16.4 KB) - added by kaptinlin 3 years ago.
post.php (60.4 KB) - added by kaptinlin 3 years ago.
wp-admin\includes\post.php

Download all attachments as: .zip

Change History (3)

kaptinlin3 years ago

kaptinlin3 years ago

wp-admin\includes\post.php

comment:1 azaozz3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Yes, the current code expects that extra TinyMCE plugins are added from wp-content/plugins. Currently I'm refactoring this and will switch it to look in wp-content directory instead.

Closing this as duplicate of #17144 as it should be handled there.

Note: See TracTickets for help on using tickets.