-1

I'm using a plugin and a bit of PHP code in the theme of my WP blog to put ads where I want them. This is an example of the code:

<?php echo adrotate_ad(4); ?>

Not too complicated but...

When the plugin is deactivated, this of course, returns a warning when trying to load the page.

I'm guessing I need a conditional statement that says if adrotate_ad(4) is not there then ignore the command?

edited:

So, trying to piece it together, would it be something like this?

<? 
if (function_exists('adrotate_ad(4)')) {
echo adrotate_ad(4);
} else {

} 
?>

What would be after "else"?

edited:

OK, I figured it out! Thanks for the help. Now, I'd just like to know if this is the best way for me to return nothing if the plugin is disabled:

<? 
if (function_exists('adrotate_ad')) {
echo adrotate_ad(4);
} else {
print "";
} 
?>

This produces the results I want but I don't know if it's proper.

1 Answers1

0

function_exists() is what you need.

halfer
  • 19,824
  • 17
  • 99
  • 186
QQping
  • 1,370
  • 1
  • 13
  • 26