I’m wondering, given this code:
add_shortcode( $tag , $func );
Is there a hook I can use that will always be called AFTER the last time $func
was called, but soon enough, so I can still call wp_localize_script()
?
WP Function referencres: add_shortcode, wp_localize_script
Not sure about the last time, but you can hijack every shortcode and either call
wp_localize_script()
here or register an action forwp_footer
that runs earlier than the footer script handler.Letâs say, this is the original:
Now you can overwrite it with:
Related, with a longer example: Use AJAX in shortcode
Update in response to your comment
Catching all arguments for the
gallery
shortcode is even easier:See
wp-includes/media.php
.