Skip to content

Commit a530e38

Browse files
AndreAngelantonitimmywil
authored andcommitted
jquery: add version support banner and version support nav link
1 parent 7711bf5 commit a530e38

File tree

6 files changed

+150
-0
lines changed

6 files changed

+150
-0
lines changed

themes/api.jquery.com/category.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* The template for displaying Category Archive pages.
4+
*/
5+
6+
get_header(); ?>
7+
8+
9+
<div class="content-right twelve columns">
10+
<div id="content">
11+
<?php if ( have_posts() ) : ?>
12+
13+
<header class="page-header">
14+
<h1 class="page-title"><?php
15+
printf( __( 'Category: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
16+
?></h1>
17+
<hr>
18+
<?php
19+
20+
$current_url = home_url(add_query_arg(null, null));
21+
22+
if (jq_is_version_deprecated($current_url)) {
23+
24+
?>
25+
26+
<div id="support-warning-box" class="warning"><svg width="20" height="20" viewBox="0 0 24 24">
27+
<circle cx="12" cy="12" r="10" fill="none" stroke="black" stroke-width="2" />
28+
<text x="50%" y="57%" dominant-baseline="middle" text-anchor="middle">i</text>
29+
</svg>&nbsp;&nbsp;This version is End-of-Life. Read more about support options&nbsp;<a href="https://jquery.com/support/">here</a>.
30+
</div>
31+
32+
<?php
33+
34+
}
35+
36+
$category_description = category_description();
37+
if ( ! empty( $category_description ) ) {
38+
echo apply_filters( 'category_archive_meta',
39+
'<div class="category-archive-meta">' . $category_description . '</div>' );
40+
}
41+
?>
42+
43+
</header>
44+
45+
<?php
46+
while ( have_posts() ) : the_post();
47+
get_template_part( 'content', 'listing' );
48+
endwhile;
49+
?>
50+
51+
<?php echo jq_content_nav(); ?>
52+
53+
<?php else : ?>
54+
55+
<article id="post-0" class="post no-results not-found">
56+
<header class="entry-header">
57+
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
58+
</header>
59+
60+
<div class="entry-content">
61+
<p><?php _e( 'Apologies, but no results were found for the requested archive.', 'twentyeleven' ); ?></p>
62+
</div>
63+
</article>
64+
65+
<?php endif; ?>
66+
</div>
67+
68+
<?php get_sidebar(); ?>
69+
</div>
70+
71+
<?php get_footer(); ?>

themes/api.jquery.com/style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@ a {
3434
margin-top: 0;
3535
padding-left: 1em;
3636
}
37+
38+
/* Support warning at top of API pages */
39+
40+
#support-warning-box {
41+
padding-top: 8px;
42+
padding-left: 8px;
43+
padding-bottom: 8px;
44+
display: flex;
45+
position: relative;
46+
z-index: 1;
47+
}

themes/jquery/css/base.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,24 @@ iframe {
881881
margin: 0;
882882
}
883883

884+
/* Support message at top of page.
885+
========================================================================== */
886+
887+
#support-message {
888+
display: flex;
889+
justify-content: center;
890+
background-color: #dddddd;
891+
padding: 4px 4px;
892+
font-size: 15px;
893+
}
894+
#support-message span {
895+
text-align: center;
896+
padding-left: 20px;
897+
padding-right: 20px;
898+
}
899+
#support-message span a {
900+
color: #222;
901+
}
884902

885903
/* Global Nav
886904
========================================================================== */

themes/jquery/functions.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,46 @@ function jq_image_posted_on() {
252252
return $classes;
253253
} );
254254

255+
/*
256+
* Determine if the current page is for a deprecated version of jQuery.
257+
* We are concened with two URL structures:
258+
* category/deprecated/deprecated-1.3/
259+
* category/version/1.9/
260+
*
261+
* @returns int True or false
262+
*/
263+
function jq_is_version_deprecated($url) {
264+
$parsedUrl = parse_url($url);
265+
$path = $parsedUrl['path'];
266+
$segments = explode('/', trim($path, '/'));
267+
268+
$versionLessThan3 = false;
269+
270+
if (count($segments) > 2) {
271+
switch (strtolower($segments[1])) {
272+
// Check first URL structure:
273+
// category/deprecated/deprecated-1.3/
274+
case 'deprecated':
275+
// Obtain the version number from the third slug.
276+
$version = floatval(substr($segments[2], 11));
277+
278+
if ($version < 3) $versionLessThan3 = true;
279+
280+
break;
281+
282+
// Check second URL structure:
283+
// category/version/1.9/
284+
case 'version':
285+
$version = floatval($segments[2]);
286+
287+
if ($version < 3) $versionLessThan3 = true;
288+
289+
break;
290+
}
291+
}
292+
return $versionLessThan3;
293+
}
294+
255295
/**
256296
* Content Security Policy
257297
*/
@@ -296,3 +336,4 @@ function jq_content_security_policy() {
296336
}
297337

298338
add_action( 'send_headers', 'jq_content_security_policy' );
339+

themes/jquery/header.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
</head>
4040
<body <?php body_class(); ?>>
4141

42+
<?php if (is_front_page()) { ?>
43+
44+
<div id="support-message" class="support-message">
45+
<span style="">jQuery 4 is currently in beta. Soon jQuery 3 will reach EOL along with versions 1 and 2. Learn more about our&nbsp;<a href="https://jquery.com/support/">Version&nbsp;Support</a>.</span>
46+
</div>
47+
48+
<?php } ?>
49+
4250
<header>
4351
<section id="global-nav">
4452
<nav>

themes/jquery/menu-header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function menu_header_jquery_com() {
1313
'https://blog.jquery.com/' => 'Blog',
1414
'https://plugins.jquery.com/' => 'Plugins',
1515
'https://jquery.com/browser-support/' => 'Browser Support',
16+
'https://jquery.com/support/' => 'Version Support',
1617
);
1718
}
1819

0 commit comments

Comments
 (0)