Controlling pop-up dialog display using shortcodes
As you may be aware, loading scripts and styles on a page where they won't be used unnecessarily slows down that page's loading time. This happens since the browser still needs to download, validate, and execute the content of these external files. The previous recipe's There's more... section offered one technique to select specific pages where scripts and styles should be loaded. However, a different approach is to analyze the page contents for the presence of a special code to make that decision.
This recipe shows how to add a filter to the previous recipe to search for a shortcode in posts and pages to decide when to display a pop-up dialog.
Getting ready
You should have already followed the Displaying a pop-up dialog using the built-in ThickBox plugin recipe to have a starting point for this recipe. Alternatively, you can get the resulting code (ch9/ch9-pop-up-dialog/ch9-pop-up-dialog-v1.php
) from...