jQuery on all admin pages
-
Hey there,
I was developing a new plugin for a client; when I noticed my admin styles were not appearing properly on the admin page I created.
Upon further investigation… I found your jQuery styles are being enqueued on all admin pages.
Specifically, it originates from this block:
function addHeaderCode() { wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-tabs'); if (@!class_exists('AGCA')) { wp_enqueue_script('wpscstniceditor', plugins_url('/js/nicedit/nicEdit.js', __FILE__), array('jquery'), '1.3.2'); } wp_enqueue_style('plugin_name-admin-ui-css', plugins_url('/css/custom-theme/jquery-ui-1.10.3.custom.css', __FILE__), false, 2, false); }Which references back to this block of code:
add_action("admin_print_scripts-$newTicketPage", array(&$wpscSupportTickets, 'addHeaderCode')); add_action("admin_print_scripts-$editPage", array(&$wpscSupportTickets, 'addHeaderCode')); if(@function_exists('wpscSupportTicketDepartments')) { // For wpsc Support Tickets v5.0+ add_action("admin_print_scripts-$departmentsPage", array(&$wpscSupportTickets, 'addHeaderCode')); } add_action("admin_print_scripts-$statsPage", array(&$wpscSupportTickets, $statsHeaderCode)); add_action("admin_print_scripts-$settingsPage", array(&$wpscSupportTickets, 'addHeaderCode')); add_action("admin_print_scripts-$fieldsPage", array(&$wpscSupportTickets, 'addFieldsHeaderCode'));I do see where you are attempting to run the scripts only on the needed pages… but your approach is apparently not working properly.
I think instead of doing it like this:
add_action("admin_print_scripts-$newTicketPage", array(&$wpscSupportTickets, 'addHeaderCode'));… it would work if you did it like this:
add_action("admin_print_scripts-".$newTicketPage, array(&$wpscSupportTickets, 'addHeaderCode'));You’ve done everything perfectly when adding the menu and submenu pages (by setting them to a variable). I think if you changed the code as mentioned above; it would make everything work exactly as you intended.
Thanks for looking into this.
The topic ‘jQuery on all admin pages’ is closed to new replies.