[wp-hackers] What is the best method to check a theme's dependencies on plugins?

Bjorn Wijers burobjorn at gmail.com
Fri Nov 27 13:57:50 UTC 2009

Hi there,

I'm working on a theme which is going to be used in conjunction with a
lot of plugins. So naturally I want to make sure these plugins are all
active and ready for my theme to use, but I'm not sure about the best
way to approach this. Oh, and I need to install this theme on a blog
part of a WP MU install. As far as I can see I have two options:

1) Use this solution posted in 2005:

2) Or do something like this in the functions.php of my theme, which at
the moment does not seem to work (any hints on why it's not working

 * Checks if certain plugins are active before this theme can be used.
 * This function is called by the switch_theme() Wordpress action.
 * @access private
 * @param string Theme name
 * @return string theme name or stop and display an error message
if( ! function_exists('_bbtheme_check_dependencies') ) {
  function _bbtheme_check_dependencies($theme_name) {

    // return theme name directly if not using our theme
    if( $theme_name !== 'bbtheme' ) { return $theme_name; }

    // are plugins we need active and available?
    if( ! is_active_plugin('register-plus/register-plus.php') ) {
        die (__('Register Plus not active', $bbtheme_txt_domain) );
    } else if( ! is_active_plugin('userphoto/userphoto.php') ) {
        die (__('User Photo plugin not active.', $bbtheme_txt_domain) );

// upon theme activation check dependencies
add_action('switch_theme', '_bbtheme_check_dependencies');


Thanks in advance,

met vriendelijke groet,
Bjorn Wijers

* b u r o b j o r n .nl *
digitaal vakmanschap | digital craftsmanship

Concordiastraat 68-126
3551 EM Utrecht
The Netherlands

phone: +31 6 49 74 78 70

More information about the wp-hackers mailing list