Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function breadcrumb_json() {
- $dom = new DOMDocument();
- $libxml_previous_state = libxml_use_internal_errors( true );
- // Populate $dom with $content, making sure to handle UTF-8.
- // Also, make sure that the doctype and HTML tags are not added to our
- // HTML fragment. http://stackoverflow.com/a/22490902/3059883
- $dom->loadHTML($html);
- // Create an instance of DOMXpath.
- $xpath = new DOMXpath( $dom );
- // Get images then loop through and add additional classes.
- $imgs = $xpath->query( "//img" );
- foreach ( $imgs as $img ) {
- $existing_class = $img->getAttribute( 'class' );
- echo $existing_class;
- }
- }
- add_action('wp_footer', 'breadcrumb_json');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement