['section' => 'Comparte FeAdulta', 'fb' => 'Facebook',
'ig' => 'Instagram', 'print' => 'Imprimir',
'copied' => '¡Enlace copiado! Compártelo en Instagram'],
'en' => ['section' => 'Share FeAdulta', 'fb' => 'Facebook',
'ig' => 'Instagram', 'print' => 'Print',
'copied' => 'Link copied! Share it on Instagram'],
'fr' => ['section' => 'Partager FeAdulta', 'fb' => 'Facebook',
'ig' => 'Instagram', 'print' => 'Imprimer',
'copied' => 'Lien copié ! Partagez-le sur Instagram'],
'it' => ['section' => 'Condividi FeAdulta', 'fb' => 'Facebook',
'ig' => 'Instagram', 'print' => 'Stampa',
'copied' => 'Link copiato! Condividilo su Instagram'],
'pt' => ['section' => 'Partilha FeAdulta', 'fb' => 'Facebook',
'ig' => 'Instagram', 'print' => 'Imprimir',
'copied' => 'Link copiado! Partilha-o no Instagram'],
];
return $all[$lang] ?? $all['es'];
}
function fea_share_block_html(): string {
$t = fea_share_labels();
$url = rawurlencode(get_permalink());
$svg_fb = '';
$svg_ig = '';
$svg_pr = '';
$copied_msg = esc_js($t['copied']);
return '
';
}
function fea_share_already_rendered(string $content): bool {
return strpos($content, 'class="fea-share"') !== false
|| strpos($content, "class='fea-share'") !== false;
}
// ── Bloque al final del contenido ────────────────────────────────────────────
add_filter('the_content', function ($content) {
if (is_admin() || !fea_share_eligible() || !is_main_query() || !in_the_loop()) {
return $content;
}
if (fea_share_already_rendered($content)) return $content;
return $content . fea_share_block_html();
}, 20);
add_filter('render_block', function ($block_content, $block) {
if (is_admin() || !fea_share_eligible()) return $block_content;
if (($block['blockName'] ?? '') !== 'core/post-content') return $block_content;
if (fea_share_already_rendered($block_content)) return $block_content;
return $block_content . fea_share_block_html();
}, 20, 2);
// ── CSS (screen + print) ─────────────────────────────────────────────────────
add_action('wp_head', function () {
if (!fea_share_eligible()) return;
?>
post_content), 30, '…');
$url = get_permalink($post);
$img = get_the_post_thumbnail_url($post, 'large');
if (!$img && preg_match('~
]+src="([^"]+)"~', $post->post_content, $m)) {
$img = $m[1];
}
if ($img && strpos($img, 'http') !== 0) {
if (strpos($img, '//') === 0) {
$img = (is_ssl() ? 'https:' : 'http:') . $img;
} elseif ($img[0] === '/') {
$origin = preg_replace('~^(https?://[^/]+).*~', '$1', home_url('/'));
$img = $origin . $img;
}
}
echo "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
if ($img) {
echo '' . "\n";
}
}, 5);