Pular para o conteúdo principal
×
/* =========================================================
REGISTRO DO PERSONALIZADOR - ADS REMADOR PRO
Este bloco cria os campos no painel "Personalizar"
========================================================= */
if ( ! function_exists( 'remador_ads_customizer_register' ) ) {
function remador_ads_customizer_register($wp_customize) {
$wp_customize->add_section('remador_ads_section', array(
'title' => 'Portal Remador - Gerenciador de Ads',
'priority' => 120,
'description' => 'Cole aqui o código do anúncio ou Shortcode',
));
$ads = array(
'rem_ad_global_top' => 'Anúncio Topo Global',
'rem_ad_sidebar_int'=> 'Anúncio Sidebar (Interno)',
'rem_ad_p2' => 'Anúncio no 2º Parágrafo',
'rem_ad_p3' => 'Anúncio no 3º Parágrafo',
'rem_ad_feed_cat' => 'Anúncio no Feed de Categorias (a cada 3 posts)'
);
foreach ($ads as $id => $label) {
$wp_customize->add_setting($id, array(
'default' => '',
'sanitize_callback' => 'wp_kses_post',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, $id, array(
'label' => $label,
'section' => 'remador_ads_section',
'settings' => $id,
'type' => 'textarea',
)));
}
}
add_action('customize_register', 'remador_ads_customizer_register');
}
/* =========================================================
BLINDAGEM SEO & ANTISPAM: OMEGA BACKLINK PROTECTOR
Foco: Proteção contra Backlinks tóxicos e validação EEAT
========================================================= */
add_filter('comment_text', function($text) {
return preg_replace('/]+)href=["\'](http|https)([^"\']+)["\']([^>]*)>/i', '', $text);
});
add_filter('author_link', function($link) {
return $link . '" rel="noindex, nofollow';
}, 10, 1);
add_filter('walker_nav_menu_start_el', function($item_output, $item, $depth, $args) {
if (strpos($item_output, 'http') !== false && strpos($item_output, $_SERVER['HTTP_HOST']) === false) {
$item_output = str_replace('post_content);
$key = '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';
// Mínimo de 300 caracteres para garantir que a IA tenha material de qualidade
if ( empty($key) || strlen($texto) < 300 ) return;
$prompt = "Resuma a notícia abaixo em 3 pontos curtos e objetivos. Formato obrigatório: 'Fato: Detalhe'. Sem frases introdutórias. Notícia: " . substr($texto, 0, 1500);
$response = wp_remote_post("https://api.groq.com/openai/v1/chat/completions", [
'headers' => ['Authorization' => 'Bearer ' . $key, 'Content-Type' => 'application/json'],
'body' => wp_json_encode([
"model" => "llama-3.1-8b-instant",
"messages" => [["role" => "user", "content" => $prompt]],
"temperature" => 0.2
]),
'timeout' => 45
]);
if ( ! is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200 ) {
$data = json_decode(wp_remote_retrieve_body($response), true);
$resumo = $data['choices'][0]['message']['content'];
$resumo = str_replace(['*', '- '], '', $resumo);
$linhas = explode("\n", trim($resumo));
$html = '';
foreach($linhas as $l) { if(trim($l)) $html .= '' . trim($l) . ''; }
update_post_meta($post_id, '_remador_resumo_key', $html);
if ( function_exists('wp_cache_delete') ) wp_cache_delete($post_id, 'posts');
}
}
}
// 2. Injetor no Front-end (Prioridade Máxima - Exibição Profissional)
add_filter('the_content', function($content) {
// Só injeta em posts únicos, no loop principal
if ( ! is_singular('post') || ! in_the_loop() || ! is_main_query() ) return $content;
$resumo_html = get_post_meta(get_the_ID(), '_remador_resumo_key', true);
if ( ! empty($resumo_html) ) {
// Design Profissional: Fundo Azul (#f0f7ff), Acordeão colapsável, Bolinhas vermelhas
$bloco = '
';
return $bloco . $content;
}
return $content;
}, 0);
/* =========================================================
REGISTRO DO PERSONALIZADOR - ADS REMADOR PRO
Este bloco cria os campos no painel "Personalizar"
========================================================= */
add_action('customize_register', 'remador_ads_customizer_register');
function remador_ads_customizer_register($wp_customize) {
// 1. Cria a Seção no Painel Personalizar
$wp_customize->add_section('remador_ads_section', array(
'title' => 'Portal Remador - Gerenciador de Ads',
'priority' => 120,
'description' => 'Cole aqui o código do anúncio ou Shortcode',
));
// 2. Define os IDs dos anúncios que o seu motor utiliza (AGORA COM O FEED DE CATEGORIA INCLUSO)
$ads = array(
'rem_ad_global_top' => 'Anúncio Topo Global',
'rem_ad_sidebar_int'=> 'Anúncio Sidebar (Interno)',
'rem_ad_p2' => 'Anúncio no 2º Parágrafo',
'rem_ad_p3' => 'Anúncio no 3º Parágrafo',
'rem_ad_feed_cat' => 'Anúncio no Feed de Categorias (a cada 3 posts)'
);
// 3. Cria os campos para cada anúncio
foreach ($ads as $id => $label) {
$wp_customize->add_setting($id, array(
'default' => '',
'sanitize_callback' => 'wp_kses_post', // Permite scripts e shortcodes
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, $id, array(
'label' => $label,
'section' => 'remador_ads_section',
'settings' => $id,
'type' => 'textarea',
)));
}
}
/* =========================================================
BLINDAGEM SEO & ANTISPAM: OMEGA BACKLINK PROTECTOR
Foco: Proteção contra Backlinks tóxicos e validação EEAT
========================================================= */
// 1. Blindagem de Comentários: Força 'nofollow' em qualquer link externo em comentários
add_filter('comment_text', function($text) {
return preg_replace('/]+)href=["\'](http|https)([^"\']+)["\']([^>]*)>/i', '', $text);
});
// 2. Limpeza de Metadados de Autoria (Zera o rastreio de perfis de spam em buscas)
add_filter('author_link', function($link) {
return $link . '" rel="noindex, nofollow';
}, 10, 1);
// 3. Blindagem de Links em Menus e Widgets (Evita que sites tóxicos ganhem rastreio)
add_filter('walker_nav_menu_start_el', function($item_output, $item, $depth, $args) {
if (strpos($item_output, 'http') !== false && strpos($item_output, $_SERVER['HTTP_HOST']) === false) {
$item_output = str_replace(' "https://schema.org",
"@type" => "CollectionPage",
"name" => $cat->name,
"description" => strip_tags(category_description($cat->term_id)),
"publisher" => [
"@type" => "NewsMediaOrganization",
"name" => "Portal Remador",
"url" => home_url()
]
];
echo '';
});
/* =========================================================
REMADOR TV ENGINE V6.0 - AUTO-INTEGRAÇÃO NATIVA
Detecta blocos de YouTube e aplica o efeito CNN Sticky
========================================================= */
add_filter('render_block', function($block_content, $block) {
// Verifica se é um bloco de vídeo do YouTube (nativo do WP)
if ($block['blockName'] === 'core-embed/youtube') {
// Extrai a URL do iframe nativo
preg_match('/src="([^"]+)"/', $block_content, $matches);
$video_url = isset($matches[1]) ? $matches[1] : '';
if (!empty($video_url)) {
// Retorna o player "Turbinado" com efeito Sticky
return '
REMADOR TV
' . $block_content . '
';
}
}
return $block_content;
}, 10, 2);
// Adiciona o CSS e o JS necessários globalmente
add_action('wp_footer', function() {
if (!is_singular('post')) return;
?>