Peobaedo

API Key guardada.

‘;
}
$key = get_option(‘tmdb_api_key’);
echo ‘

Configurar TMdb

‘;
});
});

// 2. Meta box para el enlace online
add_action(‘add_meta_boxes’, function() {
add_meta_box(‘link_online_box’, ‘Enlace de Reproducción’, function($post) {
$val = get_post_meta($post->ID, ‘link_online’, true);
echo ‘‘;
}, ‘post’, ‘side’, ‘high’);
});

add_action(‘save_post’, function($post_id) {
if (isset($_POST[‘link_online’])) {
update_post_meta($post_id, ‘link_online’, sanitize_text_field($_POST[‘link_online’]));
}
});

// 3. El Shortcode/Ficha Técnica
function mostrar_ficha_pelicula() {
global $post;
$post_id = $post->ID;

// Solo si hay datos importados
$titulo = get_post_meta($post_id, ‘titulo_original’, true);
if (!$titulo) return »;

$link_online = get_post_meta($post_id, ‘link_online’, true);
$trailer_id = get_post_meta($post_id, ‘trailer_youtube’, true);

$html = ‘

‘;
$html .= ‘

Ficha Técnica: ‘ . esc_html($titulo) . ‘

‘;

if ($link_online) {
$html .= ‘

Película Online

‘;
}

if ($trailer_id) {
$html .= ‘

Tráiler

‘;
}

$html .= ‘

‘;
return $html;
}
add_shortcode(‘ficha_pelicula’, ‘mostrar_ficha_pelicula’);

// 4. Inyectar automáticamente
add_filter(‘the_content’, function($content) {
if (is_single()) {
return $content . mostrar_ficha_pelicula();
}
return $content;
});