Title: Before upgrading, wrap your plugins
Last modified: August 18, 2016

---

# Before upgrading, wrap your plugins

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/)
 * If you have plugin functions in your theme, there is the risk that when you upgrade
   and something goes wrong, that plugin code will throw you an error.
 * So if the plugin says to use this:
    `<?php wp_grins(); ?>`
 * Then you need to alter that to be like this:
    `<?php if (function_exists('wp_grins'))
   wp_grins(); ?>`
 * That way, if no plugin, no error from the theme.

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/page/2/?output_format=md)

 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-284923)
 * Good advice…. and in fact I started doing that on all themes I was using or developing
   about 3 months back. It’s a little bit of extra code, but worth it!
 *  Thread Starter [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285574)
 * I just remembered what a very good idea this was 🙂
 *  [chaaban](https://wordpress.org/support/users/chaaban/)
 * (@chaaban)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285575)
 * Should we also make this in a plugin it self ?
 * <?php if (!function_exists(‘wp_grins’)) wp_grins(); ?>
 * // adding the negation !
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285576)
 * no, adding the negation is erroneous — if the function doesn’t exist, you can’t(
   and shouldn’t) call it… 😉
 *  [chaaban](https://wordpress.org/support/users/chaaban/)
 * (@chaaban)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285577)
 * sorry i meant 2 make definition if it dont exist …
 * if (! function_exists(“my_function”))
    { function my_function () { } }
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285578)
 * I was waiting for someone to say something. If there isn’t a tree in the woods,
   does it make a sound when it falls? 😉
 *  Thread Starter [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285579)
 * Yes – you just said it wasn’t in the woods 🙂
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285580)
 * Yep and the function still works in other programs, but it doesn’t make a sound
   in WP if it doesn’t exist there ;-). The analogy I was going for (and guess didn’t
   get):
    Tree = function woods = WP make a sound = work falls = is called
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285581)
 * Um…. so what am I supposed to wrap my plugins with now? I am NOT the brightest
   light in the universe upon many occasions, this being the current one….
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285582)
 * Don’t wrap the plugins, just wrap the function calls in case the plugin is not
   activated. If the plugin is not activated the function will not exist and you
   will get a fatal error and bring down your site unless the call is wrapped with
   the test for its existence.
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285583)
 * Beel…. pretend I’m an idiot (well, okay, you don’t HAVE to pretend….)
 * If we are talking about themeswitcher for instance, exactly what is the “new”
   version of the call I should be using in the sidebar – the whole thing, please
   and thank you….
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285584)
 * I was just copying something from my index page…
 * I have plugins which replace regular WP tags. Instead of replacing the tags. 
   I do something like:
    `<`p id=”prev_next_links”> <?php if (!function_exists(‘
   wp_pagenavi’)) posts_nav_link(‘ | ‘, __(‘« Previous Page’), __(‘Next Page »’));
   echo ““; ?>
 * <?php if (function_exists(‘wp_pagenavi’)) wp_pagenavi(); ?>
    `<`/p>
 * That way, if my plugin is not activated, WP’s regular tag will be used.
 * And here is what I have for theme-switcher…
    <?php if (function_exists(“wp_theme_switcher”)){?
   > `<`li>Themes <?php wp_theme_switcher(‘dropdown’); ?> `<`/li> <?php } ?>
 * It is a little different from many because I also wrap the li’s – no since in
   having an empty line in my list if theme-switcher is deactivated. Get it?
 *  [chaaban](https://wordpress.org/support/users/chaaban/)
 * (@chaaban)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285585)
 * <?php if (function_exists(‘wp_theme_switcher’)) { ?>
    <h2><?php _e(‘Themes:’);?
   ></h2> <?php wp_theme_switcher(); ?>
 * <?php } ?>
 *  [chaaban](https://wordpress.org/support/users/chaaban/)
 * (@chaaban)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285586)
 * did i just mess arround wordpress posts ?
 * this is what i tought there is something wrong in wordpress strip tag issue
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/#post-285587)
 * So now it needs both the “normal” (as posted by podz in the first post above,
   and as I’m currently using) and the one with the “!”?
 * Okay, I get what you mean about wrapping the li tags – makes sense, I’ll redo
   some stuff…. but what is it with the “!”?

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/page/2/?output_format=md)

The topic ‘Before upgrading, wrap your plugins’ is closed to new replies.

## Tags

 * [upgrade](https://wordpress.org/support/topic-tag/upgrade/)

 * In: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
 * 27 replies
 * 7 participants
 * Last reply from: [electrolund](https://wordpress.org/support/users/electrolund/)
 * Last activity: [20 years, 2 months ago](https://wordpress.org/support/topic/before-upgrading-wrap-your-plugins/page/2/#post-285698)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
