113 lines
4.3 KiB
PHP
113 lines
4.3 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Nomadro Live AdSense Optimization
|
|
* Description: AdSense head code, trust schema, ads.txt, and editorial CSS for nomadro.live.
|
|
* Author: Nomadro Live
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
const NOMADRO_LIVE_ADSENSE_CLIENT = 'ca-pub-8461145959530971';
|
|
const NOMADRO_LIVE_UMAMI_WEBSITE_ID = '8f5b1e28-641d-467d-9cf3-ed8cf69bb00d';
|
|
|
|
add_action('wp_head', static function (): void {
|
|
$client = NOMADRO_LIVE_ADSENSE_CLIENT;
|
|
echo '<meta name="google-adsense-account" content="' . esc_attr($client) . '">' . "\n";
|
|
echo '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client='
|
|
. esc_attr($client) . '" crossorigin="anonymous"></script>' . "\n";
|
|
echo '<meta name="author" content="Nomadro Live Editorial">' . "\n";
|
|
echo '<meta name="theme-color" content="#0b0f19">' . "\n";
|
|
if (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', NOMADRO_LIVE_UMAMI_WEBSITE_ID)) {
|
|
echo '<script defer src="https://umami.nomadro.com/script.js" data-website-id="'
|
|
. esc_attr(NOMADRO_LIVE_UMAMI_WEBSITE_ID) . '"></script>' . "\n";
|
|
}
|
|
}, 1);
|
|
|
|
add_action('wp_head', static function (): void {
|
|
if (is_admin()) {
|
|
return;
|
|
}
|
|
$data = [
|
|
'@context' => 'https://schema.org',
|
|
'@graph' => [
|
|
[
|
|
'@type' => 'Organization',
|
|
'@id' => home_url('/#organization'),
|
|
'name' => 'Nomadro Live',
|
|
'url' => home_url('/'),
|
|
'email' => 'hello@nomadro.live',
|
|
'description' => 'YouTube channel operations: analytics, live workflows, automation, and production reliability for creators.',
|
|
],
|
|
[
|
|
'@type' => 'WebSite',
|
|
'@id' => home_url('/#website'),
|
|
'url' => home_url('/'),
|
|
'name' => 'Nomadro Live',
|
|
'publisher' => ['@id' => home_url('/#organization')],
|
|
'inLanguage' => 'en-US',
|
|
],
|
|
],
|
|
];
|
|
echo '<script type="application/ld+json">' . wp_json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '</script>' . "\n";
|
|
}, 5);
|
|
|
|
add_action('init', static function (): void {
|
|
$uri = isset($_SERVER['REQUEST_URI']) ? strtok($_SERVER['REQUEST_URI'], '?') : '';
|
|
if ($uri === '/ads.txt') {
|
|
status_header(200);
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
header('X-Robots-Tag: noindex');
|
|
echo "google.com, pub-8461145959530971, DIRECT, f08c47fec0942fa0\n";
|
|
exit;
|
|
}
|
|
});
|
|
|
|
add_action('wp_enqueue_scripts', static function (): void {
|
|
$css = <<<'CSS'
|
|
:root { --nomadro-accent:#7c3aed; }
|
|
body { -webkit-font-smoothing: antialiased; }
|
|
.entry-content, .wp-block-post-content { font-size: 1.0625rem; line-height: 1.75; }
|
|
.entry-content h2, .wp-block-post-content h2 { margin-top: 2rem; line-height: 1.3; }
|
|
.nomadro-trust-footer {
|
|
display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
|
|
justify-content: center; padding: 1.5rem 1rem 2rem; font-size: 0.95rem;
|
|
}
|
|
.nomadro-trust-footer a { color: #344054; text-decoration: underline; }
|
|
CSS;
|
|
wp_register_style('nomadro-live-adsense-opt', false, [], '1.0.0');
|
|
wp_enqueue_style('nomadro-live-adsense-opt');
|
|
wp_add_inline_style('nomadro-live-adsense-opt', $css);
|
|
}, 20);
|
|
|
|
add_action('wp_footer', static function (): void {
|
|
$links = [
|
|
home_url('/about/') => 'About',
|
|
home_url('/contact/') => 'Contact',
|
|
home_url('/privacy-policy/') => 'Privacy Policy',
|
|
home_url('/terms/') => 'Terms of Service',
|
|
home_url('/disclaimer/') => 'Disclaimer',
|
|
];
|
|
echo '<nav class="nomadro-trust-footer" aria-label="Trust and policy links">';
|
|
foreach ($links as $url => $label) {
|
|
echo '<a href="' . esc_url($url) . '">' . esc_html($label) . '</a>';
|
|
}
|
|
echo '</nav>';
|
|
}, 5);
|
|
|
|
remove_action('wp_head', 'wp_generator');
|
|
add_filter('the_generator', '__return_empty_string');
|
|
add_filter('xmlrpc_enabled', '__return_false');
|
|
add_filter('comments_open', '__return_false', 20, 2);
|
|
add_filter('pings_open', '__return_false', 20, 2);
|
|
add_filter('comments_array', static function () {
|
|
return [];
|
|
}, 10, 2);
|
|
add_filter('the_author', static function ($author) {
|
|
return 'Nomadro Live Editorial';
|
|
});
|
|
add_filter('get_the_author_display_name', static function () {
|
|
return 'Nomadro Live Editorial';
|
|
});
|