Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add an admin alert that reminds the user to install a certain plugin in case it is missing. I have found a way to generally add an alert box:

function addAlert() { ?>
<script type="text/javascript">
$j = jQuery;
$j().ready(function(){
$j('.wrap > h2').parent().prev().after('<div class="update-nag">This is a test alert. Do with it what you want.</div>');
});
</script>
<?php } add_action('admin_head','addAlert');

How do I only make it appear if the plugin is missing? I was thinking about something in the lines of <?php if ( function_exists('...') ) ?> but I am not too sure.

I also need a way of adding a link to the plugin and a link to dismiss the box.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

To check if a plugin is installed and activated, use the is_plugin_active() function.

Note that you need to include this function first on the front-end before you can use it:

include_once ABSPATH.'wp-admin/includes/plugin.php';

Avoid function_exists() for doing the check. Plugins may refactor their code and a previously existing function might disappear. You never know.

share|improve this answer
    
Tried this, but I keep getting the following error: Call to undefined function is_plugin_active() What could be causing this? –  charlenemasters Dec 11 '12 at 17:03
    
You need to include it first on the front-end. I'll update my answer. –  Geert Dec 11 '12 at 17:04
    
Thanks it's working! –  charlenemasters Dec 11 '12 at 17:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.