• The open graph setting checkbox “Automatically add open graph meta data to site header.” can cause a problem because Woocommerce Social Media Share Buttons is not escaping the attributes. This leads to “Read More” text at the top of the website as shown here:

    https://www.hbodlak.com/work/readmore.png

    This is just one example, but not escaping the attributes can cause all kinds of problems. Your toastie_wc_smsb_social_meta has been modified below to fix this problem:

    function toastie_wc_smsb_social_meta() {
    	echo '<!-- Open Graph data -->
    		  <meta property="og:title" content="'.esc_attr( get_the_title($post->ID) ).'" />
    		  <meta property="og:type" content="website" />
    		  <meta property="og:url" content="'.esc_attr( get_permalink($post->ID) ).'" />
    		  <meta property="og:image" content="'.esc_attr( wp_get_attachment_url( get_post_thumbnail_id() ) ).'" />
    		  <meta property="og:description" content="'.esc_attr( get_the_excerpt($post->ID) ).'" />
    		  <meta property="og:site_name" content="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'"/>
    
    		  <!-- Twitter Card data -->
    		  <meta name="twitter:card" content="summary">
    		  <meta name="twitter:title" content="'.esc_attr( get_the_title($post->ID) ).'">
    		  <meta name="twitter:description" content="'.esc_attr( get_the_excerpt($post->ID) ).'">
    		  <!-- Twitter Summary card images must be at least 120x120px -->
    		  <meta name="twitter:image" content="'.esc_attr( wp_get_attachment_url( get_post_thumbnail_id() ) ).'">
    
    		  <!-- Schema.org markup for Google+ -->
    		  <meta itemprop="name" content="'.esc_attr( get_the_title($post->ID) ).'">
    		  <meta itemprop="description" content="'.esc_attr( get_the_excerpt($post->ID) ).'">
    		  <meta itemprop="image" content="'.esc_attr( wp_get_attachment_url( get_post_thumbnail_id() ) ).'">
    		  ';
    };

    As you can see, each content attribute value is now escaped with esc_attr() so the markup won’t be broken. If you have any questions, please ask.

    Tim

    https://www.ads-software.com/plugins/woocommerce-social-media-share-buttons/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding open graph meta data causes conflict due to lack of escaping attributes’ is closed to new replies.