PressTigers

Adding JS to specific Admin Pages

Adding JavaScript code to a specific page in admin requires coding for identifying the current page and then comparing it with a condition to include code. However, there is a method available to include JS code for a specific page by hooking that particular page.

To include JS to a specific page without putting conditions in callback function, you just need to do a little modification to admin_print_script, means that you have to append by setting page name to hookname. Hook will then be written as admin_print_script-setting_page.

If you will include JS with this method, then there will be no need to put extra conditions. It will just load JS for that specific page. Below is the sample code:

User Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Get in Touch