Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
fix(excludes): add excludes to AMP
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Aug 10, 2018
1 parent 6334d7d commit b718b0e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion wp-pwa.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,19 @@ public function amp_add_canonical() {
$ampServer = $settings['wp_pwa_amp_server'];
$ampForced = false;
$dev = 'false';
$excludes = isset($settings['wp_pwa_excludes']) ? $settings['wp_pwa_excludes'] : array();
$exclusion = false;

if (sizeof($excludes) !== 0) {
foreach ($excludes as $regex) {
$output = array();
$regex = str_replace('/', '\/', $regex);
preg_match('/' . $regex . '/', $url, $output);
if (sizeof($output) > 0) {
$exclusion = true;
}
}
}

if (isset($_GET['amp']) && $_GET['amp'] === 'true') {
$ampForced = true;
Expand All @@ -738,7 +751,7 @@ public function amp_add_canonical() {
if (isset($_GET['dev'])) $dev = $_GET['dev'];

//posts
if ($ampForced || (isset($wp_pwa_amp) && ($wp_pwa_amp !== 'disabled') && (is_single()))) {
if ($ampForced || (isset($wp_pwa_amp) && ($wp_pwa_amp !== 'disabled') && (is_single()) && $exclusion === false)) {
$singleId = get_queried_object_id();
$permalink = get_permalink($singleId);
$path = parse_url($permalink, PHP_URL_PATH);
Expand Down

0 comments on commit b718b0e

Please sign in to comment.