Overide to force wordpress/woocommerce editor to accept DIV tags

I am currently using an override plugin developed with help from someone on stackoverflow which allows me to use elements with Perfect Woocommerce Brands plugin. since before the code was keeping

, … etc… but and div tags where stripped. The code I used:

add_action( ‘edit_pwb-brand’, ‘override_add_brands_metafields_save’, 9999 );
add_action( ‘create_pwb-brand’, ‘override_add_brands_metafields_save’, 9999 );

function override_add_brands_metafields_save( $term_id ) {
// NOTE: hard-coding the file name here in order to verify the nonce. MAY need to be changed
$filename = ‘class-brands-custom-fields.php’;
if ( ! isset( $_POST[ ‘pwb_nonce’ ] ) || ! wp_verify_nonce( $_POST[ ‘pwb_nonce’ ], $filename ) ) {
return;
}

// removed bits you didn’t care about, keeping only the relevant part

if ( isset( $_POST[ ‘pwb_brand_description_field’ ] ) ) {
// added div tag to allowed tags list
$desc = strip_tags(
wp_unslash( $_POST[ ‘pwb_brand_description_field’ ] ),
‘<input><label><div><p><span><a><ul><ol><li><h1><h2><h3><h4><h5><h6><pre><strong><em><blockquote><del><ins><img><code><hr>’
);

global $wpdb;
$wpdb->update( $wpdb->term_taxonomy, [ ‘description’ => $desc ], [ ‘term_id’ => $term_id ] );
}
}

I was wondering if I could do something similar to allow me to use div tags when writing my woocommerce product descriptions?

The above code is added as a plugin. Is there something I could add to functions.php maybe? that would have a similar effect on the wordpress editor?

Any help would be great

Read more here:: Overide to force wordpress/woocommerce editor to accept DIV tags

Leave a Reply

Your email address will not be published. Required fields are marked *