[wp-hackers] How to prevent multiple processing of shortcodes?

Mike Walsh mpwalsh8 at gmail.com
Mon Jul 9 14:43:14 UTC 2012


I am looking for some advice on how to prevent a shortcode from being
processed multiple times.  I am trying to help a user of my WordPress
Google Form plugin and figured out that another plugin is calling
do_shortcode() as part of the wp_head action which causes my shortcode to
be processed twice.  Because my shortcode uses the WordPress HTTP API to
submit form data to Google Forms, processing the short code twice messes
things up.  I am not sure if running do_shortcode() as part of wp_head is a
bad idea, it seems to me like it is but I am sure there is a good reason
for it.  So I am trying to update my plugin to deal with this situation.

Any recommendations or idea?  I thought about trying to use a transient to
track when wp_remote_post() is called which might work for simple forms but
since many Google Forms have more than one page, wp_remote_post() is called
more than once and in theory could be called in unknown number of times
since Google Forms support going back and forth through the pages.

Mike
-- 
Mike Walsh - mpwalsh8 at gmail.com


More information about the wp-hackers mailing list