{"id":4682,"date":"2026-02-24T10:00:31","date_gmt":"2026-02-24T16:00:31","guid":{"rendered":"https:\/\/racmanuel.dev\/?post_type=docs&#038;p=4682"},"modified":"2026-02-24T10:00:39","modified_gmt":"2026-02-24T16:00:39","password":"","slug":"html","status":"publish","type":"docs","link":"https:\/\/racmanuel.dev\/en\/docs\/custom-fields-booster\/html\/","title":{"rendered":"HTML"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Provides an HTML editor powered by WordPress CodeMirror.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The field stores sanitized HTML as a string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"use-cases\">Use Cases<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add custom HTML blocks to a post<\/li>\n\n\n\n<li>Store formatted snippets for templates<\/li>\n\n\n\n<li>Capture reusable markup fragments<\/li>\n\n\n\n<li>Maintain short HTML instructions<\/li>\n\n\n\n<li>Embed sanitized HTML in layouts<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"field-preview\">Field Preview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A textarea enhanced with CodeMirror in HTML mode.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-use\">How to Use<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add the HTML Field to a Field Group.<\/li>\n\n\n\n<li>Set a <strong>Placeholder<\/strong> if needed.<\/li>\n\n\n\n<li>Set <strong>Rows<\/strong> to control the visible editor height.<\/li>\n\n\n\n<li>Save the Field Group and edit a post.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"field-settings\">Field Settings<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Setting<\/th><th>Description<\/th><th>Default<\/th><\/tr><tr><td>Placeholder<\/td><td>Text shown when field is empty<\/td><td><p>Enter your HTML&#8230;<\/p><\/td><\/tr><tr><td>Rows<\/td><td>Visible height of the editor<\/td><td>8<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"value-storage\">Value &amp; Storage<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Saved as: Post meta<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Storage type: String<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Return format: string<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">REST format: not specified<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Important details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Value is sanitized with <code>wp_kses_post()<\/code> on save.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"output-examples\">Output Examples<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"php\">PHP<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">$html = get_field('my_html');\n\nif (is_string($html) &amp;&amp; $html !== '') {\n    echo wp_kses_post($html);\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"twig\">Twig<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">{% set html = fn('get_field', 'my_html') %}\n{% if html %}\n  {{ html|e('html') }}\n{% endif %}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"compatibility\">Compatibility<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Repeaters<\/li>\n\n\n\n<li>Flexible Content<\/li>\n\n\n\n<li>Options Pages<\/li>\n\n\n\n<li>Frontend forms (acf_form)<\/li>\n\n\n\n<li>REST API<\/li>\n\n\n\n<li>Multisite<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"hooks-developer\">Hooks (Developer)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"hooks-summary\">Hooks Summary<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Hook<\/th><th>Type<\/th><th>Purpose<\/th><\/tr><tr><td>custom_fields_booster_html_defaults<\/td><td>Filter<\/td><td>Modify default settings.<\/td><\/tr><tr><td>custom_fields_booster_html_supports<\/td><td>Filter<\/td><td>Modify ACF support flags.<\/td><\/tr><tr><td>custom_fields_booster_html_before_render<\/td><td>Action<\/td><td>Run logic before rendering UI.<\/td><\/tr><tr><td>custom_fields_booster_html_after_render<\/td><td>Action<\/td><td>Run logic after rendering UI.<\/td><\/tr><tr><td>custom_fields_booster_html_editor_id<\/td><td>Filter<\/td><td>Modify editor DOM ID.<\/td><\/tr><tr><td>custom_fields_booster_html_textarea_atts<\/td><td>Filter<\/td><td>Modify textarea attributes.<\/td><\/tr><tr><td>custom_fields_booster_html_before_settings<\/td><td>Action<\/td><td>Run logic before rendering settings UI.<\/td><\/tr><tr><td>custom_fields_booster_html_setting_placeholder<\/td><td>Filter<\/td><td>Modify placeholder setting config.<\/td><\/tr><tr><td>custom_fields_booster_html_setting_rows<\/td><td>Filter<\/td><td>Modify rows setting config.<\/td><\/tr><tr><td>custom_fields_booster_html_after_settings<\/td><td>Action<\/td><td>Run logic after rendering settings UI.<\/td><\/tr><tr><td>custom_fields_booster_html_before_enqueue<\/td><td>Action<\/td><td>Run logic before enqueuing assets.<\/td><\/tr><tr><td>custom_fields_booster_html_codemirror_settings<\/td><td>Filter<\/td><td>Modify CodeMirror settings.<\/td><\/tr><tr><td>custom_fields_booster_html_after_enqueue<\/td><td>Action<\/td><td>Run logic after enqueuing assets.<\/td><\/tr><tr><td>custom_fields_booster_html_load_value<\/td><td>Filter<\/td><td>Modify value after loading.<\/td><\/tr><tr><td>custom_fields_booster_html_validate_value<\/td><td>Filter<\/td><td>Modify validation result.<\/td><\/tr><tr><td>custom_fields_booster_html_update_value<\/td><td>Filter<\/td><td>Modify value before saving.<\/td><\/tr><tr><td>custom_fields_booster_html_format_value<\/td><td>Filter<\/td><td>Modify value returned by <code>get_field()<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"filters\">Filters<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Filter:<\/strong> <code>custom_fields_booster_html_codemirror_settings<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Purpose: Modify CodeMirror settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When: You want to adjust editor behavior.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter('custom_fields_booster_html_codemirror_settings', function ($settings, $field_instance) {\n    $settings['codemirror']['lineNumbers'] = false;\n    return $settings;\n}, 10, 2);\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"actions\">Actions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Action:<\/strong> <code>custom_fields_booster_html_before_render<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Runs before rendering the field UI.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_action('custom_fields_booster_html_before_render', function ($field, $field_instance) {\n    \/\/ Pre-render logic.\n}, 10, 2);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"assets\">Assets<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This field enqueues assets whenever the input is rendered (admin and frontend via <code>acf_form()<\/code>):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>admin\/js\/cfb-field-html.js<\/code><\/li>\n\n\n\n<li><code>admin\/css\/cfb-html-field.css<\/code><\/li>\n\n\n\n<li>WordPress Code Editor assets (<code>wp-theme-plugin-editor<\/code>, <code>wp-codemirror<\/code>)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rest-api\">REST API<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Schema: not specified<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rest-validation\">REST Validation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Validation uses <code>validate_value()<\/code> on REST writes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"security-escaping\">Security &amp; Escaping<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Value is sanitized with <code>wp_kses_post()<\/code> on save.<\/li>\n\n\n\n<li>Output should be escaped in templates.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"notes-limitations\">Notes \/ Limitations<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The editor runs CodeMirror in <code>text\/html<\/code> mode.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"changelog\">Changelog<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1.0.0 \u2014 Initial release<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Provides an HTML editor powered by WordPress CodeMirror. The field stores sanitized HTML as a string. Use Cases Field Preview A textarea enhanced with CodeMirror in HTML mode. How to Use Field Settings Setting Description Default Placeholder Text shown when field is empty Enter your HTML&#8230; Rows Visible height of the editor 8 Value &amp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_gspb_post_css":"","_glsr_average":0,"_glsr_ranking":0,"_glsr_reviews":0,"footnotes":""},"doc_category":[96],"doc_tag":[102],"class_list":["post-4682","docs","type-docs","status-publish","hentry","doc_category-custom-fields-booster","doc_tag-free"],"blocksy_meta":[],"year_month":"2026-06","word_count":477,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"racmanuel","author_nicename":"ra_cm","author_url":"https:\/\/racmanuel.dev\/en\/author\/ra_cm\/"},"doc_category_info":[{"term_name":"Custom Fields Booster","term_url":"https:\/\/racmanuel.dev\/en\/docs\/category\/custom-fields-booster\/"}],"doc_tag_info":[{"term_name":"Free","term_url":"https:\/\/racmanuel.dev\/en\/docs\/tag\/free\/"}],"acf":[],"_links":{"self":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/docs\/4682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/comments?post=4682"}],"version-history":[{"count":1,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/docs\/4682\/revisions"}],"predecessor-version":[{"id":4683,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/docs\/4682\/revisions\/4683"}],"wp:attachment":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media?parent=4682"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/doc_category?post=4682"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/doc_tag?post=4682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}