is_plugin_active() WP 2.5.0
Determines whether a plugin is active. Works in the dashboard only. Conditional tag.
The function is located in wp-admin/includes/plugin.php, so it only works in the dashboard. Use it on admin_init action or later.
For the function to work on the front you need to connect the file:
require_once ABSPATH . 'wp-admin/includes/plugin.php';
1 time = 0.000043s = very fast | 50000 times = 0.63s = very fast | PHP 7.0.14, WP 4.7
No Hooks.
Return
true/false. True, if in the active plugins list. False, not in the list.
Usage
is_plugin_active( $plugin );
- $plugin(string) (required)
- Path to the plugin file relative to the plugins directory.
Examples
#1 In the dashboard, check if the plugin is activated
/** * Check if the plugin is in the active plugins list. */ if ( is_plugin_active( 'plugin-directory/plugin-file.php' ) ) { echo 'Plugin is active'; } else { echo 'Plugin is not active'; }
#2 Check if the plugin is active not in the dashboard (on front-end).
/** * Check if the plugin is in the active plugins list from front-page. */ include_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'plugin-directory/plugin-file.php' ) ) { echo 'Plugin is active' }
Changelog
Since 2.5.0 | Introduced. |
Code of is_plugin_active() is plugin active WP 5.6
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}Related Functions
From tag: plugin
More from tag: Conditional tags (all)
- cat_is_ancestor_of()
- comments_open()
- email_exists()
- has_category()
- has_custom_header()
- has_excerpt()
- has_nav_menu()
- has_post_thumbnail()
- has_shortcode()
- has_tag()
- has_term()
- have_comments()
- have_posts()
- in_category()
- in_the_loop()
- is_404()
- is_active_sidebar()
- is_admin()
- is_admin_bar_showing()
- is_archive()
- is_attachment()
- is_author()
- is_blog_admin()
- is_blog_installed()
- is_category()
- is_child_theme()
- is_comment_feed()
- is_customize_preview()
- is_date()
- is_day()
- is_dynamic_sidebar()
- is_embed()
- is_feed()
- is_front_page()
- is_header_video_active()
- is_home()
- is_local_attachment()
- is_main_query()
- is_month()
- is_multi_author()
- is_multisite()
- is_nav_menu()
- is_network_admin()
- is_new_day()
- is_page()
- is_page_template()
- is_paged()
- is_post_type_archive()
- is_post_type_hierarchical()
- is_preview()
- is_robots()
- is_search()
- is_single()
- is_singular()
- is_ssl()
- is_sticky()
- is_tag()
- is_tax()
- is_taxonomy_hierarchical()
- is_textdomain_loaded()
- is_time()
- is_trackback()
- is_user_admin()
- is_user_logged_in()
- is_year()
- pings_open()
- post_exists()
- post_password_required()
- shortcode_exists()
- taxonomy_exists()
- term_exists()
- term_is_ancestor_of()
- wp_attachment_is()
- wp_attachment_is_image()
- wp_doing_ajax()
- wp_doing_cron()
- wp_is_mobile()
- wp_is_post_autosave()
- wp_is_post_revision()
- wp_script_is()