• Hello,

    I’m currently developing a theme feature where you can set a default delimiter for a breadcrumb navigation through the customizer.

    That being sad, I am adding the field with this code:

    $wp_customize->add_setting(
      'breadcrumb_delimiter',
      array(
        'default' => ' ? ',
        'sanitize_callback' => 'prefix_sanitize_text',
      )
    );
    $wp_customize->add_control(
      'breadcrumb_delimiter',
      array(
        'label'         => __( 'Delimiter', 'textdomain' ),
        'section'       => 'prefix_shop',
        'type'          => 'text',
        'priority'      => 20,
        'description'   => __( 'Description', 'textdomain' ),
      )
    );

    and the sanitisation:

    function prefix_sanitize_text( $input ) {
      return wp_kses_post( force_balance_tags( $input ) );
    }

    The result is that I am getting a warning in the theme check that there are non-printable characters. Alright, so I was trying to change the character to the html code, html entity or hex code mentioned on this page.

    Changing the character to the html entity or similar removes the warning in the theme check about the non-printable character. But now there is a warning about

    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.

    Changing the sanitization callback to something like esc_html doesn’t change anything. But if I change the order of the default line and the callback line to the following, the warning is away.

    $wp_customize->add_setting(
      'breadcrumb_delimiter',
      array(
        'sanitize_callback' => 'prefix_sanitize_text',
        'default' => ' » ',
      )
    );

    How can that work? Can anyone provide a solution how I can use the Double Right-Pointing Angle Quotation Mark as the default delimiter and prevent the errors?

    I prefer understanding why the different order of default and sanitization works instead of just using this. I really appreciate every feedback.

    Best regards,
    Newb1e

    • This topic was modified 7 years, 4 months ago by Newbie.
  • The topic ‘Non-printable character in customizer’ is closed to new replies.