Support » Plugin: Allow HTML in Category Descriptions » html still removed

  • Resolved laddaa

    (@laddaa)


    Hi, not sure if I’m failing to see the obvious

    I just tried to install this plugin., but WordPress is still sanitizing the category descriptions. I also tried installing it on a completely different WordPress installation, same effect.

    I also tried to manually remove via functions.php (I understand your plugin is basically doing this?) and still doesn’t work:

    foreach ( array( 'pre_term_description' ) as $filter ) {
        remove_filter( $filter, 'wp_filter_kses' );
    }
     
    foreach ( array( 'term_description' ) as $filter ) {
        remove_filter( $filter, 'wp_kses_data' );
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Arno Esterhuizen

    (@arnoesterhuizen)

    Hi, laddaa

    Are you using the same theme on both sites you tested? It is possible that the theme is stripping out the html.

    The best way to confirm this is to go to the admin section of your site and having a look at the categories list: if the HTML is striped there, too, the functions may not be activating correctly. If it _isn’t_ stripped out, then your theme may be the culprit stripping out the html from the category descriptions.

    Let me know what you discover and I can see if I can help some more.

    Thread Starter laddaa

    (@laddaa)

    Hi Arno

    thanks for having a look! So I have found the same behaviour with two themes (twentytwentyone and astra-free) on one server and with astra-pro on another server.

    On the first server an in put in the category description of

    <span>
    <div>item 1</div>
    <div>item 2</div>
    <div>item 3</div>
    </span>

    With the Twenty Twenty-One theme, and all plugins deactivated it return this on the frontend:

    <p><span></span></p>
    <div>item 1</div>
    <div>item 2</div>
    <div>item 3</div>
    <p></p>

    The output is the same with the Astra theme on both servers. If you don’t line break and literally concatenate the html tags it is more likely that a wrapping span will make it through.

    The only thing I can’t easily deactivate for testing is the multisite – both servers run multisite. Maybe if I get around to it I’ll do a fresh install somewhere and see if I can get your plugin to work at all.

    Any ideas so long?

    Thread Starter laddaa

    (@laddaa)

    so, I have had the chance to install a completely new, vanilla wordpress instance and test the issue again.

    – fresh install
    – installed plugin
    – added html to category description (worked as expected)
    – installed astra theme (html garbled! as in previous post)
    – removed astra theme and switch back to default (html still garbled)
    – deactivated plugin (html removed as expected)
    – reactivated plugin (html still garbled)

    Plugin Author Arno Esterhuizen

    (@arnoesterhuizen)

    This is bizarre. I wonder if the Astra theme does any additional processing to the category descriptions.

    After you disable the Astra theme and re-add the html, does it still show up as garbled?

    You should be able to disable my plugin after saving the category descriptions, and if you don’t edit the categories, the descriptions should still show HTML.

    The process behind my plugin works as follows: after you fill in the category description and click the “save” button, WordPress puts the text input through a filter that strips out all HTML, and stores this cleaned version in the database. My plugin tells WordPress: skip this HTML stripping filter, carry on with the other filters, though.

    Once this is saved into the database, the HTML stays in place. My plugin only kicks in on the save process; the rest of the time it’s just hanging around doing nothing.

    Plugin Author Arno Esterhuizen

    (@arnoesterhuizen)

    Wait, you mentioned multisite; I just noticed that detail.

    With multisite, I need to check whether you have unfiltered_html permissions (for security reasons). If your user does not have unfiltered_html permissions granted by the superadmin, the plugin is unable to tell WordPress to skip the filters.

    See https://wordpress.org/support/article/roles-and-capabilities/#unfiltered_html for more info about the unfiltered_html capability.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘html still removed’ is closed to new replies.