Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HeroDevs support. #467

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions themes/api.jquery.com/category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* The template for displaying Category Archive pages.
*/

get_header(); ?>


<div class="content-right twelve columns">
<div id="content">
<?php if ( have_posts() ) : ?>

<header class="page-header">
<h1 class="page-title"><?php
printf( __( 'Category: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>
<hr>
<?php

$current_url = home_url(add_query_arg(null, null));

if (jq_is_version_deprecated($current_url)) {

?>

<div id="support-warning-box" class="warning"><svg width="20" height="20" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10" fill="none" stroke="black" stroke-width="2" />
<text x="50%" y="57%" dominant-baseline="middle" text-anchor="middle">i</text>
</svg>&nbsp;&nbsp;This version is End-of-Life. Read more about support options&nbsp;<a href="https://jquery.com/support/">here</a>.
</div>

<?php

}

$category_description = category_description();
if ( ! empty( $category_description ) ) {
echo apply_filters( 'category_archive_meta',
'<div class="category-archive-meta">' . $category_description . '</div>' );
}
?>

</header>

<?php
while ( have_posts() ) : the_post();
get_template_part( 'content', 'listing' );
endwhile;
?>

<?php echo jq_content_nav(); ?>

<?php else : ?>

<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header>

<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive.', 'twentyeleven' ); ?></p>
</div>
</article>

<?php endif; ?>
</div>

<?php get_sidebar(); ?>
</div>

<?php get_footer(); ?>
11 changes: 11 additions & 0 deletions themes/api.jquery.com/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ a {
margin-top: 0;
padding-left: 1em;
}

/* Support warning at top of API pages */

#support-warning-box {
padding-top: 8px;
padding-left: 8px;
padding-bottom: 8px;
display: flex;
position: relative;
z-index: 1;
}
18 changes: 18 additions & 0 deletions themes/jquery/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,24 @@ iframe {
margin: 0;
}

/* Support message at top of page.
========================================================================== */

#support-message {
display: flex;
justify-content: center;
background-color: #dddddd;
padding: 4px 4px;
font-size: 15px;
}
#support-message span {
text-align: center;
padding-left: 20px;
padding-right: 20px;
}
#support-message span a {
color: #222;
}

/* Global Nav
========================================================================== */
Expand Down
41 changes: 41 additions & 0 deletions themes/jquery/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,46 @@ function jq_image_posted_on() {
return $classes;
} );

/*
* Determine if the current page is for a deprecated version of jQuery.
* We are concened with two URL structures:
* category/deprecated/deprecated-1.3/
* category/version/1.9/
*
* @returns int True or false
*/
function jq_is_version_deprecated($url) {
$parsedUrl = parse_url($url);
$path = $parsedUrl['path'];
$segments = explode('/', trim($path, '/'));

$versionLessThan3 = false;

if (count($segments) > 2) {
switch (strtolower($segments[1])) {
// Check first URL structure:
// category/deprecated/deprecated-1.3/
case 'deprecated':
// Obtain the version number from the third slug.
$version = floatval(substr($segments[2], 11));

if ($version < 3) $versionLessThan3 = true;

break;

// Check second URL structure:
// category/version/1.9/
case 'version':
$version = floatval($segments[2]);

if ($version < 3) $versionLessThan3 = true;

break;
}
}
return $versionLessThan3;
}

/**
* Content Security Policy
*/
Expand Down Expand Up @@ -296,3 +336,4 @@ function jq_content_security_policy() {
}

add_action( 'send_headers', 'jq_content_security_policy' );

8 changes: 8 additions & 0 deletions themes/jquery/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
</head>
<body <?php body_class(); ?>>

<?php if (is_front_page()) { ?>

<div id="support-message" class="support-message">
<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>
</div>

<?php } ?>

<header>
<section id="global-nav">
<nav>
Expand Down
1 change: 1 addition & 0 deletions themes/jquery/menu-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function menu_header_jquery_com() {
'https://blog.jquery.com/' => 'Blog',
'https://plugins.jquery.com/' => 'Plugins',
'https://jquery.com/browser-support/' => 'Browser Support',
'https://jquery.com/support/' => 'Version Support',
);
}

Expand Down