Skip to content

Add HeroDevs support. #467

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

Closed
Changes from 1 commit
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
Next Next commit
462: Merge jq_is_version_deprecated().
  • Loading branch information
AndreAngelantoni committed Sep 16, 2024
commit c93db77a36540cac99aa234b238505c0b45ce12a
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' );