3

I have a site specific plugin that I've written for the main site in my multisite network. Now I realize that the shortcodes that are in the plugin are also useful on the sub-sites, however the sub-sites don't need all the code for custom post types and taxonomies.

How do I make just the shortcodes work for sub-sites? Is there a conditional I can use? Here's how my plugin is currently set up:

// Plugin Directory 
define( 'CLICK_DIR', dirname( __FILE__ ) );

// General
include_once( CLICK_DIR . '/lib/functions/general.php' );

// Post Types
include_once( CLICK_DIR . '/lib/functions/post-types.php' );

// Taxonomies 
include_once( CLICK_DIR . '/lib/functions/taxonomies.php' );

// Shortcodes
include_once( CLICK_DIR . '/lib/functions/shortcodes.php' );
3
if ( is_main_site() ) {
    include_once CLICK_DIR . '/lib/functions/general.php';
    include_once CLICK_DIR . '/lib/functions/post-types.php';
    include_once CLICK_DIR . '/lib/functions/taxonomies.php';
}

include_once CLICK_DIR . '/lib/functions/shortcodes.php';
3

Put the shortcodes into a separate plugin. As a rule of thumb: use one plugin per job. Do not mix unrelated functionality just because it looks easier. It isn’t.

For WordPress the number of active plugins doesn’t matter enough to care about, just what the code does. So it is better to use 20 plugins with one line of code than one plugin for 20 different small jobs.

  • 2
    Good point, I'm seriously considering that now – blogjunkie Jul 6 '12 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.