'/privacy|datenschutz|privacidad|privacidade|confidentialit|privasi|गोपनीयता|ગોપનીયતા/iu', 'about' => '/about|ueber-uns|über-uns|acerca|sobre|qui-sommes|a-propos|tentang|हमारे-बारे|અમારા-વિશે|who-we-are/iu', 'contact' => '/contact|kontakt|contacto|contato|kontak|hubungi|संपर्क|સંપર્ક/iu', 'terms' => '/terms|conditions|\btos\b|agb|terminos|términos|termos|syarat|नियम|શરતો/iu', 'disclaimer' => '/disclaimer|haftungsausschluss|descargo|aviso-legal|penafian|अस्वीकरण|ડિસ્ક્લેમર/iu']; } /** Find the policy and trust pages: the user's own links first, then WordPress, then the home page links. */ function aiotsa_find_pages($A) { $out = []; $given = (array) ($A['opts']['pages'] ?? []); $own = $A['mode'] === 'own'; $kinds = aiotsa_page_kinds(); foreach ($kinds as $k => $re) { $u = aiotsa_norm_url($given[$k] ?? ''); if ($u !== '') $out[$k] = $u; } if ($own) { if (empty($out['privacy'])) { $pp = (int) get_option('wp_page_for_privacy_policy'); if ($pp && get_post_status($pp) === 'publish') $out['privacy'] = get_permalink($pp); } $pages = get_posts(['post_type' => 'page', 'post_status' => 'publish', 'numberposts' => 300, 'orderby' => 'menu_order', 'order' => 'ASC']); foreach ($kinds as $k => $re) { if (!empty($out[$k])) continue; foreach ($pages as $p) if (preg_match($re, $p->post_name . ' ' . $p->post_title)) { $out[$k] = get_permalink($p); break; } } } foreach ($kinds as $k => $re) { if (!empty($out[$k])) continue; foreach (($A['summary']['ctx']['home']['int'] ?? []) as $l) { $path = urldecode((string) wp_parse_url($l, PHP_URL_PATH)); if ($path !== '/' && preg_match($re, $path)) { $out[$k] = $l; break; } } } return $out; } function aiotsa_task_policy(&$A) { $R = &$A['results']; $C = &$A['summary']['ctx']; $found = aiotsa_find_pages($A); $C['pages'] = $found; $own = $A['mode'] === 'own'; $home = array_map(function ($u) { return untrailingslashit(strtolower($u)); }, $C['home']['int'] ?? []); $P = []; foreach ($found as $k => $u) { $r = aiotsa_fetch($u, ['timeout' => 10]); $f = $r['ok'] ? aiotsa_parse($r['body'], $r['url']) : null; $P[$k] = ['url' => $u, 'ok' => (bool) $f, 'words' => $f ? $f['words'] : 0, 'text' => $f ? $f['text'] : '', 'html' => $f ? $r['body'] : '', 'linked' => in_array(untrailingslashit(strtolower($u)), $home, true)]; } $names = ['privacy' => 'Privacy Policy', 'about' => 'About', 'contact' => 'Contact', 'terms' => 'Terms', 'disclaimer' => 'Disclaimer']; $fixnew = $own ? 'Create the page in Pages > Add New and link it in the footer menu.' : 'Create the page and link it in the footer.'; foreach (['privacy' => 'fail', 'about' => 'fail', 'contact' => 'fail', 'terms' => 'warn', 'disclaimer' => 'warn'] as $k => $sev) { $id = 'a_' . $k; $p = $P[$k] ?? null; if (!$p) $R[$id] = aiotsa_r($sev, 'Not found.', [], $fixnew); elseif (!$p['ok']) $R[$id] = aiotsa_r('fail', 'Found at %s, but the page does not load.', [$p['url']], 'Open the page and check it is published.', [], [[$names[$k], $p['url']]]); elseif ($p['words'] < 80 && $k !== 'contact') $R[$id] = aiotsa_r('warn', 'Found, but it has only %d words.', [$p['words']], 'Write a complete page.', [], [[$names[$k], $p['url']]]); elseif (!$p['linked']) $R[$id] = aiotsa_r('warn', 'Found, but the home page does not link to it.', [], 'Add it to the footer menu so visitors and reviewers can find it.', [], [[$names[$k], $p['url']]]); else $R[$id] = aiotsa_r('pass', 'Found (%d words) and linked from the home page.', [$p['words']], '', [], [[$names[$k], $p['url']]]); } if (!empty($P['privacy']['ok'])) { $t = strtolower($P['privacy']['text']); $ck = preg_match('/cookie|कुकी|કૂકી/u', $t); $ad = preg_match('/advertis|adsense|google|anuncio|anúncio|publicit|werbung|iklan|विज्ञापन|જાહેરાત/u', $t); $C['privacy_text'] = mb_substr($P['privacy']['text'], 0, 3000); $R['a_privacy_text'] = $ck && $ad ? aiotsa_r('pass', 'It mentions cookies and advertising.') : aiotsa_r('warn', $ck ? 'It mentions cookies, but not advertising or Google.' : 'It does not mention cookies or advertising.', [], 'Add a paragraph on Google advertising cookies and how visitors can opt out.'); } else $R['a_privacy_text'] = aiotsa_skip('No Privacy Policy page to read.'); if (!empty($P['about']['ok'])) { $w = $P['about']['words']; $R['r_about'] = $w >= 250 ? aiotsa_r('pass', '%d words.', [$w]) : aiotsa_r('warn', 'Only %d words.', [$w], 'Say who runs the site, their experience, and why readers can trust it.'); } else $R['r_about'] = aiotsa_r('fail', 'No About page.', [], 'Create one: who runs the site and why.'); if (!empty($P['contact']['ok'])) { $h = $P['contact']['html']; $ways = []; if (preg_match('/mailto:|[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/i', $h)) $ways[] = 'e-mail'; if (stripos($h, '