• There is a problem with a required setting with the wordpress theme check plugin, this is the error that i get:

    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.

    Im not able to find anything related to sanitize a logo upload, the only things i can find is to sanitize integers and other settings but not image uploads,

    this is what i have in functions.php

    function themeslug_theme_customizer( $wp_customize ) {
    	// create a new section for our logo upload
        $wp_customize->add_section( 'themeslug_logo_section' , array(
        'title'       => __( 'Logo', 'themeslug' ),
        'priority'    => 30,
        'description' => 'Upload a logo to replace the default site name and description in the header',
    ) );
        //  register our new setting
        $wp_customize->add_setting( 'themeslug_logo' );
    
        // tell the Theme Customizer to let us use an image uploader for setting our logo
        $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo',
        array(
        'label'    => __( 'Logo', 'themeslug' ),
        'section'  => 'themeslug_logo_section',
        'settings' => 'themeslug_logo',) ) );
    }
    add_action('customize_register', 'themeslug_theme_customizer');
Viewing 2 replies - 16 through 17 (of 17 total)
  • @aaron Beverly, after I added your code to the Theme Check plugin it returns the following error:

    E:\xampp\htdocs\ys_magazine/wp-content/themes/ys-magazine\functions.php: ‘first_category’ ) E:\xampp\htdocs\ys_magazine/wp-content/themes/ys-magazine\functions.php: ‘second_category’ ) E:\xampp\htdocs\ys_magazine/wp-content/themes/ys-magazine\functions.php: ‘third_category’ ) E:\xampp\htdocs\ys_magazine/wp-content/themes/ys-magazine\functions.php: ‘fourth_category’ )

    Do you have any idea what I have to do? Thanks!

    This works for me:

    // Customize Logo instead of Text
    function themeslug_theme_customizer( $wp_customize ) {
        $wp_customize->add_section( 'themeslug_logo_section' , array(
            'title'       => __( 'Logo', 'themeslug' ),
            'priority'    => 30,
            'description' => 'Upload a logo to replace the default site name and description in the header',
        ) );
    
        $wp_customize->add_setting( 'themeslug_logo',
            'sanitize_callback' == 'esc_url_raw'
        );
    
        $wp_customize->add_control('themeslug_logo',
            array( 'default' => '',
                'sanitize_callback' => 'esc_url_raw',
                'type' => 'theme_mod',
            ));
    
        $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
            'label'    => __( 'Logo', 'themeslug' ),
            'section'  => 'themeslug_logo_section',
            'settings' => 'themeslug_logo',
            'sanitize_callback' => 'esc_url_raw',
        ) ) );
    }
    add_action( 'customize_register', 'themeslug_theme_customizer' );
Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Theme customizer sanitization’ is closed to new replies.