Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a category removes HTML from the description #287

Open
redelschaap opened this issue Oct 18, 2023 · 1 comment
Open

Updating a category removes HTML from the description #287

redelschaap opened this issue Oct 18, 2023 · 1 comment

Comments

@redelschaap
Copy link

We experience two issues regarding HTML in the product category description.

  1. When creating or updating a product category using the REST API, most HTML is removed from the category description. However, the description supports more HTML when creating or editing a product category in the WordPress Admin, so I would say that the description field in the REST API should also support the same HTML options.

  2. HTML is also removed from the category description when the description field is not included in the update request. In that case, I would expect that the description field remains unchanged.

Steps to reproduce:

  1. Given the current state of the description:
    image
  2. After updating the category (with or without the description field present):
    image
  3. The description is stripped from most HTML:
    image
@yulumadavid
Copy link

yulumadavid commented Jun 5, 2024

We also experience this behaviour. Nevertheless when you switch Yoast SEO off you are not able to add any tags like <h1> in it. So it seems the Woo rEST API just follows the IDE way.

There is a fix:

/**

  • Allow HTML in term (category, tag) descriptions
    */
    foreach ( array( 'pre_term_description' ) as $filter ) {
    remove_filter( $filter, 'wp_filter_kses' );
    if ( ! current_user_can( 'unfiltered_html' ) ) {
    add_filter( $filter, 'wp_filter_post_kses' );
    }
    }

foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants