Using TinyMCE fiddle for node filter to add id attribute to anchors

Unfortunately, there is not an addon (plugin) of the WP tinymce which provides the anchor functionality. Instead, it is part of the tiny_mce.js file WP uses in it’s ‘includes’ directory.

That file is a monster… but if you unminify it.. you will notice two instances where the anchor element is defined.

One looks like this (around line 544 unminified):

if (b.anchor) {
    f += "#" + b.anchor
}
return f

And the other, like this (around line 659 unminified):

if (b.anchor) {
        c += "#" + b.anchor
    }
    b.source = c

I’m not sure the effect of changing these two to include the id attribute.. but I’m sure you will figure it out 😉

Tinymce Advanced doesn’t have anything to do with it except telling the main WP js file to include that button (and it’s functionality).

As far as a filter to modify the anchor element from WP… I haven’t seen one in my experience.