Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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' );
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted
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';
share|improve this answer
add comment

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.

share|improve this answer
2  
Good point, I'm seriously considering that now –  blogjunkie Jul 6 '12 at 14:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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