• Home
  • Cloud
    • General
    • SaaS
    • BPaaS
    • PaaS
    • IaaS
    • Other Internet Hosted Applications
      • WordPress
        • WooThemes Canvas
          • WooThemes Canvas CSS
  • About me
  • Why Badly Wired?
  • Contact

Badly Wired

Connecting WordPress via APIs, Plugins and other stuff - a technical notebook

You are here: Home / Genesis / Genesis breadcrumbs markup issues

Genesis breadcrumbs markup issues

15th January 2015 by Alan Leave a Comment

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

In certain circumstances, permitted markup for page titles breaks the Genesis breadcrumbs.

In this example  the <sup> tag is being used in parent page title.

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

2015-01-15_1342

This is because Genesis’ breadcrumbs uses esc_html  ( genesis/lib/classes/breadcrumbs.php ) in most cases (note that it doesn’t in all cases as the far right is rendering correctly )

One solution would be to remove the esc_html from the core genesis file, but that would of course create problems when you upgrade.

This particular problem (parent page) is solved by removing the esc_html on line 758 changing

$link = sprintf( '<a href="%s"%s>%s</a>', esc_attr( $url ), $title, esc_html( $content ) );

to

$link = sprintf( '<a href="%s"%s>%s</a>', esc_attr( $url ), $title,  $content );

But this isn’t a great way to go about it, changing core files in Genesis

esc_html is filtered, which means you can change the behavior by adding a filter to your functions.php

( you can see the code for esc_html here https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/formatting.php )

If you add the following code esc_html is modified across your whole site, so I can’t take any responsibility, its up to you to test and make sure your site works fine and is secure.

The code essentially replaces the call to  _wp_specialchars( $safe_text, ENT_QUOTES ); to a call to wp_kses, allowing in this example the <sup> tag ( http://codex.wordpress.org/Function_Reference/wp_kses )

// filter to allow <sup> tag through esc_html
add_filter('esc_html', 'bw_esc_html',10,2);
function bw_esc_html($val, $text, $content = null)
    {
       $text = wp_check_invalid_utf8( $text );
       return wp_kses($text, array ( 'sup' => array()));
    }

 

 

The end result

2015-01-15_1356

end note: in my screenshots the <sup> tag isn’t doing anything, that is simply because mytest theme hasn’t styled it with any css

Addendum:

I raised this with StudioPress and they provided two alternative workarounds, so there are plenty of ways to solve this

We’ve been tracking this issue in our system and may resolve it in a future update.

For now, another workaround you are welcome to use that filters Genesis breadcrumb links only and not esc_html throughout WordPress is this:

 

add_filter( 'genesis_breadcrumb_link', 'sp_html_crumbs', 10, 4 );
function sp_html_crumbs( $link, $url, $title, $content ) {
	$link = sprintf( '<a href="%s"%s>%s</a>', esc_attr( $url ), $title,
$content ); 	return $link;
}

 

If you prefer, you can also solve the issue without writing code by installing the WordPress SEO plugin and activating breadcrumbs under SEO > Internal Links. This works because WordPress SEO doesn’t escape HTML in breadcrumb links by default like Genesis does. (That may change in the future, though.)

[Next] Find out where to host WordPress [Read the full article…]

Filed Under: Genesis, Wordpress  

About Alan

I'm Alan from Fullworks Digital Ltd, where I develop WordPress Plugins and support and manage WordPress websites.

My day job consists of solving clients' WordPress issues and developing new code and solutions.

I started as a professional programmer in 1979 and had been involved with the IT of business technology in virtually every area that exist.

Badlywired.com is my personal blog and my aide memoire of the many interesting facts that I come across. As I spend a lot of time gathering parts of solutions from the internet and assembling them into my own solutions, and also just learning how to do things, this blog is primarily my 'note book' and a way of giving something back to the online community that has helped me extensively.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Applications
  • Cloud
    • General
    • Google Cloud
    • IaaS
    • Other Internet Hosted Applications
      • Wordpress
        • WooThemes Canvas
        • WooThemes Canvas CSS
    • SaaS
  • Code snippets
  • Discounts
  • Genesis
  • Google Apps for Works
  • Linux
  • News
  • SEO
  • Server setup
  • Services
  • Tech Tips
  • Uncategorised
  • Useful Images
  • Useful Stuff
  • WordPress Hosting
  • WordPress Plugins

Tags

background jobs beadcrumbs bind brandings Cache canvas Centos chrome css fail2ban Find firefox Flash fraud genesis gocardless godaddy Google google maps hackers internet explorer javascript KashFlow Linus linux Magento mapquest maps microsoft mysql news nohup php plugin plugins queens diamond jubilee replace SED SEO skype Varnish Virtualmin Webmin woothemes Wordpress

 

Affiliate and Privacy Notices

This site is free to use, but hopes to cover some costs through affiliate income, some products and links are affiliates and may earn the site advertising income.

Some affiliates use Cookies to track if you purchase from them, this allows them to apportion revenue to us you will need to refer to their specific privacy notices as to how you are tracked.

This site is a participant in the Amazon EU Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.co.uk.

  • Privacy Policy

Copyright © 2021 · Badly Wired