Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/public_html/tools/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: seo-audit.php

Path: /home2/outerorb/public_html/tools/seo-audit.php

Size: 2.35 KB

Permissions: 0666

<?php
// Simple SEO audit script for this repository.
// Usage: php tools/seo-audit.php > tools/seo-report.md

$root = realpath(__DIR__ . '/../');
$exclude = ['inc', 'assets', 'vendor', '.git', 'node_modules', 'tools'];
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root));
$files = [];
foreach ($it as $f) {
    if (!$f->isFile()) continue;
    if (strtolower($f->getExtension()) !== 'php') continue;
    $path = str_replace('\\', '/', $f->getPathname());
    $rel = substr($path, strlen($root) + 1);
    $parts = explode('/', $rel);
    if (in_array($parts[0], $exclude)) continue;
    // skip this audit script itself
    if ($rel === 'tools/seo-audit.php') continue;
    $files[] = $path;
}

$report = [];
foreach ($files as $file) {
    $content = file_get_contents($file);
    $rel = substr($file, strlen($root) + 1);
    $row = [
        'file' => $rel,
        'has_page_title' => preg_match('/\\$page_title\s*=/', $content) ? 'yes' : 'no',
        'has_page_description' => preg_match('/\\$page_description\s*=/', $content) ? 'yes' : 'no',
        'has_h1' => preg_match('/<h1\b[^>]*>.*?<\\/h1>/is', $content) ? 'yes' : 'no',
        'imgs_missing_alt' => 0
    ];

    // find img tags and count those missing alt attribute
    if (preg_match_all('/<img\b[^>]*>/i', $content, $m)) {
        foreach ($m[0] as $imgTag) {
            if (!preg_match('/\balt\s*=\s*("|\')/i', $imgTag)) {
                $row['imgs_missing_alt']++;
            }
        }
    }
    $report[] = $row;
}

// Output Markdown report
$out = [];
$out[] = "# SEO Audit Report\n";
$out[] = "Generated: " . date('c') . "\n";
$out[] = "| File | Page Title | Page Description | H1 | Images Missing alt |";
$out[] = "|---|---:|---:|---:|---:|";
foreach ($report as $r) {
    $out[] = sprintf("| %s | %s | %s | %s | %s |", $r['file'], $r['has_page_title'], $r['has_page_description'], $r['has_h1'], $r['imgs_missing_alt']);
}
$out[] = "\n\n---\n\n";
$out[] = "Notes:\n- 'yes' means the page defines the corresponding PHP variable or element.\n- Images inside included templates (e.g., in 'inc/') are not scanned by default.\n- Review pages with missing titles/descriptions/H1 and add `$page_title` / `$page_description` / H1 markup.\n";

$reportMd = implode("\n", $out);
file_put_contents($root . '/tools/seo-report.md', $reportMd);
echo $reportMd;

?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager