When you want inject something into the WordPress admin, you might not think to account for pages that load inside lightboxes (plugin updates, media upload, etc.). Generally, you don’t want to add your JS/CSS/etc. to these pages.
To check for this type of page load, you can check for the IFRAME_REQUEST constant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Standard WP Admin Page Check | |
| Description: Example code. | |
| Version: 1.0 | |
| Author: Alex King | |
| Author URI: http://alexking.org | |
| */ | |
| function ak_wp_admin_standard_page_test() { | |
| ?> | |
| <script type="text/javascript"> | |
| alert('This is a standard WP admin page.'); | |
| </script> | |
| <?php | |
| } | |
| if ( !defined( 'IFRAME_REQUEST' ) ) { | |
| add_action( 'admin_head', 'ak_wp_admin_standard_page_test' ); | |
| } | |
| ?> |
[…] shared some code snippets for Custom Post Types you might find handy.Alex King posted a tip on detecting lightboxed pages in the WordPress Admin.That brings us to the end of this edition of WordPress Community Links. If […]