Skip to content
Merged
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
510 changes: 0 additions & 510 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
"devDependencies": {
"@playwright/test": "^1.45.3",
"playwright": "^1.45.3"
},
"dependencies": {
"sharp": "^0.34.4"
}
}
45 changes: 45 additions & 0 deletions tests/e2e/seo-remediation.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @ts-check
const { test, expect } = require('@playwright/test');

const BASE_URL =
process.env.PLAYWRIGHT_PROD_BASE_URL ||
process.env.PLAYWRIGHT_BASE_URL ||
'https://www.3wdistributing.com';

test.describe('SEO remediation', () => {
test('overlapping BRABUS price articles redirect to the selected hubs', async ({ request }) => {
const redirects = new Map([
['/brabus-g-wagon-price/', '/price-of-g-wagon-brabus/'],
['/brabus-price/', '/price-of-g-wagon-brabus/'],
['/mercedes-benz-g63-brabus-price/', '/g63-brabus-price/'],
]);

for (const [source, destination] of redirects) {
const response = await request.get(`${BASE_URL}${source}`, {
maxRedirects: 0,
});
expect(response.status(), source).toBe(301);
expect(response.headers().location, source).toBe(`${BASE_URL}${destination}`);
}
});

test('main sitemap excludes utility and duplicate commerce URLs', async ({ request }) => {
const response = await request.get(`${BASE_URL}/sitemap-pages.xml`);
expect(response.ok()).toBeTruthy();
const xml = await response.text();

for (const path of ['/shop/', '/cart/', '/checkout/', '/my-account/']) {
expect(xml, path).not.toContain(`<loc>${BASE_URL}${path}</loc>`);
}
});

test('retained price guides have current metadata and commercial actions', async ({ page }) => {
for (const path of ['/price-of-g-wagon-brabus/', '/g63-brabus-price/']) {
await page.goto(`${BASE_URL}${path}`, { waitUntil: 'domcontentloaded' });
await expect(page).toHaveTitle(/2026/);
await expect(page.locator('[data-threew-commercial-cta]')).toBeVisible();
await expect(page.locator('[data-threew-commercial-cta] a[href*="shop.3wdistributing.com/product-category/brabus"]')).toBeVisible();
await expect(page.locator('[data-threew-commercial-cta] a[href*="shop.3wdistributing.com/contact-us"]')).toBeVisible();
}
});
});
21 changes: 5 additions & 16 deletions wp-content/themes/3w-2025/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ function threew_2025_get_asset($entry = 'index') {
*/
require_once get_theme_file_path('inc/fitment-import.php');

/**
* Include targeted SEO remediation for high-value BRABUS guides.
*/
require_once get_theme_file_path('inc/seo-remediation.php');

/**
* Include SEO functionality
*/
Expand Down Expand Up @@ -667,22 +672,6 @@ function threew_handle_contact_form() {
}
});

add_action('template_redirect', function () {
if (isset($_GET['threew_probe_global']) && $_GET['threew_probe_global'] === '1') {
header('Content-Type: text/plain; charset=utf-8');
echo isset($_SERVER['REQUEST_URI']) ? wp_unslash($_SERVER['REQUEST_URI']) : '';
exit;
}
}, 999);

add_action('template_redirect', function () {
if (isset($_GET['threew_debug_key']) && $_GET['threew_debug_key'] === '1') {
header('Content-Type: text/plain; charset=utf-8');
echo 'site_key=' . threew_get_recaptcha_site_key();
exit;
}
}, 998);

add_action('init', function () {
$already_purged = get_option('threew_about_cache_purged', false);
if ($already_purged) {
Expand Down
10 changes: 9 additions & 1 deletion wp-content/themes/3w-2025/inc/seo-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,11 @@ private function generate_sitemap_index() {
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

$sitemaps = ['posts', 'pages', 'categories', 'products'];
$sitemaps = ['posts', 'pages', 'categories'];

if (post_type_exists('product') && wp_count_posts('product')->publish > 0) {
$sitemaps[] = 'products';
}

foreach ($sitemaps as $sitemap) {
$xml .= ' <sitemap>' . "\n";
Expand Down Expand Up @@ -1182,7 +1186,11 @@ private function generate_sitemap($type) {

case 'pages':
$pages = get_pages();
$excluded_slugs = ['shop', 'cart', 'checkout', 'my-account'];
foreach ($pages as $page) {
if (in_array($page->post_name, $excluded_slugs, true)) {
continue;
}
$xml .= $this->generate_sitemap_entry(
get_permalink($page),
get_the_modified_date('c', $page),
Expand Down
122 changes: 122 additions & 0 deletions wp-content/themes/3w-2025/inc/seo-remediation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
/**
* Focused SEO remediation for the site's highest-visibility BRABUS guides.
*
* @package 3w-2025
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Return the selected guide metadata keyed by post slug.
*
* @return array<string, array{title: string, description: string}>
*/
function threew_2025_get_price_guide_seo() {
return [
'price-of-g-wagon-brabus' => [
'title' => '2026 BRABUS G-Wagon Price: G63, 700, 800 & 900 Costs',
'description' => 'Compare 2026 BRABUS G-Wagon prices for the G63, 700, 800 and 900, plus upgrade costs and guidance from 3W Distributing.',
],
'g63-brabus-price' => [
'title' => '2026 Mercedes-AMG G63 BRABUS Price & Upgrade Guide',
'description' => 'See 2026 Mercedes-AMG G63 BRABUS pricing, upgrade options and genuine parts guidance from 3W Distributing, a premier North American BRABUS dealer.',
],
];
}

/**
* Consolidate overlapping price articles into two authoritative hubs.
*/
add_action( 'template_redirect', function () {
if ( ! is_singular( 'post' ) ) {
return;
}

$redirects = [
'brabus-g-wagon-price' => '/price-of-g-wagon-brabus/',
'brabus-price' => '/price-of-g-wagon-brabus/',
'mercedes-benz-g63-brabus-price' => '/g63-brabus-price/',
];
$slug = get_post_field( 'post_name', get_queried_object_id() );

if ( isset( $redirects[ $slug ] ) ) {
wp_safe_redirect( home_url( $redirects[ $slug ] ), 301, 'ThreeW SEO Consolidation' );
exit;
}
}, 1 );

/**
* Keep document, Open Graph and visible article titles aligned.
*/
add_filter( 'pre_get_document_title', function ( $title ) {
if ( ! is_singular( 'post' ) ) {
return $title;
}

$map = threew_2025_get_price_guide_seo();
$slug = get_post_field( 'post_name', get_queried_object_id() );
return isset( $map[ $slug ] ) ? $map[ $slug ]['title'] . ' - ' . get_bloginfo( 'name' ) : $title;
}, 20 );

add_filter( 'the_title', function ( $title, $post_id ) {
if ( ! is_singular( 'post' ) || (int) $post_id !== get_queried_object_id() ) {
return $title;
}

$map = threew_2025_get_price_guide_seo();
$slug = get_post_field( 'post_name', $post_id );
return isset( $map[ $slug ] ) ? $map[ $slug ]['title'] : $title;
}, 20, 2 );

add_filter( 'get_the_excerpt', function ( $excerpt, $post ) {
$map = threew_2025_get_price_guide_seo();
$slug = $post instanceof WP_Post ? $post->post_name : '';
return isset( $map[ $slug ] ) ? $map[ $slug ]['description'] : $excerpt;
}, 20, 2 );

/**
* Add a direct, measurable commercial path without changing editorial copy.
*/
add_filter( 'the_content', function ( $content ) {
if ( ! is_singular( 'post' ) || ! in_the_loop() || ! is_main_query() ) {
return $content;
}

$map = threew_2025_get_price_guide_seo();
$slug = get_post_field( 'post_name', get_queried_object_id() );
if ( ! isset( $map[ $slug ] ) ) {
return $content;
}

$campaign = rawurlencode( str_replace( '-', '_', $slug ) );
$category = add_query_arg(
[
'utm_source' => '3w_main',
'utm_medium' => 'editorial',
'utm_campaign' => $campaign,
],
'https://shop.3wdistributing.com/product-category/brabus/'
);
$contact = add_query_arg(
[
'utm_source' => '3w_main',
'utm_medium' => 'editorial',
'utm_campaign' => $campaign,
],
'https://shop.3wdistributing.com/contact-us/'
);

$cta = '<aside class="threew-commercial-cta" data-threew-commercial-cta aria-label="BRABUS parts and fitment assistance">';
$cta .= '<h2>' . esc_html__( 'Ready to build your G-Wagon?', 'threew-2025' ) . '</h2>';
$cta .= '<p>' . esc_html__( 'Browse genuine BRABUS upgrades or contact 3W Distributing for pricing, fitment and availability help before ordering.', 'threew-2025' ) . '</p>';
$cta .= '<div class="threew-commercial-cta__actions">';
$cta .= '<a href="' . esc_url( $category ) . '">' . esc_html__( 'Shop BRABUS upgrades', 'threew-2025' ) . '</a>';
$cta .= '<a href="' . esc_url( $contact ) . '">' . esc_html__( 'Request fitment help', 'threew-2025' ) . '</a>';
$cta .= '<a href="tel:+17024306622">' . esc_html__( 'Call (702) 430-6622', 'threew-2025' ) . '</a>';
$cta .= '</div></aside>';

return $content . $cta;
}, 30 );
Loading
Loading