Skip to content

Commit ccea1de

Browse files
committed
Eliminate the $tlsite global and move the site classes from the html to the body element.
1 parent 4a2df97 commit ccea1de

File tree

17 files changed

+37
-63
lines changed

17 files changed

+37
-63
lines changed

mu-plugins/jquery-filters.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ function jquery_unfiltered_html_for_term_descriptions() {
6262

6363
// Add body classes found in postmeta.
6464
add_filter( 'body_class', function( $classes ) {
65-
if ( ! is_singular() )
66-
return $classes;
65+
$sites = jquery_sites();
66+
if ( isset( $sites[ JQUERY_LIVE_SITE ]['body_class'] ) )
67+
array_unshift( $classes, $sites[ JQUERY_LIVE_SITE ]['body_class'] );
68+
if ( 0 === strpos( JQUERY_LIVE_SITE, 'api.' ) )
69+
array_unshift( $classes, 'api' );
70+
6771
if ( is_page() )
6872
$classes[] = 'page-slug-' . sanitize_html_class( strtolower( get_queried_object()->post_name ) );
69-
if ( $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) )
73+
if ( is_singular() && $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) )
7074
$classes = array_merge( $classes, explode( ' ', $post_classes ) );
7175
return $classes;
7276
});

sites.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function jquery_sites() {
99
'jquery.com' => array(
1010
'blog_id' => 1,
1111
'cookie_domain' => '.jquery.com',
12+
'body_class' => 'jquery',
1213
'options' => array(
1314
'blogname' => 'jQuery',
1415
'stylesheet' => 'jquery.com',
@@ -20,6 +21,7 @@ function jquery_sites() {
2021
'blog.jquery.com' => array(
2122
'blog_id' => 2,
2223
'cookie_domain' => '.jquery.com',
24+
'body_class' => 'jquery',
2325
'options' => array(
2426
'blogname' => 'jQuery Blog',
2527
'stylesheet' => 'blog-jquery-com',
@@ -29,6 +31,7 @@ function jquery_sites() {
2931
'api.jquery.com' => array(
3032
'blog_id' => 3,
3133
'cookie_domain' => '.jquery.com',
34+
'body_class' => 'jquery',
3235
'options' => array(
3336
'blogname' => 'jQuery API Documentation',
3437
'stylesheet' => 'api.jquery.com',
@@ -37,6 +40,7 @@ function jquery_sites() {
3740
'plugins.jquery.com' => array(
3841
'blog_id' => 4,
3942
'cookie_domain' => '.jquery.com',
43+
'body_class' => 'jquery',
4044
'options' => array(
4145
'blogname' => 'jQuery Plugins',
4246
'stylesheet' => 'plugins.jquery.com',
@@ -45,6 +49,7 @@ function jquery_sites() {
4549
'learn.jquery.com' => array(
4650
'blog_id' => 5,
4751
'cookie_domain' => '.jquery.com',
52+
'body_class' => 'jquery-learning',
4853
'options' => array(
4954
'blogname' => 'Learn jQuery',
5055
'stylesheet' => 'learn.jquery.com',
@@ -53,6 +58,7 @@ function jquery_sites() {
5358
'jqueryui.com' => array(
5459
'blog_id' => 6,
5560
'cookie_domain' => '.jqueryui.com',
61+
'body_class' => 'jquery-ui',
5662
'options' => array(
5763
'blogname' => 'jQuery UI',
5864
'stylesheet' => 'jqueryui.com',
@@ -64,6 +70,7 @@ function jquery_sites() {
6470
'blog.jqueryui.com' => array(
6571
'blog_id' => 7,
6672
'cookie_domain' => '.jqueryui.com',
73+
'body_class' => 'jquery-ui',
6774
'options' => array(
6875
'blogname' => 'jQuery UI Blog',
6976
'stylesheet' => 'blog.jqueryui.com',
@@ -73,6 +80,7 @@ function jquery_sites() {
7380
'subsites' => 1, // Has one level of sub-sites (api.jqueryui.com/([^/]+))
7481
'blog_id' => 8,
7582
'cookie_domain' => '.jqueryui.com',
83+
'body_class' => 'jquery-ui',
7684
'options' => array(
7785
'blogname' => 'jQuery UI API Documentation',
7886
'stylesheet' => 'api.jqueryui.com',
@@ -84,6 +92,7 @@ function jquery_sites() {
8492
'api.jqueryui.com/1.8' => array(
8593
'blog_id' => 17,
8694
'cookie_domain' => '.jqueryui.com',
95+
'body_class' => 'jquery-ui',
8796
'options' => array(
8897
'blogname' => 'jQuery UI 1.8 Documentation',
8998
'stylesheet' => 'api.jqueryui.com',
@@ -95,6 +104,7 @@ function jquery_sites() {
95104
'jquery.org' => array(
96105
'blog_id' => 9,
97106
'cookie_domain' => '.jquery.org',
107+
'body_class' => 'jquery-project',
98108
'options' => array(
99109
'blogname' => 'jQuery Foundation',
100110
'stylesheet' => 'jquery.org',
@@ -106,6 +116,7 @@ function jquery_sites() {
106116
'qunitjs.com' => array(
107117
'blog_id' => 10,
108118
'cookie_domain' => '.qunitjs.com',
119+
'body_class' => 'qunitjs',
109120
'options' => array(
110121
'blogname' => 'QUnit',
111122
'stylesheet' => 'qunitjs.com',
@@ -117,6 +128,7 @@ function jquery_sites() {
117128
'sizzlejs.com' => array(
118129
'blog_id' => 11,
119130
'cookie_domain' => '.sizzlejs.com',
131+
'body_class' => 'sizzlejs',
120132
'options' => array(
121133
'blogname' => 'Sizzle JS',
122134
'stylesheet' => 'sizzlejs.com',
@@ -128,6 +140,7 @@ function jquery_sites() {
128140
'jquerymobile.com' => array(
129141
'blog_id' => 12,
130142
'cookie_domain' => '.jquerymobile.com',
143+
'body_class' => 'jquery-mobile',
131144
'options' => array(
132145
'blogname' => 'jQuery Mobile',
133146
'stylesheet' => 'jquerymobile.com',
@@ -139,6 +152,7 @@ function jquery_sites() {
139152
'api.jquerymobile.com' => array(
140153
'blog_id' => 13,
141154
'cookie_domain' => '.jquerymobile.com',
155+
'body_class' => 'jquery-mobile',
142156
'options' => array(
143157
'blogname' => 'jQuery Mobile API Documentation',
144158
'stylesheet' => 'api.jquerymobile.com',
@@ -147,6 +161,7 @@ function jquery_sites() {
147161
'api.qunitjs.com' => array(
148162
'blog_id' => 14,
149163
'cookie_domain' => '.qunitjs.com',
164+
'body_class' => 'qunitjs',
150165
'options' => array(
151166
'blogname' => 'QUnit API Documentation',
152167
'stylesheet' => 'api.qunitjs.com',
@@ -155,6 +170,7 @@ function jquery_sites() {
155170
'books.jquery.com' => array(
156171
'blog_id' => 15,
157172
'cookie_domain' => '.jquery.com',
173+
'body_class' => 'jquery',
158174
'options' => array(
159175
'blogname' => 'jQuery Books',
160176
'stylesheet' => 'books.jquery.com',
@@ -163,6 +179,7 @@ function jquery_sites() {
163179
'events.jquery.org' => array(
164180
'blog_id' => 16,
165181
'cookie_domain' => '.jquery.org',
182+
'body_class' => 'jquery-events',
166183
'options' => array(
167184
'blogname' => 'jQuery Events',
168185
'stylesheet' => 'events.jquery.org',

themes/api.jquerymobile.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/api.jquerymobile.com/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: api-jquerymobile-com
33
Template: jquery
44
*/
55

6-
html.jquery-mobile, #container { background: #598611 url(../jquery/i/bg-body-mobile.jpg) no-repeat center -30px; }
6+
body.jquery-mobile, #container { background: #598611 url(../jquery/i/bg-body-mobile.jpg) no-repeat center -30px; }
77

88
h1.site-title a {
99
background: url(../jquery/i/logo-mobile.png) no-repeat;

themes/api.jqueryui.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/api.jqueryui.com/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: api-jqueryui-com
33
Template: jquery
44
*/
55

6-
html.jquery-ui, #container {
6+
body.jquery-ui, #container {
77
background: #BB6F04 url(../jquery/i/bg-body-ui.jpg) no-repeat center -20px;
88
}
99

themes/api.qunitjs.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/jquery.org/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/jquery/css/base.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ a:hover {
10251025
/* jQuery Core */
10261026
/*******************************************************************************/
10271027

1028-
html.jquery, .jquery #container { background: #065791 url(../i/bg-body-jquery.jpg) no-repeat center -20px; }
1028+
body.jquery, .jquery #container { background: #065791 url(../i/bg-body-jquery.jpg) no-repeat center -20px; }
10291029

10301030
.jquery h1.site-title a {
10311031
height: 72px;
@@ -1055,7 +1055,7 @@ html.jquery, .jquery #container { background: #065791 url(../i/bg-body-jquery.jp
10551055
/* jQuery Project */
10561056
/*******************************************************************************/
10571057

1058-
html.jquery-project { background: #cab57e url(../i/bg-body-jquery-project.jpg) no-repeat center -30px; }
1058+
body.jquery-project { background: #cab57e url(../i/bg-body-jquery-project.jpg) no-repeat center -30px; }
10591059

10601060
.jquery-project h1.site-title a {
10611061
background: url(../i/logo-project.png) no-repeat;
@@ -1071,7 +1071,7 @@ html.jquery-project { background: #cab57e url(../i/bg-body-jquery-project.jpg) n
10711071

10721072
/* ===[ Sizzle ]=== */
10731073

1074-
html.sizzlejs, .sizzlejs #container { background: #8c0000 url(../i/bg-body-sizzlejs.jpg) no-repeat center -20px; }
1074+
body.sizzlejs, .sizzlejs #container { background: #8c0000 url(../i/bg-body-sizzlejs.jpg) no-repeat center -20px; }
10751075

10761076
.sizzlejs h1.site-title a {
10771077
background: url(../i/logo-sizzlejs.png) no-repeat;
@@ -1097,7 +1097,7 @@ html.sizzlejs, .sizzlejs #container { background: #8c0000 url(../i/bg-body-sizzl
10971097

10981098
/* ===[ QUnit ]=== */
10991099

1100-
html.qunitjs, .qunitjs #container { background: #00733c url(../i/bg-body-qunitjs.jpg) no-repeat center -20px; }
1100+
body.qunitjs, .qunitjs #container { background: #00733c url(../i/bg-body-qunitjs.jpg) no-repeat center -20px; }
11011101

11021102
.qunitjs h1.site-title a {
11031103
background: url(../i/logo-qunitjs.png) no-repeat;
@@ -2324,7 +2324,7 @@ nav .searchform .icon-search {
23242324
/* Learning Site */
23252325
/*******************************************************************************/
23262326

2327-
html.jquery-learning { background: #000 url(../i/learning_bg.jpg) no-repeat center 0; }
2327+
body.jquery-learning { background: #000 url(../i/learning_bg.jpg) no-repeat center 0; }
23282328

23292329
.jquery-learning h1.site-title a {
23302330
background: url(../i/logo-learning.png) no-repeat;

themes/jquery/header.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
<?php
22
global $sidebar;
33
$sidebar = "sidebar-left";
4-
$site = str_replace(".", "-", str_replace("https://", "", str_replace("http://", "", home_url())));
5-
6-
global $tlsite;
7-
if (!isset($tlsite)) {
8-
$tlsite = "jquery";
9-
}
10-
11-
$site = str_replace(array("dev-", "stage-"), "", $site);
12-
if ( strpos($site, "api-") !== false ) {
13-
$site .= " api";
14-
}
154
?>
165
<!DOCTYPE html>
17-
<!--[if lt IE 7 ]> <html class="no-js ie ie6 lte6 lte7 lte8 lte9 <?php echo $site . " " . $tlsite; ?>" <?php language_attributes(); ?>> <![endif]-->
18-
<!--[if IE 7 ]> <html class="no-js ie ie7 lte7 lte8 lte9 <?php echo $site . " " . $tlsite; ?>" <?php language_attributes(); ?>> <![endif]-->
19-
<!--[if IE 8 ]> <html class="no-js ie ie8 lte8 lte9 <?php echo $site . " " . $tlsite; ?>" <?php language_attributes(); ?>> <![endif]-->
20-
<!--[if IE 9 ]> <html class="no-js ie ie9 lte9 <?php echo $site . " " . $tlsite; ?>" <?php language_attributes(); ?>> <![endif]-->
21-
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js <?php echo $site . " " . $tlsite; ?>" <?php language_attributes(); ?>> <!--<![endif]-->
6+
<!--[if IE 7 ]> <html class="no-js ie ie7 lte7 lte8 lte9" <?php language_attributes(); ?>> <![endif]-->
7+
<!--[if IE 8 ]> <html class="no-js ie ie8 lte8 lte9" <?php language_attributes(); ?>> <![endif]-->
8+
<!--[if IE 9 ]> <html class="no-js ie ie9 lte9>" <?php language_attributes(); ?>> <![endif]-->
9+
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
2210
<head>
2311

2412
<meta charset="utf-8">

themes/jquerymobile.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/jquerymobile.com/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: jquerymobile-com
33
Template: jquery
44
*/
55

6-
html.jquery-mobile, #container { background: #598611 url(../jquery/i/bg-body-mobile.jpg) no-repeat center -30px; }
6+
body.jquery-mobile, #container { background: #598611 url(../jquery/i/bg-body-mobile.jpg) no-repeat center -30px; }
77

88
h1.site-title a {
99
background: url(../jquery/i/logo-mobile.png) no-repeat;

themes/jqueryui.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/jqueryui.com/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: jqueryui-com
33
Template: jquery
44
*/
55

6-
html.jquery-ui, #container {
6+
body.jquery-ui, #container {
77
background: #BB6F04 url(../jquery/i/bg-body-ui.jpg) no-repeat center -20px;
88
}
99

themes/learn.jquery.com/functions.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
22

3-
global $tlsite;
4-
$tlsite = "jquery-learning";
5-
63
function is_subpage() {
74
global $post; // load details about this page
85

themes/qunitjs.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

themes/sizzlejs.com/functions.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)