Chris
Chris

Reputation: 301

Wordpress TinyMCE not converting simple 'www.sitename.com' to hyperlink, as in demos

Despite the behavior of examples shown on TinyMCE's demo pages (http://www.tinymce.com/tryit/classic.php), I am unable to get TinyMCE on my Wordpress 4.0 site to act in such a way that if you simply type "www.sitename.com" into the editor and press space, it's automatically converted into a hyperlink for http://www.sitename.com/.

To be clear, it doesn't convert into any link at all...This isn't a case of absolute vs. relative links. That's what most of the talk seems to be about when it comes to TinyMCE and link creation. ...Would that I could get to that stage!

I can find no toggle or option or plugin name to enable automatic link creation, and yet it's there in their demos on the TinyMCE's site.

Can anyone tell me how I might get this feature up and running, ideally by not adding another Wordpress plugin?

Err...That being said, I'm open to a suggestion if you have a really good one! :)

Cheers!

Upvotes: 2

Views: 527

Answers (1)

maiorano84
maiorano84

Reputation: 11980

Even though you found a plugin, some background might help because I personally think this is a good question:

Wordpress uses TinyMCE, however the Wordpress WYSIWYG Editor is actually heavily extended and no longer fully resembles the original TinyMCE editor you see on the TinyMCE website.

In order for links to automatically render in TinyMCE, the 'autolink' plugin needs to be enabled. The following native TinyMCE plugins are used by Wordpress:

  1. charmap
  2. colorpicker
  3. hr
  4. lists
  5. media
  6. paste
  7. tabfocus
  8. textcolor
  9. fullscreen
  10. image

In addition to these, Wordpress also employs the following custom plugins to fill out the remainder of the functionality you normally see:

  • wordpress
  • wpautoresize
  • wpeditimage
  • wpgallery
  • wplink
  • wpdialogs
  • wpview

It is my belief that Wordpress left out this behavior by design. As you know, the Autolink plugin specifically converts all valid URLs to comparable anchor tags once the space or return keys are pressed. However, Wordpress does allow you to explicitly convert URLs or words to anchor tags using its own plugin 'wplink'.

It should be noted that the wplink plugin closely resembles the native anchor plugin, but is NOT the same.

With the ability to both explicitly define your links in both the visual editor (via the wplink plugin) and the Text (aka: HTML) editor, I believe the development team decided to forgo on automatically linking content in favor of allowing authors to explicitly provide links where needed.

With all of that said:

Wordpress does provide a convenient way of adding new TinyMCE plugins via its 'mce_external_plugins' filter. If you would like to add the autolink functionality without the use of an external plugin, you may download the latest TinyMCE package, upload the autolink plugin (tinymce/js/tinymce/plugins/autolink) to your theme folder, and then add the following to your theme's functions.php:

add_filter('mce_external_plugins', 'mm_add_tinymce_plugins');
function mm_add_tinymce_plugins($plugins){
    $plugins['autolink'] = get_stylesheet_directory_uri().'/path/to/tinymce/plugins/autolink/plugin.js';
    return $plugins;
}

Upvotes: 1

Related Questions