Browse files

Added support for a "site" stylesheet

  • Loading branch information...
1 parent c2246e5 commit ceb430c37ad83e0d3226f7e62110fc5b4987961e @collegeman committed Mar 27, 2012
Showing with 54 additions and 0 deletions.
  1. +53 −0 frame.php
  2. +1 −0 frame/parts/header.php
View
53 frame.php
@@ -28,6 +28,59 @@ function init() {
add_action('wp_ajax_nopriv_'.__CLASS__, array($this, 'lazyload'));
}
+ static function site_stylesheet($atts = '') {
+ $atts = (object) wp_parse_args($atts, array(
+ 'rel' => 'stylesheet',
+ 'media' => 'screen, projection',
+ 'version' => false
+ ));
+
+ if ($uri = self::get_site_stylesheet_uri()) {
+ ?><link rel="<?php
+ echo $atts->stylesheet
+ ?>" href="<?php
+ echo $uri;
+ if ($version) {
+ echo '?'.$atts->version;
+ }
+ ?>" type="text/css" media="<?php
+ echo $atts->media
+ ?>" />
+ <?php
+ }
+ }
+
+ static function get_site_stylesheet_uri() {
+ return self::get_site_file_uri('style.css');
+ }
+
+ static function get_site_file_uri($filename) {
+ $domain = $_SERVER['HTTP_HOST'];
+ $subdomain = array_shift(explode('.', $domain));
+ $subfolder = array_shift(explode('/', trim($_SERVER['REQUEST_URI'], '/')));
+
+ $locations = array();
+ $locations[] = "/frame/sites/{$subdomain}/{$filename}";
+ $locations[] = "/frame/sites/{$domain}/{$filename}";
+ if ($subfolder) {
+ $locations[] = "/frame/sites/{$subfolder}/{$filename}";
+ }
+
+ $href = false;
+
+ foreach($locations as $location) {
+ if (file_exists(STYLESHEETPATH . $location)) {
+ $href = get_stylesheet_directory_uri() . $location;
+ break;
+ } else if (file_exists(TEMPLATEPATH . $location)) {
+ $href = FRAME_URI . $location;
+ break;
+ }
+ }
+
+ return $href;
+ }
+
private function encode($args) {
$json = json_encode($args);
$base64 = base64_encode($json);
View
1 frame/parts/header.php
@@ -32,6 +32,7 @@
<!-- stylesheets -->
<link href="<?php echo FRAME_URI ?>/bootstrap/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ) ?>">
+ <?php FrameTheme::site_stylesheet() ?>
<link href="<?php echo FRAME_URI ?>/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->

0 comments on commit ceb430c

Please sign in to comment.