Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added support for a "site" stylesheet

  • Loading branch information...
commit ceb430c37ad83e0d3226f7e62110fc5b4987961e 1 parent c2246e5
Aaron Collegeman authored

Showing 2 changed files with 54 additions and 0 deletions. Show diff stats Hide diff stats

  1. +53 0 frame.php
  2. +1 0  frame/parts/header.php
53 frame.php
@@ -28,6 +28,59 @@ function init() {
28 28 add_action('wp_ajax_nopriv_'.__CLASS__, array($this, 'lazyload'));
29 29 }
30 30
  31 + static function site_stylesheet($atts = '') {
  32 + $atts = (object) wp_parse_args($atts, array(
  33 + 'rel' => 'stylesheet',
  34 + 'media' => 'screen, projection',
  35 + 'version' => false
  36 + ));
  37 +
  38 + if ($uri = self::get_site_stylesheet_uri()) {
  39 + ?><link rel="<?php
  40 + echo $atts->stylesheet
  41 + ?>" href="<?php
  42 + echo $uri;
  43 + if ($version) {
  44 + echo '?'.$atts->version;
  45 + }
  46 + ?>" type="text/css" media="<?php
  47 + echo $atts->media
  48 + ?>" />
  49 + <?php
  50 + }
  51 + }
  52 +
  53 + static function get_site_stylesheet_uri() {
  54 + return self::get_site_file_uri('style.css');
  55 + }
  56 +
  57 + static function get_site_file_uri($filename) {
  58 + $domain = $_SERVER['HTTP_HOST'];
  59 + $subdomain = array_shift(explode('.', $domain));
  60 + $subfolder = array_shift(explode('/', trim($_SERVER['REQUEST_URI'], '/')));
  61 +
  62 + $locations = array();
  63 + $locations[] = "/frame/sites/{$subdomain}/{$filename}";
  64 + $locations[] = "/frame/sites/{$domain}/{$filename}";
  65 + if ($subfolder) {
  66 + $locations[] = "/frame/sites/{$subfolder}/{$filename}";
  67 + }
  68 +
  69 + $href = false;
  70 +
  71 + foreach($locations as $location) {
  72 + if (file_exists(STYLESHEETPATH . $location)) {
  73 + $href = get_stylesheet_directory_uri() . $location;
  74 + break;
  75 + } else if (file_exists(TEMPLATEPATH . $location)) {
  76 + $href = FRAME_URI . $location;
  77 + break;
  78 + }
  79 + }
  80 +
  81 + return $href;
  82 + }
  83 +
31 84 private function encode($args) {
32 85 $json = json_encode($args);
33 86 $base64 = base64_encode($json);
1  frame/parts/header.php
@@ -32,6 +32,7 @@
32 32 <!-- stylesheets -->
33 33 <link href="<?php echo FRAME_URI ?>/bootstrap/css/bootstrap.css" rel="stylesheet">
34 34 <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ) ?>">
  35 + <?php FrameTheme::site_stylesheet() ?>
35 36 <link href="<?php echo FRAME_URI ?>/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
36 37
37 38 <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->

0 comments on commit ceb430c

Please sign in to comment.
Something went wrong with that request. Please try again.