Admin Functions (admin.php)
wp-admin/includes/admin.php is the core loader for WordPress admin APIs. It does not define many public functions itself; instead it loads the admin-only APIs that developers use in the dashboard. This file is the primary entry point for admin functionality.
Purpose
- Ensures admin localization is loaded when included outside
wp-admin/admin.php. - Requires all admin-only API modules (comments, plugins, themes, media, files, screen, list tables, etc.).
- Initializes multisite-specific admin APIs when multisite is enabled.
Typical Usage
If you need admin APIs in a custom script (e.g., a CLI admin tool or a custom admin endpoint), you can include admin.php to load the full admin API stack:
require_once ABSPATH . 'wp-admin/includes/admin.php';
// Now admin-only functions are available:
// - Settings API (register_setting, add_settings_section, ...)
// - List tables (WP_List_Table)
// - Meta boxes (add_meta_box)
// - File uploads (wp_handle_upload, media_handle_upload)
// - Plugin/theme upgraders
// - Dashboard widgets
Note: Most plugins do not need to include this directly because WordPress admin pages already load it. Use it when running admin logic outside the normal admin request context.
What admin.php Loads
admin.php require_onces the following admin APIs:
Core Admin Modules
admin-filters.php— admin-only filters/hooksbookmark.php— links/bookmarks admin helperscomment.php— comment admin actionsfile.php— filesystem + editor helpersimage.php— image handling helpersmedia.php— media upload helpersimport.php— importer registrationmisc.php— misc admin utilitiesoptions.php— Settings API (core)plugin.php— plugin admin APIspost.php— post admin helperstaxonomy.php— taxonomy admin helperstemplate.php— admin template helperstheme.php— theme admin APIsprivacy-tools.php— privacy export/erase toolsuser.php— user admin APIsupdate.php— update checks + updater helpersdeprecated.php— admin deprecations
Screen & List Tables
class-wp-screen.php+screen.php— Screen Options and screen contextclass-wp-list-table.php+class-wp-list-table-compat.php+list-table.php— List table base and helpers
Site Icon
class-wp-site-icon.php— Site Icon helpers
Privacy List Tables
class-wp-privacy-requests-table.phpclass-wp-privacy-data-export-requests-list-table.phpclass-wp-privacy-data-removal-requests-list-table.php
Multisite Admin (when is_multisite())
ms-admin-filters.phpms.phpms-deprecated.php
Localization Handling
admin.php includes a guard for contexts where it is included directly (not via wp-admin/admin.php). In that case, it ensures the admin text domain is loaded:
if ( ! defined( 'WP_ADMIN' ) ) {
$admin_locale = get_locale();
load_textdomain( 'default', WP_LANG_DIR . '/admin-' . $admin_locale . '.mo', $admin_locale );
unset( $admin_locale );
}
This ensures admin UI strings are available even in non-standard entry points.
When to Use admin.php
✅ Use it when:
- Running admin-only functions in a custom script.
- Building an admin-only endpoint outside standard admin pages.
- Writing maintenance tasks that need admin-only APIs (upgrader, media functions, etc.).
❌ Avoid using it when:
- Already inside
wp-admin(it is loaded automatically). - In front-end requests (unless you explicitly need admin-only APIs).
Related Admin APIs
See other files in this directory for the specific APIs loaded by admin.php:
- Dashboard widgets
- List tables
- Screen options
- Meta boxes
- Admin notices
- Settings API
- File uploads
- Image editing
- Plugin/theme installation
- Update functions
- Export/import