I’m using the mingle plugin and the mingle-forum plugin.
I want to show a certain part on my site only if those two plugins are active. How can I solve this?
<?php if ( is_plugin_active('mingle-forum') ) { ?>
<div id="login"><?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?></div>
<?php } ?>
This throws a php error. Call to undefined function is_plugin_active
Any idea what I’m doing wrong?
update:
<?php if ( plugin_active('plugin-directory/mingle-forum/wpf-main.php') ) { ?>
<div id="login"><?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?></div>
<?php } ?>
This function exists in
wp-admin/includes/plugin.php
so I’m assuming it doesn’t get included by the theme.You can either
require
it, or just create your own version of it – see here: http://wordpress.org/support/topic/is_plugin_activeUPDATED:
Please check
is_plugin_active
There are two way by which you can check plugin is active or not.
not.
If plugin have class then you can check like below-
The above class related to YITH WooCommerce Compare plugin . The above code check if class exist then only you code inside the bracket will execute.
You can also try to check plugin is Active or Not
Also try below code for simplicity
You can simply use the WordPress default function. This function exists in
wp-admin/includes/plugin.php
.Simply pass the Path to the plugin file relative to the plugins directory.
For more details on
is_plugin_active
please see the below link:https://developer.wordpress.org/reference/functions/is_plugin_active/
the correct and actual way to check if a plugin is active or not is to set a
function for your code