You can use the is_admin function. By definition, it checks “Whether the current request is for an administrative interface page.”
You might also want to verify you are not doing an AJAX call by doing
if ( ! is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
# code here...
}
Related Posts:
- Problems with removing admin bar
- Remove Permalink Meta Box not working?
- I cant add is_admin control to plugin
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- function deactivate_plugins does not exist
- Export data as CSV in back end with proper HTTP headers
- Completely remove WP_Admin_Bar for specific user roles
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Understanding WordPress functions’ naming conventions
- API to trigger prompt on leaving page
- Using OOP plugin’s methods throughout the website
- Show message on wordpress admin dashboard
- Hook the Keydown Event in the TinyMCE Post Editor
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- how to use thickbox in admin?
- How do you create a custom edit.php / edit pages page
- Cancel post save
- Add a jQuery function to admin pages
- function triggered by “manage_users_custom_column” filter not working
- How can I change the frequency of a scheduled event?
- WordPress plugin how to run function when button is clicked
- Is it save to require plugin.php early to be able to use get_plugin_data() earlier?
- When is it appropriate to put functions on page template vs. functions.php?
- WP Cron doesn’t save or in post body
- Shortcodes, output buffering, and WordPress functions
- Create a clickable name in WP_List_Table for Plugin Admin
- How can i list current author’s categories?
- Determine which theme location a wp_get_nav_menu_items is for
- When to check if a function exists
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- Checking for existence of a page by title?
- URLs of plugin resources?
- Dynamically Override Fancy Title
- Problem with `wp_mail()`
- Calling a function from functions.php in custom page/ blog post
- What is the Difference between directly call a function and call a function using add_action?
- How to add custom content under plugin row in WordPress admin plugin list?
- Call to undefined function get_blog_option()
- How to put placeholder text in the main post input area?
- What is the difference between current_page_parent and current_page_ancestor?
- Plugin development: is adding empty index.php files necessary?
- Undefined function wp_set_password
- Does add_filter work outside functions.php
- What function to hook for changes made in status and visibility of a post
- How to load the plugin only when logged in?
- how to use preg_replace for wordpress video?
- How to redirect to action on custom page within admin section
- Plugin Uninstall and Deactivate via Options Menu
- How can I add a CSS rule to edit.php?
- WP AJAX is not working, always returns 0
- wp_enqueue_script + wp_enqueue_style Since When
- Add notification bubble notice in navigation using transients
- Can I individually style items in the backend widget list?
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- Widget update function not saving values
- add a class when login
- Add a panel to edit post
- Where should I put “run once” plugin pages?
- add more custom post types and custom role to the code
- $content variable – Is this a reserved variable for a WordPress function? – php / wordpress
- Using the default wordpress uploader inside plugin
- How to use WP_Term with (menu) argument in the wp_nav_menu?
- WordPress after content Hook & external template part
- Enqueue scripts in footer
- override pluggable.php functions
- Modify users.php page to create page/post on button clicked
- Retrieve contents/page names of various pages for use in a plugin
- Can wp_list_comments output into variable?
- is user logged in not working
- Issue plugin commands in admin settings page
- Can I change header.php of current theme through a plugin function?
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- maintaing consistent layout wordpress dashboard
- Replacing Scripts in Admin Load_Scripts
- get_current_screen() return null
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Override class inside $atts shortcode_atts in WordPress
- creating custom function to log actions in plugin
- Problems with: manage_${post_type}_posts_columns
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Global State During an Admin Post
- Maximum lifetime for nonce
- Where can i find wordpress auto update code flows?
- Render content after post title in wp-admin
- Adding option to Gallery shortcode
- correct way to call javascript into hook function
- On cliking add new post redirect user to a custom page first
- How to change the hover content of a specific menu item on WordPress?
- how to search users by ajax live search
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Prevent third party plugin’s admin page access based on user type
- How to add WordPress Admin “Insert Link” UI (searches through existing posts for URL) and functionality into a custom plugin?