Pular para o conteúdo principal
×
/**
* =========================================================
* PACOTE DE FUNÇÕES OMEGA - PORTAL REMADOR (V2026.7)
* Descrição: Gerenciador de Ads, Blindagem SEO, IA SGE,
* Schema de Categorias e Remador TV Sticky Engine.
* =========================================================
*/
if ( ! defined( 'ABSPATH' ) ) exit;
/* =========================================================
1. REGISTRO DO PERSONALIZADOR - ADS REMADOR PRO
========================================================= */
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');
}
/* =========================================================
2. BLINDAGEM SEO & ANTISPAM: OMEGA BACKLINK PROTECTOR
========================================================= */
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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';
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');
}
}
}
add_filter('the_content', function($content) {
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) ) {
$bloco = '
';
return $bloco . $content;
}
return $content;
}, 0);
/* =========================================================
4. MOTOR DE AUTORIDADE DE CATEGORIAS (V2026.7)
========================================================= */
add_action('wp_head', function() {
if ( ! is_category() ) return;
$cat = get_queried_object();
$schema = [
"@context" => "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 '';
});
/* =========================================================
5. REMADOR TV ENGINE V6.0 - AUTO-INTEGRAÇÃO NATIVA
========================================================= */
add_filter('render_block', function($block_content, $block) {
if ($block['blockName'] === 'core-embed/youtube') {
preg_match('/src="([^"]+)"/', $block_content, $matches);
$video_url = isset($matches[1]) ? $matches[1] : '';
if (!empty($video_url)) {
return '
REMADOR TV
' . $block_content . '
';
}
}
return $block_content;
}, 10, 2);
add_action('wp_footer', function() {
if (!is_singular('post')) return;
?>