• Resolved Reggiewjr1

    (@reggiewjr1)


    Greetings Andrew,

    I believe this is the plug-in I need, I’ve spent several hours today studying up on my issue, and I was wondering if you could help.

    Clients site uses WordPress (clearly) and Google Analytics. With GA Event Tracking, you are instructed to use something similar to the following:

    <a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);">Play</a>

    As it stands now though TinyMCE strips out all onClicks from a href’s as it sees them as invalid code (for security purposes as I understand it) when switching between HTML & WYSIWYG editors. Editing the core code/configuration directly is not an option we are fond of.

    I believe I need to use Adv TinyMCE Config to add a new option, I just am not confident on the exact formatting…Again, I’m just trying to add onClick to the valid elements list… I understand its “bad practice” but I’m not going to try and tell Google that…

    Option Name: extended_valid_elements
    Value: ???

    Thank you in advance.

    https://wordpress.org/plugins/advanced-tinymce-configuration/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Reggiewjr1

    (@reggiewjr1)

    OK, so I found another article, several pages deep on Google, that seems to list all the default valid_elements, but it is a little out of date.

    This is what I’ve come up with for an updated extended_valid_elements setting:

    a[rel|rev|charset|hreflang|tabindex|accesskey|type|” + “name|href|target|title|class|onfocus|onblur|onclick]

    However, when I install and activate Advanced TinyMCE Configuration, I get a warning as described in your changelog, that settings need to be updated, or it may “break” my editor. Which it has done… When I activate this plugin, and try to edit a page, the TinyMCE editor options are not showing above the code text area.

    Have deactivated this plugin, and investigating other options until a reply is received. Hoping to receive support soon, but it’s been 3 months since developer has replied to anyone (?).

    I am running the most current version of WP/TinyMCE with TinyMCE Advanced.

    Plugin Author Andrew Ozz

    (@azaozz)

    Yes, the Advanced TinyMCE Configuration plugin gives access to the “low level” TinyMCE settings. That makes it very “powerful” but also doesn’t prevent errors when something is not set properly.

    The example setting you posted above works for me. The difference is that it needs to be added all on one line and without quotes. The properly formatted value is:

    a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick]

    BTW this list of attributes doesn’t include all of the HTML 5.0 attributes and also adds onfocus and onblur (not sure if you need these). The full list is

    a[accesskey|charset|class|contenteditable|contextmenu|coords|dir|download|draggable|dropzone|hidden|href|hreflang|id|lang|media|name|rel|rev|shape|spellcheck|style|tabindex|target|title|translate|type|onclick|onfocus|onblur]

    Another option would be to just add a[*] which will turn off checking attributes on that tag completely.

    Thread Starter Reggiewjr1

    (@reggiewjr1)

    Thank you for your reply!

    I was having a heck of time trying to find/compile a complete list… I couldn’t find the default in the code anywhere…

    I do not need onfocus or onblur, now that you mention it, thank you for your help, I have removed them, it works now especially without that line break… I think note pad wordwrap snuck that in there on me? Not sure…

    But again, thank you for your assistance!!

    lkepchar

    (@lkepchar)

    I am having the same problem. I am using TinyMCE Advanced and just installed the Advanced TinyMCE Cofig plugin. I added a new option name “a” and this for the value

    a[accesskey|charset|class|contenteditable|contextmenu|coords|dir|download|draggable|dropzone|hidden|href|hreflang|id|lang|media|name|rel|rev|shape|spellcheck|style|tabindex|target|title|translate|type|onclick|onfocus|onblur]

    But my tracking code is still being stripped. Any suggestions on what I may be doing wrong?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘extended__valid_elements adjusted to allow a href onClick attribute’ is closed to new replies.