diff --git a/wordpress/wp-content/mu-plugins/fea-audio-player.php b/wordpress/wp-content/mu-plugins/fea-audio-player.php index ecb7c9f..b8642e2 100644 --- a/wordpress/wp-content/mu-plugins/fea-audio-player.php +++ b/wordpress/wp-content/mu-plugins/fea-audio-player.php @@ -9,14 +9,17 @@ if (!defined('ABSPATH')) exit; /** Devuelve el HTML del reproductor para el post actual, o '' si no hay audio. */ function fea_audio_player_html(): string { - $url = get_post_meta(get_the_ID(), 'fea_audio_url', true); + $id = get_the_ID(); + $url = get_post_meta($id, 'fea_audio_url', true); if (!$url) return ''; + $voice = get_post_meta($id, 'fea_audio_voice', true) ?: 'NicoFeadulta2026'; return '
' . '' . ' Escucha' - . '' + . '' . '
'; } @@ -60,3 +63,27 @@ add_action('wp_head', function () { +// y carga de página, disparado en el primer 'play' (no en cada resume tras +// pausa/seek). gtag ya está definido por fea-analytics.php en wp_head prio 1, +// así que este script (footer) siempre lo encuentra disponible. +add_action('wp_footer', function () { + if (!is_singular('post')) return; + if (!get_post_meta(get_queried_object_id(), 'fea_audio_url', true)) return; + ?> + + ['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']); + $post_id = get_the_ID(); + + return ' +
+ +
+ ' . esc_html($t['section']) . ' + + ' . $svg_fb . '' . esc_html($t['fb']) . ' + + + + + +
+
+
'; +} + +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);