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 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?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- function deactivate_plugins does not exist
- Completely remove WP_Admin_Bar for specific user roles
- 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
- 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 can I change the frequency of a scheduled event?
- 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
- How can i list current author’s categories?
- Determine which theme location a wp_get_nav_menu_items is for
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- URLs of plugin resources?
- 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
- WP AJAX is not working, always returns 0
- Add notification bubble notice in navigation using transients
- Can I individually style items in the backend widget list?
- Where should I put “run once” plugin pages?
- add more custom post types and custom role to the code
- Enqueue scripts in footer
- 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
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Override class inside $atts shortcode_atts in WordPress
- Problems with: manage_${post_type}_posts_columns
- Global State During an Admin Post
- Render content after post title in wp-admin
- correct way to call javascript into hook function
- how to search users by ajax live search
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- Remove unwanted elements for a wp_nav_menu
- Is it possible to restrict all admin pages except theme customisation and storefront using plugin?
- How do I update a field of a meta box?
- How to add user details to different tables immediately after user registration
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- Issue with contextual help overwriting existing content
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- How do I link to a php file in my plugin directory?
- Function/Class to list categories with checkboxes
- WordPress Admin Login Custom Logo
- How to create custom settings page for custom plugin
- Why wp_die() doesn’t work with wp_redirect but exit() works
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Wp-admin Custom User Management
- Apply styles to blockquote element with the WYSIWYG editor
- Filter for admin (back end) ‘reply to’ comment
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Redirect in WordPress plugin
- How to add custom view links to wp-admin/post.php?
- How to output functions from plugin inside theme
- Overwriting a plugin function
- Writing editor content to a file
- How do I duplicate a single post, with all its properties, and save it as a different post?
- Adding tables to dashboard pages programmatically?
- Modify code for functions.php with specific twitter user url and hashtags
- can’t access some WordPress function from my plugin
- Custom Settings Plugin Save foreach checkboxes
- check_admin_referer()
- Customise Grouped Product display in Woocommerce with custom column
- Can someone explain what’s the use of parse request function in WordPress?
- function add custom fields to media gallery
- Override category archive page title (not the head title)
- Make visible page only in the trash
- Why would one specify multiple arguments when using get_previous_posts_link() which takes only one parameter?
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- WordPress plugin how to run function when button is clicked
- Is admin section completely customizable in terms of styling?
- Stop unauthorised file access
- Plugin dev: How to multiply instances of a plugin in the same metabox?
- WordPress permalink setting
- Issue with iframe in TinyMCE
- Dynamic banner for use on external sites
- admin page passing $_POST variables to itself
- How can i call from custom fields to the category editor?
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- modify buddpress adminbar only in admin pages
- How to change the headline title for an admin page in a plugin?
- get_term_by() returning null on plugin
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard