When you register a plugin option page you get a hook from the registration function:
$hook = add_menu_page(
'T5 Demo', // page title
'T5 Demo', // menu title
'manage_options', // capability
't5-demo', // menu slug
'my_render_page' // callback function
);
Use this hook to enqueue the scripts and styles:
add_action( "admin_print_styles-$hook", "my_enqueue_style" );
add_action( "admin_print_scripts-$hook", "my_enqueue_script" );
See my plugin T5 Admin Menu Demo for an example.
Do not define a constant PLUGIN_URL
. You will run into collisions with other code.
Related Posts:
- What are the standard admin CSS id/class tags?
- WordPress admin stylesheet
- This CSS Stuffing Works, But Is This A Good Practice?
- How do I load a CSS style into WordPress admin area only?
- How can I target WordPress 3.8 new interface MP6 with CSS?
- How to fix admin stylesheet muck-up? [closed]
- Custom CSS In Admin Only For Certain Roles
- Modify CSS via Theme Control Panel
- Why are my styles being applied to the admin area?
- Adding another “Add Post” button to admin
- How can I load an inline script after the enqueued scripts in admin?
- Correct check for any admin page with editor
- Enqueue and Dequeue from admin bar nodes
- admin_enqueue_scripts the same css file as wp_enqueue_style
- Fixed layout for admin section
- WordPress admin toolbar not loading styles after migration
- Black admin bar is being hidden by page elements
- WordPress Admin Thickbox: Remove Margins/Padding
- How to remove entire admin menu?
- The website cannot display the page
- Set Default Admin Colour For All Users
- WP List Table custom quick edit box – post meta data missing and columns change on submit
- Is there a more efficient admin search function/plugin?
- WordPress Admins or Roles per Page
- How to add filter in “Comments” at the admin panel?
- Using require_once() within admin
- List All Post Types in Admin view using /wp-admin/edit.php?post_type=
- Integrate post tags in Post Edit page with qTranslate
- Add a custom column in users list page
- Change post title during post saving process
- How to display only logged in user’s post comments in comments area
- WordPress 3.8 get current admin color scheme
- Custom taxonomy admin description
- Can you have the users list pre sorted by specific column?
- Different color admin bars for dev, staging and production
- WordPress manage users as non admin
- remove_action with profile_personal_options
- With WP 3.4 customizer, while using postMessage & working within your JS for one option, can you retrieve current value for another option?
- Refreshing collections in the admin media manager
- $user_id vs. is_user_logged_in()
- Conditionally load CSS/JS/PHP in wp-admin if using a mobile device
- Assuming a theme is properly secured, how save is the WordPress admin?
- Is there a way to hook into the update-core page for custom messages?
- How to solve 500 Error on WordPress Admin Dashboard due to time-out on getdirsize
- Enabling users to replace site title (text) with a image logo (but keeping the text if there isn’t any image)?
- WordPress How to begin editing from admin page (please see picture)
- Add stylesheets and js to template files when shortcode is used
- WordPress as a web app – always auto-save post and meta data
- Determining whether it’s a AJAX call from front-end or from back-end
- Is it possible to edit the styling of the admin panel from within a custom theme?
- Disable the “Skip to Toolbar” tabbing accessibility feature
- Custom Thickbox Broken on Dashboard Page?
- Super slow admin panel
- My WordPress Admin looks messed up when I edit posts or pages
- Save author posts as in pending review – block users updating their posts
- POMO_Reader->substr() call endless loop?
- jQuery UI AutoComplete & wp_enqueue_script
- Plugin admin panel JavaScript Broken
- Force Contributors to add Tags via edit-tags.php
- Edit Auto Update Admin Notification
- Unable to Access WP Admin or Login buttons after Migration
- How to enqueue admin content outside admincp
- get_current_screen and the WP_Screen class
- How to find a spam link?
- Is there alternative to WP_List_Table?
- How to change all “Post” texts in dahboard into “Article”?
- Filter WooCommerce Orders
- How to disable Media Library uploads for non-Admin users?
- Page can’t hand request – HTTP ERROR 500 – when updating something
- How to change the User name and Password of admin account
- Redirect public site to another one but allow administrators to access the old site
- How to change widget’s form color in admin?
- Posts in sidebar only by admin
- Display an image of selected template in admin to aid user when using complex templates
- How to remove the default checked attribute from inputs in admin?
- Passing state from child component to parent component in a Gutenberg Sidebar
- I can’t enter the control panel of my wordpress site after channing the URL to https://
- Admin user column sort by numeric meta key
- Shop in Subdomain feeding main domain order in admin area
- Can I retrieve Published changes when changes have been Saved but not Published in WordPress Semplice?
- I can’t access login page
- Admin Access for specific page(s)
- Get Link of Page Selected through a Select Field in Custom Admin Page
- how to disable the e-mail verification on wp-admin/options-general.php multisite admin e-mail
- WordPress Admin Email
- conditionally update css on edit.php
- Simple CSS admin pagination
- Can I show the tag admin interface on a post when logged in as an admin?
- Editing post in admin panel
- Making a custom upload form and page in the admin section
- Customise the add media pop-up to include rel attribute option
- WordPress gallery image link gives 404 when not logged in
- Custom Div with links on Admin Bar
- Remove “minor-publishing” div from Publish admin metabox
- New User Notification – Setting Email
- Can’t access my wp admin: captcha images invisible, gives me error message
- Pull Random Images From Options Page [closed]
- You do not have permission to access this document on form submit
- Woo Commerce Settings for Check-out Form [closed]
- What Role to assign remote site developer?