I need to append a default text block to each product description (same text for each and every product) in WooCommerce. So I've created simple plugin which adds new settings field as rich text editor (wp_editor) into "WooCommerce > Settings > Catalog" tab.

All works fine and I can enter/save plain text, but it strips any HTML tags. I believe tags are stripped by woocommerce_clean in settings-save.php

if ( isset( $value['id'] ) && isset( $_POST[$value['id']] ) ) {
 update_option($value['id'], woocommerce_clean($_POST[$value['id']]));
} elseif( isset( $value['id'] ) ) {

How can this be fixed without changing core code?

  • Is the text the same on each and every product?
    – Steve
    Commented Feb 2, 2013 at 21:04
  • Yes, it's the same for all products.
    – Tomas
    Commented Feb 2, 2013 at 21:13

1 Answer 1


The woocommerce_clean function: return trim( strip_tags( stripslashes( $var ) ) ); is pretty much going to stip out any html. You may be able to use core WordPress sanitize and escaping functions, but no guarantee how WooCommerce is going to react.

Take a look at Data Validation docs on the WordPress Codex for other options.

Since your boilerplate text is the same on every product your simplest solution may be copy the default WooCommerce template(s) into your theme's directory and editing the file(s) as needed. Seems like overkill to write a user interface for this.

If you want to display this in the product 'Short Description' then the file would be ../wp-content/plugins/woocommerce/templates/single-product/short-description.php. Copy that file to your your theme's directory ../wp-content/themes/***your theme directory***/woocommerce/single-product/short-description.php

Once you've copied you can edit the file without worrying about your changes being overwritten when you update WooCommerce.

The docs on customizing the templates are at WooCommerce docs.

NOTE: If you want this in the Description tab you can use the file ../wp-content/plugins/woocommerce/templates/single-product/tabs/description.php

  • Thanks @Stephen. That's how I did it (added required text into the template). My concern with this solution is that shop manager will not be able to change that text easily and that's why I'm trying to make it editable through admin interface.
    – Tomas
    Commented Feb 2, 2013 at 21:57
  • @Tomas, I added a link that might be helpful. It's to the 'Data Validation' page on the codex. Should get you started.
    – Steve
    Commented Feb 2, 2013 at 22:05
  • @Thomas after re-reading the question it makes sense. My first impression was you were doing a per product option rather than a global option.
    – Steve
    Commented Feb 2, 2013 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.