triadazilla.blogg.se

Wordpress enqueue script on specific admin page
Wordpress enqueue script on specific admin page







wordpress enqueue script on specific admin page wordpress enqueue script on specific admin page

#Wordpress enqueue script on specific admin page code#

This code will add a top level menu item 'My Admin Page', which will display the HTML returned by the callback 'adminpagehtml'. To fix this, I have come up with a quick code, which would check all scripts and styles, and will dequeue everything that isn’t related to WordPress core admin or the plugin page itself. To enqueue scripts and styles in admin for specific pages, all you need to find the slug for that page as shown in the image below. Normally, plugins use wpenqueuescripts hook to enqueue scripts, but here we use a dynamic hook so that chart scripts are added only to plugins admin. When I'm building a plugin with an admin panel, I like to only enqueue my scripts and styles on that page. I have faced several cases, where a particular plugin would insert its own jQuery UI styling on all WordPress admin pages and it would inevitably break eForm styling. In some cases, plugins and themes may enqueue scripts and styles all over the admin area which can potentially break your own admin page. It provides a single parameter, hooksuffix, that informs the current admin page. To solve this problem ive used this in my js file: var location String(window.location). Despite the name, it is used for enqueuing both scripts and styles. Execute script only on certain admin pages. This tutorial will talk about dequeue hack to remove external plugins’ and themes’ scripts and styles from your WordPress admin page. adminenqueuescripts is the proper hook to use when enqueuing scripts and styles that are meant to be used in the administration panel. If you want to enqueue scripts & styles on a specific admin page in WordPress or if you want to enqueue scripts & styles on a theme options page in WordPress.









Wordpress enqueue script on specific admin page