Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. function breadcrumb_json() {
  2. $dom = new DOMDocument();
  3. $libxml_previous_state = libxml_use_internal_errors( true );
  4.  
  5. // Populate $dom with $content, making sure to handle UTF-8.
  6. // Also, make sure that the doctype and HTML tags are not added to our
  7. // HTML fragment. http://stackoverflow.com/a/22490902/3059883
  8. $dom->loadHTML($html);
  9. // Create an instance of DOMXpath.
  10. $xpath = new DOMXpath( $dom );
  11.  
  12. // Get images then loop through and add additional classes.
  13. $imgs = $xpath->query( "//img" );
  14. foreach ( $imgs as $img ) {
  15. $existing_class = $img->getAttribute( 'class' );
  16. echo $existing_class;
  17. }
  18. }
  19.  
  20. add_action('wp_footer', 'breadcrumb_json');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement