{"id":9201212,"date":"2017-06-06T11:05:57","date_gmt":"2017-06-06T11:05:57","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/sanitize-callback-fallback\/"},"modified":"2017-06-06T11:11:16","modified_gmt":"2017-06-06T11:11:16","slug":"sanitize-callback-fallback","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/sanitize-callback-fallback\/","title":{"rendered":"Sanitize Callback fallback"},"content":{"rendered":"<p>I am using the WP customizer to allow users to customise the html class of a certain element. As required, I have added the sanitize callback to sanitize user input. I would like the user to be able to set it to either a valid html class or an empty string. However, if an empty string is entered, wordpress will fail to save the customization. How can I set the $fallback value in such a case?<\/p>\n<p>$wp_customize-&gt;add_setting( &#8216;voce_social_icon_1&#8217; , array(&#8216;default&#8217;   =&gt; &#8216;fa-facebook&#8217;, &#8216;sanitize_callback&#8217; =&gt; &#8216;sanitize_html_class&#8217;,));<\/p>\n<p>I am only having such problems with &#8216;sanitize_html_class&#8217;, &#8216;esc_url_raw&#8217; happily accepts an empty string.<\/p>\n","protected":false},"template":"","class_list":["post-9201212","topic","type-topic","status-publish","hentry","topic-tag-html-class"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9201212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9201212\/revisions"}],"predecessor-version":[{"id":9201230,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9201212\/revisions\/9201230"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9201212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}