• Hey Otto,

    Firstly, thanks for an awesome plugin!

    I’ve noticed that the method Simple Facebook Connect uses to generate Open Graph tags causes the post or page being displayed to be processed twice: once to extract the tags, and once to show to the user. This can cause conflicts with other plugins which trigger actions (such as sending an email or performing some other transaction) when their content filters or shortcodes are run. Most content filters work fine when called twice, but in some cases this causes breakage.

    Would it be possible to generate Open Graph tags after WordPress has run its normal content filters, say by registering a content filter of your own with a high priority?

    I like SFC, but the way content filters get called twice has caused me grief in the past, and it always surprises me when I get tripped up by this.

    Thanks,
    Graham

    http://wordpress.org/extend/plugins/simple-facebook-connect/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    In short, no, that method won’t work. By the time the normal content filters run, it’s too late to add stuff to the head of the page. OpenGraph content must be in the head of the page for FB to see it, and content filters normally only run when producing the content lower down in the page.

    The long version of my response to this you can find here: http://ottopress.com/2011/actions-and-filters-are-not-the-same-thing/

    Summary: Other plugins should not use filters (or shortcodes) to take actions like sending email or performing other non-repeatable transactions. Any plugin that is doing such a thing is doing-it-wrong and needs to be fixed.

    This is not an uncommon problem though, I’ve had to point out issues in plugins like this even to core developers when their plugins did it. It’s a relatively easy mistake to make. The easy fix is usually to pull whatever code is performing the action in question out of the filter function, and to put it in a function being called by the proper action hook (usually “init”) instead.

    Thread Starter Graham Stoney

    (@greyham)

    Hey Otto,

    Thanks for the quick reply. I can see what you’re saying, but it also seems inefficient to generate the content and run all the filters twice. Seems like a chick-and-egg problem. I was surprised when I first dove into the SFC code and saw all the content processing it was duplicating.

    Would it be possible to add an option to en/disable Open Graph tag generation to work around problems like this? The only feature I use in SFC is Publish and I have little control over other plugin authors. 🙁

    Thanks,
    Graham

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The “inefficiency” is minor, at best. Most all filters and shortcodes do nothing more than simple string processing. The benefits and ease-of-use outweigh the downside.

    And while you have little control over plugin authors, you do have the ability to tell them that their plugins are broken, and the ability to not use broken plugins. I suggest exercising that ability.

    BTW, SFC-Publish needs the meta to be there too. The manual publish triggers FB to crawl your site for it.

    I will not add an option to disable the meta generation, since most people don’t need it. Options are counterproductive when the vast majority of people don’t need to use them. “Decisions, not options.”

    If you want to disable it yourself (breaking a lot of functionality in the process), then you can add a remove_action call somewhere to remove the sfc_base_meta function from the wp_head hook.

    Thread Starter Graham Stoney

    (@greyham)

    I understand your reasoning; I don’t like having zillions of options either. I just want things to work. But sometimes it helps users to be able to disable certain functionality when there is a plugin conflict or duplicated functionality. I have two other plugins installed that also generate OpenGraph tags.

    Thanks for the tip. I’m not a fan of plugin-hacking, since the hack gets deleted in the next upgrade. I may have to resort to that; I’ve been playing with FacePress II for my wall updates, but it’s just not as clean as SFC Publish. 🙁

    Cheers,
    Graham

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    I have two other plugins installed that also generate OpenGraph tags.

    Betcha mine does it better. 🙂

    Just added audio support into 1.2. Video handling improvements are next, although I may have to write a whole frickin’ library to make that one work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Simple Facebook Connect] Open Graph tag generation method causing plugin conflicts’ is closed to new replies.