WordPress.org

Forums

WP SVG Icons
[resolved] Prevent icon code removal when switching from Text to Visual? (7 posts)

  1. jf80
    Member
    Posted 1 year ago #

    If I add an icon to a post:
    <span data-icon="" style="font-size:1000%; color:green;"></span>

    I understand it must be done on the Text tab.

    If I switch to Visual then my icon code is removed.

    Is there any way around this?

    Thanks.

    http://wordpress.org/plugins/svg-vector-icon-plugin/

  2. Evan Herman
    Member
    Plugin Author

    Posted 1 year ago #

    Hi jf80,

    This is a known issue when using the plugin. Unfortunately, from the research I've done on resolving this, the issue lies with the TinyMCE WYSIWYG text editor. One of the intended functionality of TinyMCE is stripping out any unfiltered HTML from the visual tab.

    The only way I was able to resolve the issue myself was by hacking away at the TinyMCE core (which is less than ideal as it will be overwritten on WP updates).

    Apparently with TinyMCE version 4.0 this issue has been remedied and switching between text and visual tabs no longer strips out the code. We have to wait for the WordPress core team to implement a newer version of TinyMCE before we no longer have this issue.

    Sorry about the inconvenience , I know how frustrating it can be to have code stripped away after spending a good deal of time writing it in the first place.

    Thanks for downloading the plugin!

    -Evan

  3. jf80
    Member
    Posted 1 year ago #

    Ok, thanks for responding.

  4. Evan Herman
    Member
    Plugin Author

    Posted 1 year ago #

    WordPress 3.9 will feature TINYmce v 4.0, which should (finally) resolve the issue of code being stripped.

    I also believe the code may be stripped due to the ampersand (&) in the icon code. Which, if that's the case, I'll have to re-code the icon codes my self.

    Thanks,
    Evan

    http://make.wordpress.org/core/2014/01/18/tinymce-4-0-is-in-core/

  5. WP Monkey
    Member
    Posted 10 months ago #

    I'm on WP 4.0 and still experiencing this issue. Any thoughts on an update or workaround?

    Thanks.

  6. Evan Herman
    Member
    Plugin Author

    Posted 10 months ago #

    Hi WP Monkey,

    Unfortunately, the fix didn't make it into the latest core update (4.0). As it sits now, there is no solid work around. A few plugins claim to add the ability to prevent unfiltered HTML from being stripped, but I still have yet to get one of them working properly.

    From the few emails I had with another users of the plugin, we were able to come up with a solid work around.

    Instead of using the 'data-icon' parameter on the icon itself, you can create an element and use an appropriate class name to assign the icon. For example, the following will work and will prevent the unfiltered HTML from being stripped out:

    <i class="wp-svg-icon-set1-home"></i>

    That will create a home icon, using the provided class name instead of the alternate methods mentioned in the plugin. You'll want to make sure that the contents of the element are NOT empty tho, because sometimes the content editor will strip out elements that are empty.

    To be safe, add a space inside of the element :
    <i class="wp-svg-icon-set1-home"> </i>
    (notice the space)

    I am hoping that in the coming days I can loop back around and update the documentation within the plugin, as well as on the site to let users know that this is a valid and working method for generating icons and to prevent this issue. I also need to specify the class name of each icon as they are clicked, so the user knows what classname to use.

    Evan

  7. WP Monkey
    Member
    Posted 10 months ago #

    I've been having a lot of code stripped from my pages, plus I needed to add some header code to only two pages on the site (not all) and I found this plugin works for both well.

    https://wordpress.org/plugins/css-javascript-toolbox/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP SVG Icons
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.