'No title', 'long_title' => 'Title too long', 'short_title' => 'Title too short', 'no_desc' => 'No description', 'long_desc' => 'Description too long', 'short_desc' => 'Description too short', 'no_h1' => 'No H1', 'multi_h1' => 'More than one H1', 'head_skip' => 'Heading level skipped', 'thin' => 'Thin', 'noalt' => 'Images without alt text', 'few_links' => 'Few internal links', 'no_og' => 'No Open Graph', 'no_schema' => 'No schema', 'noindex' => 'noindex', 'hard_read' => 'Hard to read', 'long_url' => 'Long URL', 'load' => 'Did not load']; } /** Everything the report shows, already in the report language. Used by the screen, print, share, Word and CSV. */ function aiotsa_report($A, $lang = '') { $lang = $lang ?: $A['lang']; $T = function ($s) use ($lang) { return aiotsa_t($s, $lang); }; $S = aiotsa_settings(); $reg = aiotsa_registry(); $secs = aiotsa_sections(); $own = $A['mode'] === 'own'; $stl = ['pass' => $T('Pass'), 'warn' => $T('Warning'), 'fail' => $T('Fail'), 'info' => $T('Info'), 'skip' => $T('Not checked')]; $rep = ['id' => $A['id'], 'lang' => $lang, 'mode' => $A['mode'], 'target' => $A['target'], 'host' => (string) wp_parse_url($A['target'], PHP_URL_HOST), 'status' => $A['status'], 'score' => $A['score'], 'date' => wp_date(get_option('date_format'), strtotime(($A['finished'] ?: $A['created']) . ' UTC')), 'brand' => $S['brand'] !== '' ? $S['brand'] : 'AllInOneTools Site Audit', 'logo' => $S['logo'], 'prepared' => $S['prepared'], 'cnt' => $A['summary']['cnt'] ?? [], 'counts' => $A['summary']['ctx']['counts'] ?? [], 'stl' => $stl, 'sections' => [], 'top' => [], 'posts' => [], 'comp' => null, 'ai' => null, 'prev' => null, 'token' => $A['token'], 'shared' => !empty($A['opts']['shared'])]; $sm = (int) ($A['summary']['ctx']['sitemap_count'] ?? 0); $rep['sample_of'] = ($A['mode'] === 'external' && $sm > (int) ($rep['counts']['pages'] ?? 0) + 5) ? $sm : 0; $ad = $A['summary']['adsense'] ?? ''; $rep['adsense'] = $ad; $rep['adsense_label'] = $ad === 'ready' ? $T('Ready') : ($ad === 'almost' ? $T('Almost ready') : ($ad === 'not' ? $T('Not ready') : '')); $top = []; $notes = aiotsa_notes(); $words = aiotsa_note_words(); $rep['notes_print'] = !empty($S['notes_print']); foreach ($secs as $k => [$name, $w]) { $checks = []; foreach ($reg as $id => [$s, $title, $wt]) { if ($s !== $k || !isset($A['results'][$id])) continue; $r = $A['results'][$id]; $list = []; foreach (($r['l'] ?? []) as $row) { $x = (string) ($row[3] ?? ''); if ($id === 'i_bots') $x = $x === 'block' ? $T('Blocked') : $T('Allowed'); $list[] = [$T((string) $row[0]), (string) ($row[1] ?? ''), (string) ($row[2] ?? ''), $x, (int) ($row[4] ?? 0)]; } $c = ['id' => $id, 'words' => strtolower($title . ' ' . ($words[$id] ?? '')), 'title' => $T($title), 'st' => $r['s'], 'msg' => aiotsa_tf($r['m'], $lang), 'fix' => isset($r['f']) ? aiotsa_tf($r['f'], $lang) : '', 'list' => $list]; $checks[] = $c; if (($r['s'] === 'fail' || $r['s'] === 'warn') && $wt > 0) $top[] = [($r['s'] === 'fail' ? 100 : 0) + $wt * 10 + $w, $c, $T($name)]; } if (!$checks) continue; $sc = $A['summary']['sec'][$k] ?? null; $rep['sections'][] = ['k' => $k, 'name' => $T($name), 'score' => $sc ? $sc['score'] : null, 'pass' => $sc['pass'] ?? 0, 'warn' => $sc['warn'] ?? 0, 'fail' => $sc['fail'] ?? 0, 'checks' => $checks, 'what' => isset($notes[$k]) ? $T($notes[$k][0]) : '', 'why' => isset($notes[$k]) ? $T($notes[$k][1]) : '', 'attn' => count(array_filter($checks, function ($c) { return $c['st'] === 'fail' || $c['st'] === 'warn'; }))]; } usort($top, function ($a, $b) { return $b[0] <=> $a[0]; }); $top = array_values(array_filter($top, function ($t) { return $t[1]['id'] !== 'a_open'; })); foreach (array_slice($top, 0, 10) as [, $c, $sn]) $rep['top'][] = ['title' => $c['title'] . ': ' . $c['msg'], 'sub' => $c['fix'], 'sec' => $sn, 'id' => $c['id']]; $il = aiotsa_issue_labels(); foreach (aiotsa_items($A['id'], 'post') as $it) { $d = $it['data']; $rep['posts'][] = ['pid' => $own ? $it['ref'] : 0, 'title' => $d['pt'] ?? $d['t'], 'url' => $it['url'], 'edit' => ($own && $it['ref']) ? (string) get_edit_post_link($it['ref'], 'raw') : '', 'type' => $d['type'] ?? 'post', 'words' => (int) ($d['w'] ?? 0), 'score' => $it['score'], 'tl' => (int) ($d['tl'] ?? 0), 'dl' => (int) ($d['dl'] ?? 0), 'na' => (int) ($d['na'] ?? 0), 'links' => count($d['il'] ?? []), 'issues' => array_map(function ($c) use ($il, $T) { return $T($il[$c] ?? $c); }, $d['is'] ?? []), 'codes' => $d['is'] ?? [], 'mod' => $d['mod'] ?? '']; } usort($rep['posts'], function ($a, $b) { return $a['score'] <=> $b['score']; }); if (!empty($A['summary']['prev'])) { $p = $A['summary']['prev']; $rows = [[$T('Overall'), (int) $p['score'], $A['score']]]; foreach ($rep['sections'] as $s) if ($s['score'] !== null && isset($p['sec'][$s['k']])) $rows[] = [$s['name'], (int) $p['sec'][$s['k']]['score'], $s['score']]; $rep['prev'] = ['date' => wp_date(get_option('date_format'), strtotime($p['date'] . ' UTC')), 'rows' => $rows]; } // standard roadmap from the audit (the AI one replaces it when present) $rm = ['d30' => [], 'd60' => [], 'd90' => []]; $where = ['adsense' => 'd30', 'tech' => 'd30', 'onpage' => 'd60', 'wp' => 'd60', 'security' => 'd60', 'trust' => 'd90', 'ai' => 'd90', 'speed' => 'd90', 'domain' => 'd60']; foreach ($top as [, $c]) { $k = $where[$reg[$c['id']][0]] ?? 'd90'; if ($c['st'] === 'fail' && $k !== 'd30' && count($rm['d30']) < 5) $k = 'd30'; if ($c['fix'] !== '' && count($rm[$k]) < 5) $rm[$k][] = $c['fix']; } $rep['roadmap'] = ['ai' => false] + $rm; $L = ['Site audit report', 'Website audit report', 'Page audit report', 'Overall score', 'of 100', 'AdSense readiness', 'Fix these first', 'Score by section', 'Check', 'Result', 'What we found and how to fix it', 'Fix', 'Summary', 'Content: every page and post', 'Page', 'Words', 'Score', 'Issues', 'Competitor comparison', 'What we compared', 'Your site', 'They have it, you do not', 'You have it, they do not', 'Both have it, theirs is stronger', 'Topics they cover and you do not (estimate)', '90-day roadmap', 'Days 1-30', 'Days 31-60', 'Days 61-90', 'Compared with the last audit', 'Section', 'Last time', 'Now', 'Change', 'AI suggestion (Google Gemini) - check before you use it', 'Prepared by', 'passed', 'warnings', 'failed', 'Show the list', 'Yes', 'No', 'no change', 'Paragraph for your Privacy Policy', 'Topics to write next', 'Edit', 'Found on', 'more in the CSV download', 'Title', 'Description', 'Images without alt text', 'Internal links', 'Scores are a guide from our own checks. They are not from Google and do not guarantee rankings or AdSense approval. AdSense approval is Google\'s decision.', 'Based on the public pages of the competitor (%d pages read). Traffic, rankings and backlinks are not public data and are not included.', 'Scanned on %s', 'Pages scanned', 'chars', 'What the competitors do better', 'AI Insights could not be made: %s', 'The competitor site could not be read: %s', 'A sample of about %d pages in the sitemap']; foreach (['What is checked where', 'What this section checks', 'Checks in this section', 'Why it matters', 'What it looks at', 'Checks', 'Need attention'] as $s) $L[] = $s; foreach ($L as $s) $rep['L'][$s] = $T($s); return apply_filters('aiotsa_report', $rep, $A, $T); } /* ---------- HTML ---------- */ /** The HTML tags and attributes the plugin's own markup uses. Every HTML string the plugin prints goes through wp_kses() with this list. */ function aiotsa_allowed_html() { static $A = null; if ($A !== null) return $A; $g = ['class' => true, 'id' => true, 'style' => true, 'title' => true, 'lang' => true, 'dir' => true, 'hidden' => true, 'role' => true, 'tabindex' => true, 'data-*' => true, 'aria-label' => true, 'aria-hidden' => true, 'aria-live' => true, 'aria-current' => true, 'aria-expanded' => true, 'aria-controls' => true, 'aria-describedby' => true, 'aria-labelledby' => true, 'aria-pressed' => true]; $A = wp_kses_allowed_html('post'); foreach (['div', 'span', 'p', 'a', 'b', 'strong', 'i', 'em', 'small', 'br', 'hr', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'section', 'header', 'footer', 'nav', 'details', 'summary', 'label', 'code', 'pre', 'img', 'figure', 'figcaption', 'datalist'] as $t) $A[$t] = (isset($A[$t]) && is_array($A[$t]) ? $A[$t] : []) + $g; $A['a'] += ['href' => true, 'target' => true, 'rel' => true, 'download' => true]; $A['details'] += ['open' => true]; $A['label'] += ['for' => true]; $A['td'] += ['colspan' => true, 'rowspan' => true]; $A['th'] += ['colspan' => true, 'rowspan' => true, 'scope' => true]; $A['img'] += ['src' => true, 'alt' => true, 'width' => true, 'height' => true, 'loading' => true]; $A['button'] = $g + ['type' => true, 'name' => true, 'value' => true, 'disabled' => true]; $A['input'] = $g + ['type' => true, 'name' => true, 'value' => true, 'placeholder' => true, 'readonly' => true, 'disabled' => true, 'checked' => true, 'size' => true, 'min' => true, 'max' => true, 'step' => true, 'list' => true, 'autocomplete' => true]; $A['select'] = $g + ['name' => true, 'disabled' => true]; $A['option'] = ['value' => true, 'selected' => true]; $A['textarea'] = $g + ['name' => true, 'rows' => true, 'cols' => true, 'placeholder' => true, 'readonly' => true]; $A['svg'] = $g + ['width' => true, 'height' => true, 'viewbox' => true, 'xmlns' => true, 'fill' => true, 'focusable' => true]; $A['circle'] = ['cx' => true, 'cy' => true, 'r' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-dasharray' => true, 'stroke-dashoffset' => true, 'transform' => true, 'class' => true]; $A['text'] = ['x' => true, 'y' => true, 'text-anchor' => true, 'dominant-baseline' => true, 'font-size' => true, 'font-weight' => true, 'fill' => true, 'class' => true]; $A['g'] = ['transform' => true, 'fill' => true, 'class' => true]; $A['path'] = ['d' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'class' => true]; $A['line'] = ['x1' => true, 'x2' => true, 'y1' => true, 'y2' => true, 'stroke' => true, 'stroke-width' => true]; $A['rect'] = ['x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'fill' => true, 'class' => true]; $A['polyline'] = ['points' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true]; $A = (array) apply_filters('aiotsa_allowed_html', $A); return $A; } function aiotsa_kses($html) { return wp_kses((string) $html, aiotsa_allowed_html()); } /** Extra CSS for the report from add-ons. It is added with wp_add_inline_style(), never printed as a style tag. */ function aiotsa_report_css($ctx) { return wp_strip_all_tags((string) apply_filters('aiotsa_report_css', '', $ctx)); } function aiotsa_ring($s, $size = 120, $dark = false) { $r = 42; $c = 2 * M_PI * $r; $col = $s >= 80 ? '#1a9c56' : ($s >= 55 ? '#d98a00' : '#d43c3c'); return '' . (int) $s . ''; } function aiotsa_col($s) { return $s >= 80 ? '#1a9c56' : ($s >= 55 ? '#d98a00' : '#d43c3c'); } /** Darker shades of the same colors, readable as text on white. */ function aiotsa_tcol($s) { return $s >= 80 ? '#12643a' : ($s >= 55 ? '#8a5200' : '#a11b1b'); } /** $ctx: admin (with action buttons), print, share. */ function aiotsa_report_html($rep, $ctx = 'admin') { $L = $rep['L']; $e = 'esc_html'; $adm = $ctx === 'admin'; $h = '
'; $title = $rep['mode'] === 'page' ? $L['Page audit report'] : ($rep['mode'] === 'own' ? $L['Site audit report'] : $L['Website audit report']); $h .= '
' . ($rep['logo'] ? '' : '') . '' . $e($rep['brand']) . '

' . $e($title) . '

' . $e($rep['target']) . '

' . $e(sprintf($L['Scanned on %s'], $rep['date'])) . ($rep['prepared'] !== '' ? ' · ' . $e($L['Prepared by']) . ' ' . $e($rep['prepared']) : '') . (!empty($rep['counts']['pages']) ? ' · ' . $e($L['Pages scanned']) . ': ' . (int) $rep['counts']['pages'] : '') . ($rep['sample_of'] ? ' · ' . $e(sprintf($L['A sample of about %d pages in the sitemap'], $rep['sample_of'])) : '') . '

'; $c = $rep['cnt'] + ['pass' => 0, 'warn' => 0, 'fail' => 0]; $h .= '
' . aiotsa_ring($rep['score'], 132, true) . '
' . $e($L['Overall score']) . ': ' . (int) $rep['score'] . ' ' . $e($L['of 100']) . '

' . (int) $c['pass'] . ' ' . $e($L['passed']) . ', ' . (int) $c['warn'] . ' ' . $e($L['warnings']) . ', ' . (int) $c['fail'] . ' ' . $e($L['failed']) . '.

' . ($rep['adsense_label'] !== '' ? '

' . $e($L['AdSense readiness']) . ': ' . $e($rep['adsense_label']) . '

' : '') . '
'; $h .= '
'; foreach ($rep['sections'] as $s) if ($s['score'] !== null) $h .= '' . aiotsa_ring($s['score'], 70, true) . '' . $e($s['name']) . ''; $h .= '
'; $h .= apply_filters('aiotsa_report_slot', '', 'top', $rep, $ctx, null); if ($rep['top']) { $h .= '

' . $e($L['Fix these first']) . '

    '; foreach ($rep['top'] as $t) $h .= '
  1. ' . $e($t['title']) . '' . ($t['sub'] !== '' ? '' . $e($L['Fix']) . ': ' . $e($t['sub']) . ' ' : '') . '' . $e($t['sec']) . '
  2. '; $h .= '
'; } $h .= '

' . $e($L['Score by section']) . '

'; foreach ($rep['sections'] as $s) if ($s['score'] !== null) $h .= ''; $h .= '
' . $e($s['name']) . '' . (int) $s['score'] . '
' . (int) $s['pass'] . ' ' . $e($L['passed']) . ', ' . (int) $s['warn'] . ' ' . $e($L['warnings']) . ', ' . (int) $s['fail'] . ' ' . $e($L['failed']) . '
'; $notes_on = $ctx !== 'print' || !empty($rep['notes_print']); $noted = array_values(array_filter($rep['sections'], function ($s) { return ($s['what'] ?? '') !== ''; })); if ($notes_on && count($noted) > 1) { $h .= '

' . $e($L['What is checked where']) . '

'; if ($adm) $h .= '

'; $h .= ''; foreach ($noted as $s) $h .= ''; $h .= '
' . $e($L['Section']) . '' . $e($L['What it looks at']) . '' . $e($L['Checks']) . '' . $e($L['Need attention']) . '
' . $e($s['name']) . '' . $e($s['what']) . '' . count($s['checks']) . '' . (int) $s['attn'] . '
'; } if ($rep['prev']) { $h .= '

' . $e($L['Compared with the last audit']) . ' ' . $e($rep['prev']['date']) . '

'; foreach ($rep['prev']['rows'] as [$n, $a, $b]) $h .= ''; $h .= '
' . $e($L['Section']) . '' . $e($L['Last time']) . '' . $e($L['Now']) . '' . $e($L['Change']) . '
' . $e($n) . '' . (int) $a . '' . (int) $b . '' . ($b === $a ? $e($L['no change']) : ($b > $a ? '+' : '') . ($b - $a)) . '
'; } foreach ($rep['sections'] as $s) { $h .= '

' . $e($s['name']) . ($s['score'] !== null ? ' ' . (int) $s['score'] . '' : '') . ($s['k'] === 'adsense' && $rep['adsense_label'] !== '' ? ' ' . $e($rep['adsense_label']) . '' : '') . '

'; if ($notes_on && ($s['what'] ?? '') !== '') { $names = []; foreach ($s['checks'] as $c) $names[] = '' . $e($c['title']) . ''; $h .= '
' . $e($L['What this section checks']) . ': ' . $e($s['what']) . '

' . $e($L['Checks in this section']) . ' (' . count($s['checks']) . '): ' . implode(', ', $names) . '

' . $e($L['Why it matters']) . ': ' . $e($s['why']) . '

'; } $h .= ''; foreach ($s['checks'] as $c) { $h .= ''; } $h .= '
' . $e($L['Check']) . '' . $e($L['Result']) . '' . $e($L['What we found and how to fix it']) . '
' . $e($c['title']) . '' . $e($rep['stl'][$c['st']]) . '' . $e($c['msg']); if ($c['fix'] !== '') $h .= '
' . $e($L['Fix']) . ': ' . $e($c['fix']) . '
'; if ($c['list']) { $n = count($c['list']); $show = $ctx === 'print' ? array_slice($c['list'], 0, 12) : $c['list']; $rows = ''; foreach ($show as $r) { $rows .= '
  • ' . ($r[1] !== '' ? '' . $e($r[0]) . '' : $e($r[0])) . ($r[3] !== '' ? ' ' . ($c['id'] === 't_broken' ? $e($L['Found on']) . ': ' : '') . $e($r[3]) . '' : '') . ($adm && $r[2] !== '' ? ' ' . $e($L['Edit']) . ' ' . esc_html__('(opens in a new tab)', 'aiot-site-audit') . '' : '') . '
  • '; } $h .= $ctx === 'print' ? '
      ' . $rows . ($n > 12 ? '
    • +' . ($n - 12) . ' ' . $e($L['more in the CSV download']) . '
    • ' : '') . '
    ' : '' . $e($L['Show the list']) . ' (' . $n . ')
      ' . $rows . '
    '; $h .= apply_filters('aiotsa_report_slot', '', 'check', $rep, $ctx, $c); } if ($adm && $c['id'] === 'i_llms' && $c['st'] !== 'pass') $h .= ' ' . esc_html__('Create llms.txt', 'aiot-site-audit') . ''; if ($adm && $c['id'] === 'i_bots') $h .= ' ' . esc_html__('Set AI crawler rules', 'aiot-site-audit') . ''; $h .= '
    '; $h .= apply_filters('aiotsa_report_slot', '', 'after_section', $rep, $ctx, $s); $h .= '
    '; } if ($rep['posts']) { $max = $ctx === 'print' ? 100 : 200; $h .= '

    ' . $e($L['Content: every page and post']) . ' ' . count($rep['posts']) . '

    ' . ($adm ? '' : '') . ''; foreach (array_slice($rep['posts'], 0, $max) as $p) { $h .= ''; if ($adm) $h .= ''; $h .= ''; } $h .= '
    ' . $e($L['Page']) . '' . $e($L['Words']) . '' . $e($L['Score']) . '' . $e($L['Issues']) . '
    ' . $e($p['title']) . '' . number_format_i18n($p['words']) . '' . (int) $p['score'] . '' . implode(' ', array_map(function ($i) use ($e) { return '' . $e($i) . ''; }, $p['issues'])) . '' . ($p['pid'] ? apply_filters('aiotsa_report_slot', '', 'post', $rep, $ctx, $p) . ' · ' . $e($L['Edit']) . ' ' . esc_html__('(opens in a new tab)', 'aiot-site-audit') . '' : '') . '
    ' . (count($rep['posts']) > $max ? '

    +' . (count($rep['posts']) - $max) . ' ' . $e($L['more in the CSV download']) . '

    ' : '') . '
    '; } $h .= apply_filters('aiotsa_report_slot', '', 'comp', $rep, $ctx, null); $rm = $rep['roadmap']; if (!empty($rm['d30']) || !empty($rm['d60']) || !empty($rm['d90'])) { $h .= '

    ' . $e($L['90-day roadmap']) . '

    ' . ($rm['ai'] ? '' . $e($L['AI suggestion (Google Gemini) - check before you use it']) . '' : '') . '
    '; foreach (['d30' => 'Days 1-30', 'd60' => 'Days 31-60', 'd90' => 'Days 61-90'] as $k => $t) $h .= '
    ' . $e($L[$t]) . '
      ' . implode('', array_map(function ($x) use ($e) { return '
    • ' . $e(is_scalar($x) ? $x : '') . '
    • '; }, (array) ($rm[$k] ?? []))) . '
    '; $h .= '
    '; } $h .= '
    '; return $h; }