Support » Plugins and Hacks » [Plugin: Facebook Like Thumbnail] Why is do_shortcode call as part of the wp_head action?

[Plugin: Facebook Like Thumbnail] Why is do_shortcode call as part of the wp_head action?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ashfame


    Can you give examples of possible issues?

    You are right shortcodes are processed again on the post page, but they both or infact any no of do_shortcode() calls are isolated. The only area where this could cause an issue with some other plugin will be when that plugin is using filter in place of where it should be using action.

    I have a Google Forms plugin which allows users to embed Google Forms within a post or a page using a short code. When the short code is called twice on the same page (which is happening as a result of your plugin), it causes the form to be posted incorrectly (it hasn’t been filled out yet because it hasn’t been rendered).

    I am not sure I understand your statement above about do_shortcode() being isolated. From what I observed it appears that any shortcode which appeared on a post was being processed in both the wp_head processing as well as the page processing.

    Plugin Author Ashfame


    Can you share the code so that I can take a look?

    Sure – download the plugin here. Create a sample form using Google Forms. If you don’t want to set up a Google Form , drop me an email (same as my WordPress.org username @gmail.com) and I can send you a short code that you can use for testing.

    Plugin Author Ashfame


    Emailed you!

    Plugin Author Ashfame


    Looks like it doesn’t work on a local setup. Anyways, here is what I have to say:

    I process the shortcodes so as to take in account of actual markup that is there after plugins like Nextgen have rendered their galleries. I am sure there will be cases where this needs to be done.

    Shortcode is by no means to be processed only once per page load. Its just like retrieving content with some on-the-fly modifications because we don’t want them to be permanent.

    I understand you are trying to process form submission inside a shortcode but I see two ways of doing it, which are:

    1) Don’t use the same url for submission, may be use a different endpoint. This way you only process the submission when you are on that particular URL. (Another instance – http://wordpress.stackexchange.com/questions/3902/best-practices-for-creating-and-handling-forms-with-plugins)

    2) Set a flag to process it only once. Like add a VERY UNIQUE key to the global $wpdb object indicating the form has been submitted, and only process it if that key in $wpdb object doesn’t exist yet.

    Hope that helps! And very interesting question, though I am surprised I never ran into such a thing. Happy coding 🙂

    P.S. – I have asked the Question on WPSE for more developers feedback on approach #2 – http://wordpress.stackexchange.com/questions/57548/handling-form-submissions-in-shortcodes

    Hi Ashfame, the plugin is great, but the do_shortcode() is annoying – it broke eShop – the Proceed to Paypal button disappeared because it is added with an include_once() call; it was included in the first pass and then left out on the second and last pass of do_shortcode(). Another bad side effect is that any orders I get are processed twice.

    Please change your code so that it does not call do_shortcode().


    Plugin Author Ashfame



    You should have known from the discussion above that if a plugin assumes the shortcode will be processed only once per page load, then that’s something they need to act on.

    I even have 2 possible ways of doing it in one of the post above. Have a look.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Facebook Like Thumbnail] Why is do_shortcode call as part of the wp_head action?’ is closed to new replies.