Should be simple
if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(1) && function_exists(‘anyUTWfunction’) ) etc
but probably best to leave a note for users that UTW is required, else no widgets…
Bad choice of words – I should clarify – I don’t want to actually “merge” the widgets sidebar and UTW; rather, I just want to use if(function_exists to say, “If UTW is installed then use it; otherwise, just display the regular WP categories.” I only mentioned the sidebar code above because that’s the only time I’ve seen if(function_exists in WP. Sorry about the confusion. 🙂
From my example
UTW_ShowWeightedTagSetAlphabetical("coloredsizedtagcloud","","")
what is the proper function in this case? Is it UTW_ShowWeightedTagSetAlphabetical or is it something else altogether?
Aside from knowing that if(function_exists is used for the widget sidebars, I know practically nothing about it, so any and all help is appreciated. My ultimate goal is to use if(function_exists for other popular plugins as well, just to make my theme more out-of-the-box friendly.
The function you’re actually calling is the one you should be checking for. Like so:
<?php
if (function_exists('UTW_ShowWeightedTagSetAlphabetical')) {
UTW_ShowWeightedTagSetAlphabetical("coloredsizedtagcloud","","");
}
?>
function_exists does more or less exactly what you’d expect it to do. If the function you pass to it exists, then it returns true. So if you’re wanting to call function aaa(), but don’t know if that function has been declared (or that the aaa plugin is active), then you can check for it first. Like so:
if (function_exists('aaa')) {
aaa(parameters);
}
else {
// optional: no aaa, so do something else
}
More info:
http://php.net/function_exists
Excellent – thanks Otto! It seems much easier than I anticipated. I’ll post back if I run into any issues. Thanks again. 🙂