function fetch_external_page_plain_text($atts) {
$atts = shortcode_atts([
'url' => ''
], $atts);
if (empty($atts['url'])) {
return 'No URL provided.';
}
// Fetch the external page
$response = wp_remote_get($atts['url']);
if (is_wp_error($response)) {
return 'Failed to fetch the URL.';
}
$body = wp_remote_retrieve_body($response);
// Strip HTML tags and decode entities
$plain_text = wp_strip_all_tags($body);
$plain_text = html_entity_decode($plain_text, ENT_QUOTES | ENT_HTML5, 'UTF-8');
return "<pre style='white-space: pre-wrap; word-break: break-word;'>{$plain_text}</pre>";
}
add_shortcode('fetch_plain_text', 'https://gettemp.lhermitte.org');