Secure Include Plugin In WordPress

Some people use more and other less Plugins in WordPress. but it is allways advisable to check via code if a Plugin is active or not. That makes sure the theme wouldn't break if the Plugin is not active. It's pretty easy to include a little bit code to check for inactivity. I show you an example where I use it in my Plugin RSSImport.

<?php if ( function_exists('FUNCTIONSNAME') ) : ?>
...
<?php endif; ?>

Example for Plugin RSSImport:
This is how the function looks like in the code of the Plugin RSSImport.

...
function RSSImport($display=0, $feedurl, $displaydescriptions=false, $truncatetitle=true) {

if ( $feedurl ) {
...
<?php if ( function_exists('RSSImport') ) : ?>
<?php RSSImport(10, "http://feeds.feedburner.com/WpEngineer", false, false); ?>
<?php endif; ?>

or a little bid smaller

<?php if ( function_exists('RSSImport') )
RSSImport(10, "http://feeds.feedburner.com/WpEngineer", false, false); ?>

Comments are closed.

3 comments

  1. Richard

    Is it possible to run more than 1 feed in a template page?

    I tried a table with 3 feeds, only 1 showed up.

  2. Frank

    @Richard: yes, you can use many feeds an your site. The link for browser and users must stay in the in the head of the theme.

One pingback

  1. 4 Fragen für Theme Autoren