thumb Some time ago WordPress.org is changed the rules of the publication of a themes to their repository. And then, I have not been able to publish update of my theme, because of the following error:

REQUIRED: Found a Customizer setting that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed.

To localize the problem I used the plugin “Theme Check”. After installation plugins page will be located at WordPress DashbordAppearanceTheme Check. That plugin doesn’t show more information than at wordpress.org when you publish an update of theme. But we can modify it, so let’s start.

If the “Theme Check” plugin is not yet installed then do this.

Then modify customizer.php file which is located at plugins/theme-check/checks/. You can modify it directly out of your WordPress Dashbord. For this go to WordPress DashbordPluginsEditor and select Theme Check plugin.

Now, in the file customizer.php, add this:

echo "$file_path: $match ";

After this section of code:

if ( false === strpos( $match, 'sanitize_callback' ) && false === strpos( $match, 'sanitize_js_callback' ) ) {
$this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . __( 'Found a Customizer setting that did not have a sanitization callback function. Every call to the <strong>add_setting()</strong> method needs to have a sanitization callback function passed.', 'theme-check' );

Done. This should indicate the file and fragment of code that causing the error. In my case, it show this string:

/var/www/site/wp-content/themes/anarcho-notepad/inc/customizer.php: 'copyright_post', array( 'default' => 'Copyright ©

This string mean that code which causing the error is this:

'copyright_post', array( 'default' => 'Copyright ©

and it located in the file customizer.php. So I need to find this code in that file. There is:

// Copyright after post
$wp_customize->add_setting( 'copyright_post', array(
	'default'			=> 'Copyright &copy; 2014. All rights reserved.',
	'sanitize_callback'	=> 'esc_attr',
));

How you see the sanitize callback function is there. The cause was in the special character “©” in the value of the key “default”.

&copy ; = Copyright = © = (c)

Now I must replace the special character &copy ; to text version (c) or just remove it.


Arthur Gareginyan

Arthur Gareginyan

Arthur is a designer and full stack software engineer. He is the founder of MyCyberUniverse.com. His personal website can be found at arthurgareginyan.com. Check out his free WordPress plugins at wordpress.org.

Follow Arthur: