• This question is based on the advice in the Codex here:
    https://codex.www.ads-software.com/Managing_Plugins#Hiding_Plugins_When_Deactivated

    I see how to do the “IF FUNCTION EXISTS”. How do I add some kind of “ELSE IF FUNCTION DOES NOT EXIST Then Do This Other Thing Instead”?

    Here’s my example. I’m using TTF Title Plugin to replace my post headlines with graphics. I set it up with “IF FUNCTION EXISTS” like this:

    <?php if (function_exists('the_ttftitle')) {  the_ttftitle($before="", $after="", $echo=true, $style="INSERT-YOUR-TTF-STYLE-HERE"); } ?>

    I would like to make it display regular-old php the_title(), if the_ttftitle() does not exist. (If the plugin is deactivated).

    Probably something with the word “else” but I don’t know how to write it. Who can show me the code?

    Thanks Support Forum

Viewing 1 replies (of 1 total)
  • Thread Starter Dgold

    (@dgold)

    Got it! I figured it out by reading some PHP reference that came up in Google.

    Here’s the way to do the if…. else.

    This is also (in my opinion) the best way to “do” the TTF Titles plugin

    <?php if (function_exists('the_ttftitle')) { the_ttftitle($before="", $after="", $echo=true, $style="YOUR-TTF-STYLE-HERE"); } else { the_title(); }?>

    This shows the fancy-font title *if* the plugin is turned on. It shows your regular text title, if the plugin is deactivated. Seems safer, degrades cleanly.

Viewing 1 replies (of 1 total)
  • The topic ‘How to write the “else” statement for If Function Exists for deactivated plugin?’ is closed to new replies.