As you may be aware, loading scripts and styles on a page where they won't be used unnecessarily slows down that page's rendering time, since the browser will still need to download and validate the content of these external files. While the previous recipe's There's More... section offered one way to select specific pages where scripts and styles should be loaded, 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.
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 (Chapter 9/ch9-pop-up-dialog/ch9-pop-up-dialog-v1.php
) from the code bundle and rename the file as ch9-pop-up-dialog.php...