WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Enable XHTML in term descriptions (8 posts)

  1. rh3sus
    Member
    Posted 4 years ago #

    I have a site that I started building on version 2.8 that relies heavily on custom taxonomies.

    I need to use html in my term descriptions for adding pictures e.t.c.

    In 2.8 I added
    remove_filter( 'pre_term_description', 'wp_filter_kses' ); in my functions.php which enabled html in the term descriptions.
    Since upgrading to 2.9 this no longer works, and html is filtered out of the descriptions on display (it is still saved in the editor).

    I have a feeling this may have something to do with

    Add a 'the_terms' filter
    or
    # Filter fields through kses upon display and introduce sanitize_user_object() and sanitize_user_field()
    mentioned in the 2.9 Codex but don't know how I can override this.

    So, does anyone know how I can enable html in term descriptions as of 2.9?
    Many thanks.

  2. rh3sus
    Member
    Posted 4 years ago #

    I've updated to 2.9.1 and the problem still persists. Anyone?

  3. quirk
    Member
    Posted 4 years ago #

    I'm having the same problem. Hate it when "upgrades" break my website.

  4. quirk
    Member
    Posted 4 years ago #

    Think this may involve some of the deprecated things in /wp-includes/deprecated.php

  5. rh3sus
    Member
    Posted 4 years ago #

    Think this may involve some of the deprecated things in /wp-includes/deprecated.php

    Not a bad idea, but I just read through that file and could not find any functions relating to filtering of content in this way.
    I'm going to start grepping through all the files in 2.9.1 now to see what I can find that might relate to this.

  6. rh3sus
    Member
    Posted 4 years ago #

    I looked for the the_terms filter that I mentioned in my first post but that is only for displaying terms in a list so it doesn't seem like it is related to term descriptions.

    I think it might be something in wp-includes/default-filters.php

  7. rh3sus
    Member
    Posted 4 years ago #

    Ok, I have found it.

    I added remove_filter( 'term_description', 'wp_kses_data' ); to my functions.php and images are now displayed again.

    [stop reading here and just apply the above if you don't want the geeky explanation]

    Turns out (I think) that it has been changed so that wp_filter_kses is for filtering when you save the description in wp-admin and wp_kses_data has been added to filter on display of the page, so you will need both the remove_filter lines in your themes functions.php

    The functions run through $allowedtags in wp-includes/kses.php so an alternative would be to add 'img', 'src' e.t.c to the allowed tags list, which would enable you still filter but let images and whatever allowed tags you add through. This explains why links still worked - 'a' and 'href' are allowed tags by default. While this would allow you to still filter other stuff in the post out, you would have to make the change to kses.php after every wordpress update.

  8. rh3sus
    Member
    Posted 4 years ago #

    quirk please confirm if this works for you too and i'll mark the thread as resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic