I wrote a plugin that enqueues a script and stylesheet only on a specific admin page. It works in my dev environment and multiple production servers; however, was introduced recently to a site that is utilizing the plugin and it will not render the script or stylesheet tag to the page. Here is the code:
add_action( 'admin_enqueue_scripts', 'gf_notification_attachment_attach_script');
// actual function to enqueue
function gf_notification_attachment_attach_script(){
global $gf_notification_attachment;
$plugin = $gf_notification_attachment;
if( GFForms::get_page() == 'notification_edit'){
$script = $plugin->plugin_url . 'script';
$script .= ( WP_DEBUG ) ? '.js' : '.min.js';
wp_enqueue_script( $plugin->text_domain, $script, array('gform_gravityforms'), $plugin->version, true );
wp_enqueue_style( $plugin->text_domain, $plugin->plugin_url . 'style.css', array(), $plugin->version );
}
}
I have inserted debug code to echo $script
within the conditional in the function and it lists the path correctly. I also have dumped the global $wp_scripts
var to the screen after calling the enqueue and see it listed correctly along with all the other scripts in the list.
As a bit of further testing I confirmed the only 2 plugins active were Gravity Forms and my plugin (which is dependent on GF). I also activated the default 2014 theme. I also removed the dependance on the Gravity Forms (conditional check for admin page) and tried and it still will not render the script tag.
I'm at a loss here as to what could be causing it to not show on this one site. Even wp_enqueue_script
works within other plugins. Any ideas? If you wish to test the plugin and have "Gravity Forms" you can download and test the full code base yourself.