Title: Multisite compatibility
Last modified: August 20, 2016

---

# Multisite compatibility

 *  Resolved [Doug Yuen](https://wordpress.org/support/users/doug-yuen/)
 * (@doug-yuen)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/)
 * Great plugin! Can you make it multisite-compatible? Two ideas that come to mind
   are to either append the site ID to the name of the file created, so multiple
   CSS files can be created/used, or make the .css file disabled when it’s on a 
   multisite install. I am using an older version of your plugin on my multisite
   installs, and it works like a charm, but I can’t upgrade because the file would
   make the same CSS apply to all sites. It would be great if you could add this
   fix.
 * By the way, I just gave you a 5-star review, not that it should influence your
   priorities 🙂
 * Thanks!
 * [http://wordpress.org/extend/plugins/my-custom-css/](http://wordpress.org/extend/plugins/my-custom-css/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Anonymous User 357386
 * (@anonymized-357386)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571331)
 * Sorry, i never tested on multisite… I can try to install a multisite installation
   in my localmachine and search a fix for it 😉
    – Thanks for report (and also 
   for your rating) 🙂
 *  Thread Starter [Doug Yuen](https://wordpress.org/support/users/doug-yuen/)
 * (@doug-yuen)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571398)
 * Thanks for the quick response!
 * After thinking about it again, the easiest thing would probably be to use a conditional
   so that if it’s a multisite installation, ignore getting the CSS from the file
   and just get it from the options table. Messing around with files and site IDs
   is probably prone to error. I think the Prose theme by StudioPress used to be
   set up that way (with site IDs) but the latest version just stores the CSS in
   the database. There’s probably a good reason why they switched.
 * Just my thoughts.
 *  Anonymous User 357386
 * (@anonymized-357386)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571400)
 * I’ve problem to setup multisite in my local machine… but my idea is this:
 *     ```
       function css_path()
       {
       	if (is_multisite())
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style_id-".get_current_site()->id.".css";
       	}
       	else
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style.css";
       	}
       	return $css_path;
       }
   
       function css_url()
       {
       	if (is_multisite())
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style_id-".get_current_site()->id.".css";
       	}
       	else
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style.css";
       	}
       	return $css_url;
       }
       ```
   
 *  Anonymous User 357386
 * (@anonymized-357386)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571403)
 * Edit: i think is best like this (to maintain id 1 without id in url), but ATM
   i can’t test:
 *     ```
       function css_path()
       {
       	if (is_multisite() && get_current_site()->id > "1")
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style_id-".get_current_site()->id.".css";
       	}
       	else
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style.css";
       	}
       	return $css_path;
       }
   
       function css_url()
       {
       	if (is_multisite() && get_current_site()->id > "1")
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style_id-".get_current_site()->id.".css";
       	}
       	else
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style.css";
       	}
       	return $css_url;
       }
       ```
   
 *  Anonymous User 357386
 * (@anonymized-357386)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571416)
 * Edit… ok, i’ve fixed…
    This is a valid code (tested in my local machine):
 *     ```
       function css_path()
       {
       	global $blog_id;
       	if (is_multisite() && ($blog_id > "1"))
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style_id-".$blog_id.".css";
       	}
       	else
       	{
       		$css_path = plugin_dir_path(__FILE__)."my_style.css";
       	}
       	return $css_path;
       }
   
       function css_url()
       {
       	global $blog_id;
       	if (is_multisite() && ($blog_id > "1"))
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style_id-".$blog_id.".css";
       	}
       	else
       	{
       		$css_url = plugin_dir_url(__FILE__)."my_style.css";
       	}
       	return $css_url;
       }
       ```
   
 *  Anonymous User 357386
 * (@anonymized-357386)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571439)
 * Fixed with a best control:
 *     ```
       function css_path()
       {
       	global $blog_id; $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
       	$css_path = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
       	return $css_path;
       }
   
       function css_url()
       {
       	global $blog_id; $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
       	$css_url = plugin_dir_url(__FILE__)."my_style".$cssid.".css";
       	return $css_url;
       }
       ```
   
 * I’ve tested more…
    Seems to work perfect 😉
 *  Thread Starter [Doug Yuen](https://wordpress.org/support/users/doug-yuen/)
 * (@doug-yuen)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571536)
 * Finally got around to testing the upgrade, and it works perfectly. Thanks for
   the compatibility fix, and for such a quick response!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Multisite compatibility’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/my-custom-css_5e56b8.svg)
 * [My Custom CSS PHP & ADS](https://wordpress.org/plugins/my-custom-css/)
 * [Support Threads](https://wordpress.org/support/plugin/my-custom-css/)
 * [Active Topics](https://wordpress.org/support/plugin/my-custom-css/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-custom-css/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-custom-css/reviews/)

## Tags

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

 * 7 replies
 * 2 participants
 * Last reply from: [Doug Yuen](https://wordpress.org/support/users/doug-yuen/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/multisite-compatibility-7/#post-3571536)
 * Status: resolved