I'm currently trying to develop a plugin that will embed a Google Earth Tour into a WP post / page via a shortcode. The issue I am running into is that for the tour to load, I have to add an onload="init()" into the tag. I can modify a specific template file, but since this is for release, I need to add it dynamically via a hook. Any ideas?
|
|
And here's a jQuery solution (as Mike suggested in his first comment).
Then add a script to your plug-in that does this:
This will start jQuery in no conflict mode (if it isn't already) and add a call to the |
|||||||||||||
|
|
Here's an approach. You would add the the
|
|||||||
|
|
Ignoring the potential to do this with jQuery one thing you could do is hook the
Note that I would not assume the above code to be fully robust yet if I were you. I doubt it will handle all edge cases since I just threw it together to answer your question but minimally it shows you how to accomplish the normal case, and then with some use-case testing I'm sure you'' get it to handle all the important edge cases (like what if |
|||
|
|
|
Here's some JavaScript to dynamically add a callback to the page load, with or without jQuery:
In your case you would just replace the my_onload_callbacks with your init method. |
|||
|
|
|
Thanks everyone. Did some more digging and found a 'better' way to get it working (Google makes it hard to get their damn Earth Tours embedded, and their gadget doesn't work). I ended up making a plugin that uses a combination of a shortcode and a custom field. |
|||||||||
|
