Support » Plugins » Hacks » Do I need to use esc_html with get_bloginfo?

  • Should I be using esc_html with get_bloginfo? For example if I’m filtering wp_title in my functions.php akin to something like this:

    # CUSTOM PAGE TITLE
    
    add_filter('wp_title', 'my_home_title');
    function my_home_title($title) {
    if (is_front_page()) {
    return esc_html((get_bloginfo( 'description' ) . ' | ' . get_bloginfo( 'name' )));
    }
    else {
    return esc_html((get_the_title() . ' | ' . get_bloginfo( 'name' )));
    }
    return $title;
    }
    
    # END CUSTOM PAGE TITLE

    Similarly would I need to use esc_url for urls that are entirely comprised of wordpress functions? Such as when using the permalink like:

    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
Viewing 1 replies (of 1 total)
  • Well did some digging around and didn’t realize

    add_theme_support( 'title-tag' );

    had been added. So I’m just going to go with that and ditch manually adding wp_title to my header.

    Still curious though about the esc_html question above in case some time in the future I do want to go ahead and filter on wp_title.

Viewing 1 replies (of 1 total)
  • The topic ‘Do I need to use esc_html with get_bloginfo?’ is closed to new replies.