Skip Navigation

HTML in Toolset Custom Field Labels is stripped when saving the Fields

Resolved

Reported for: Toolset Types 3.3.4

Resolved in: 3.3.9

Symptoms

Toolset Types allows you to add HTML to the custom field labels.

Starting from version 3.3.4 and upwards, Types will remove HTML from the Fields Labels when the Fields are saved.

Technically, only the < character is removed but that effectively breaks any HTML you add to the labels.

Workaround

This will be fixed in the upcoming version of Types. Until then, you can download this patch and overwrite the file types/vendor/toolset/types/embedded/includes/fields.php with the patched version.

After patching or with the next version, it will be possible to allow HTML in field labels again by using a filter types_sanitize_field_labels either to functions.php of your theme or as a code snippet. We recommend using the latter.

In Toolset Settings -> Custom Code, add a new code snippet:

  • Run mode: Run always
  • Run context: WordPress admin
  • Content: php

Snippet content:

<?php
/**
 * Deactivate the sanitization of custom field and field option labels, 
 * so that they can contain HTML code.
 *
 * Note that this is not recommended for sites that don't explicitly need it.
 * Disabling sanitization can have undesired security or other ramifications.
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.
add_filter( 'types_sanitize_field_labels', '__return_false' );

Don’t forget to save and activate the snippet.

After this, it will again become possible to use HTML code in labels of field and field options.

We’re sorry for the inconvenience, however, this is a potential security issue that needed to be addressed.

3 thought on HTML in Toolset Custom Field Labels is stripped when saving the Fields

    • Hello Rafael, I’ve just updated the erratum with a patch. I’m sorry for the delay… Please let me know if it solves your problem.

Comments are closed