WordPress.org

Support

Support » Plugins and Hacks » WP Facebook Open Graph protocol » [Resolved] [Plugin: WP Facebook Open Graph protocol] broke shortcode of other plugin

[Resolved] [Plugin: WP Facebook Open Graph protocol] broke shortcode of other plugin

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Andrew Ryno

    @andrewryno

    Hi Davidsky,

    We did add the feature to pull images from content after applying shortcodes, so we can pull more images. I just tested with NextGEN and it was working fine for me. Could you link me to a page of yours where it’s broken?

    Thanks,
    Andrew

    Hi Andrew,

    I have done a roolback to 1.6.1 and everything now works fine.

    eg.:

    PARKWAY DRIVE: le foto del concerto all’Alcatraz di Milano

    this page works fine with 2.0 but if you click any of the gallery in the page the gallery doesn’t show anything: http://metalitalia.com/galleria_fotografica/parkway-drive-le-foto-del-concerto-allalcatraz-di-milano/?album=41&gallery=165

    Best Regards,
    Dave

    Hi,
    I have the same problem with WP Survey And Quiz Tool. It works with a Shortcode in an article and the quiz just isn´t showing until i deactivate the WP Open graph Protocol Plugin. There is only an empty <p></p> tag in the sourcecode.

    Plugin Contributor Andrew Ryno

    @andrewryno

    Hello,

    Just pushed 2.0.2 that fixes this issue (along with bugs that affected other plugins using shortcode). Marking this as resolved but if you are still running into problems, let me know.

    Thanks,
    Andrew

    Hello Andrew,

    It works! Thank you for the quick fix.

    Hi,

    now works 🙂

    Thanks

    Bye D.

    Andrew, I had a question about this comment in the thread:

    “We did add the feature to pull images from content after applying shortcodes, so we can pull more images.”

    I’m writing a plugin that renders an image from a shortcode, but that’s not getting pulled into an og:image tag.

    When I threw in debug code in “wpfbogp_find_images()” to inspect “$post->post_content”, the content at that point still had my shortcode in it and not the rendered html with the image tag my shortcode generates.

    It could very well be possible something I’m doing wrong in my plugin, and I’m continuing to investigate that. But in the meantime, I was wondering if there was anything else beside that find images method I would want to check here?

    Thanks in advance,
    – Kris

    Another finding here, if it helps.

    Not sure if this is a valid test, but I added an echo statement to the wpfbogp_find_images() method and the same in the method my plugin’s shortcode uses, each to output an html comment.

    When looking at the page source when it’s rendered, the debug html comments I added to the wpfbogp method are displayed higher on the page then the one my shortcode method uses.

    My assumption here is that echo statements in plugins will be rendered in the output of the page when that line of code is executed, and not rendered within the context of the shortcode, etc., so if that’s assumption is wrong, then ignore this test.

    Okay, one last comment and then I’m moving onto something else for awhile…

    I looked through the revisions of this plugin and found this code in 2.0.1 that was removed in 2.0.2:

    // function to call first uploaded image in content
    	function wpfbogp_find_images() {
    	        global $post, $posts;
    
    	        // Grab filtered content (so all shorttags are fired) and match first image
    	        $content = apply_filters( 'the_content', $post->post_content );

    In no way an expert here, but I suspect the plugins that were breaking in 2.0.1 were because their plugins were adding filters for ‘the_content’ and when you called it in this plugin, it fired for them at the wrong time, etc.

    My plugin doesn’t add a filter for ‘the_content’, so I don’t know if that means I have to add one somehow or give up using a shortcode altogether. The OP says this code in 2.0.1 broke his plugin, he didn’t say whether or not your FB plugin would sucessfully pick up his images for og:image tags (which is my problem).

    In my situation here – depending if I’m in the minority of users here – I can try to get away with using a page template rather than a plugin, so if that works and I’m the only one missing out on images rendered by shortcodes, I try to change things on my end instead.

    Plugin Contributor Andrew Ryno

    @andrewryno

    For shortcodes, we did remove that bit of code that runs apply_filters() on the_content. What that did was filter all the shortcodes in the_content that you add via add_shortcode() and the rest of the shortcode API. The problem was that this caused more problems than it solved, so we removed it. I would like to add it back in eventually but it will take a lot of testing to get it working properly. It’s a little difficult to do, especially when we have to buffer the output so drastically (to account for SEO plugins that do it, too).

    You can try using that piece of code from 2.0.1 and customize the plugin and check to see if it works.

    Thanks Andrew.

    I ended up moving away from the plugin/shortcode and instead moved the code into the functions.php file and made this a page template instead, thinking it would help.

    But still no luck, $post->post_content was empty (no content from my page template code) by the time it was executed. My template code did also use the ‘the_content’ filter, so that’s probably why.

    I only needed this for a single page on my site, so I ended up hacking the following into the 2.0.4 version of the plugin:

    $content = $post->post_content;
    if (strlen($content) == 0 && $post->ID == 272) {
    $content = apply_filters( ‘the_content’, $post->post_content );
    }

    Hardcoding the page ID and only executing this if there is no existing in the page using this template (in my case) protected this from being executed elsewhere. I might have looked an checking the page template (possible?) instead of the page id, but it was too late at night when I coded this.

    Thanks for the reply.

    This is still the best plugin I’ve used for open graph support, and I appreciate you guys putting this together and maintaining active support here at the forums.

    All the best,
    – Kris

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] [Plugin: WP Facebook Open Graph protocol] broke shortcode of other plugin’ is closed to new replies.
Skip to toolbar