2012-11-18

Thesis 2.0 multisite CSS (thesis_do=css)

Note: this is a quick patch to Thesis 2.0.1, not optimized, not approved by the Thesis authors and not tested thoroughly.

Problem:

In the WPMU environment, Thesis CSS link looks like:

...?thesis_do=css&ref=...

instead of "normal" link to a .css file

Details:

The code responsible for that resides in the lib/core/skin/box.php, in class class thesis_stylesheets_link :

'url' => !is_multisite() ? THESIS_USER_SKIN_URL . '/css.css' : site_url("?thesis_do=css&ref=". THESIS_MS_CSS_VAL . time()),

Note that the time() call at the end makes this link not cacheable.

The patch:

1. In the box.php:

public function html() {
global $wpdb;
$styles = $links = array();
$styles['layout'] = array(
'url' => THESIS_USER_SKIN_URL . '/css' . (is_multisite() ? $wpdb->blogid : '') . '.css',

2. In lib/core/skin/css.php

public function write($skin, $custom) {
global $wpdb;
$css = $this->reset() . $this->update(apply_filters('thesis_css', $skin), $custom);
$css = strip_tags($css);
if (is_multisite()) {
update_option('thesis_raw_css', $css);
wp_cache_flush();
$lid = @fopen(THESIS_USER_SKIN . '/css' . $wpdb->blogid . '.css', 'w');
@fwrite($lid, trim($css));
@fclose($lid); 
}

4 comments:

  1. Thesis 2.0.2 did not change this. However, I was told that even a better solution is planned for the 2.0.3 release.

    ReplyDelete
  2. Hello you seem to be the only person talking about wordpress mu and thesis 2.0.

    I am having an issue with getting it working right on MU. When I go images under the skin editor it should images from other site vs the site I am working it. It seemed like this happened after the most recent patch to wordpress.

    Any idea on a fix?

    ReplyDelete
    Replies
    1. Hello Gera3d,
      I did not have that issue, so I cannot help you with that.
      Ask Chris at https://twitter.com/pearsonified - he is very helpful and usually answers right away.
      Thank you!

      Delete
  3. I have this problem too, though your patch didn't allow me to write to the normal css file.

    I believe that this is also the root of the problem that prevents the iPhone app from connecting to multisite blogs (if running thesis) because it creates invalid markup.

    ReplyDelete