WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: WP Facebook Open Graph protocol] Auto description includes shortcodes (12 posts)

  1. benz001
    Member
    Posted 2 years ago #

    Hi Chuck, I know there's no notification system per plugin but I hope this one catches your eye!

    One big issue with the auto generation of descriptions is that you don't filter out shortcodes.

    So for example, if you ever start a blog post with an image with a caption you'll pass the raw shortcode tags straight to facebook in the og:description field.

    Adding an excerpt of course will work around it, but if you install this plugin on an existing blog that has lots of posts without excerpts it's incredibly dangerous.

  2. benz001
    Member
    Posted 2 years ago #

    So the quick fix is something like:

    echo "\t<meta property='og:description' content='".esc_attr(substr(strip_tags(strip_shortcodes($post->post_content)), 0, 160))."' />\n";//BGE added strip_shortcodes

    I've not tested that thoroughly yet however.

  3. Chuck Reynolds
    Member
    Posted 2 years ago #

    k I'll look into it. just super busy w/ client work. I'll do what I can as soon as I can.. thx man. :)

  4. Chuck Reynolds
    Member
    Posted 2 years ago #

    fixed in 1.4 beta. standby.

  5. Chuck Reynolds
    Member
    Posted 2 years ago #

    fixed in 1.3.5 bug fix push. waiting for repo refresh then update :)

  6. benz001
    Member
    Posted 2 years ago #

    Wow - awesome stuff!

    I've also been looking at the og:image code, basically I'm not using the extension as is because as soon as you give facebook an og:image it stops scraping the page for images, meaning that people can no longer pick an image to share other than the first in the post - and for a blog post with multiple images in it that really sucks.

    There is some discussion on stackoverflow that if you supply multiple og:image tags facebook will index all of them, last time I tried this on another platform (6+ months back) it didn't seem to work, but the facebook linter didn't flush the facebook cache back then so testing was a nightmare.

    However it does now and it would be easy to iterate through the images array from that regex and put all the images as og:image tags.

    Would you consider putting the code in Github so I can fork it? Much better than me just hacking my copy and leaving no trace of what's been tried for the rest of the community :-)

  7. B_Dark
    Member
    Posted 2 years ago #

    I use the 1.3.5 version and if I have added in the beginning of the text a short code (example:[blackbirdpie id="tweet code"]) it shows it in the description of the "like" and I don't want it to show it. How can I fix this?

  8. Chuck Reynolds
    Member
    Posted 2 years ago #

    @B_Dark - Fix by adding an excerpt for that content. If you don't have one, only then will it pull the first 160 char of the content. If your content only has the shortcode then maybe introduce a short couple sentences of what that page is about. Looks like you're displaying tweets so maybe write a header or description for the on page content.

    @benz001 - I do have the dev code on github: https://github.com/rynoweb/WPFBOGP
    In regards to FB and multiples images... ....SO... IF Facebook was at all reliable I would consider doing that and having multple... however... FB or the OGP protocol don't have any mention of that functionality... and the fact that FB is NEVER consistant on if/when they do that or how they pull images from a page... I just can't worry about it yet.
    If building this plugin has taught me anything about Facebook dev's it is that they're unorganized and never write good docs. Case in point the og:type and what additional og: response codes they want with different types... they now started throwing warnings on the no og:locale stuff... which I'm about to add in but have to figure out how to pull that from the general settings timezone and correlate that to a locale. Just little shit like that.
    That seems to be a good convo over at S.O. so I'll check it out and probably get involved.

    Feel free to pull and request adds for the plugin. I'm not an awesome php dev so any help is always appreciated :)

  9. benz001
    Member
    Posted 2 years ago #

    Thanks for the git link and I hear you on the FB issues!

    There is an (almost) duplicate post on SO that states that the FB documentation explicitly allows multiple og:image tags, but I've never been able to find the spot in the FB documentation that says that myself - I've always found their docs an absolute nightmare too and validating that they really do what the docs seem to say is even worse....

  10. Chuck Reynolds
    Member
    Posted 2 years ago #

    yup. this seems closed now :)

  11. B_Dark
    Member
    Posted 2 years ago #

    @Chuck Reynolds: Thanks :)

  12. Chuck Reynolds
    Member
    Posted 2 years ago #

    bothers me I can't close this topic... grr :/

Topic Closed

This topic has been closed to new replies.

About this Topic