NEVER EDIT WITH ELEMENTOR or pay the price.
2025-04-16 – Hideki.
This page is “virtual”.
!!!!!! TO EDIT THE PRESS PAGE, PLEASE EDIT THE PAGE WITH THE URL real-press !!!!!
!!!!!! DO NOT TOUCH THIS !!!!!!
The normal press page is too slow, however unfortunately it’s the system choosen by the current website developers.
We must keep on allowing the normal press page to exist and to be updated in whatever manner it is working.

As a solution for the speed, we have setup another server for more sophisticated integrations (for example the future showrooms page, that deals directly with the company internal database.)

This other, separated, server is administered by Hideki. (inject.18montenapoleone.it).
among other thing, this new server is downloading the https://www.18montenapoleone.it/press page and extracts various things from it.
This page, basically dynamically loads the contents cached by this new server, and injects them into the page solving the speed issue.
IMPORTANT – the normal /press page must continue to work normally as it’s used for caching.
Aside from the basic content copy there’s a few extra code to inject the style and the scripts as well.



to enable the actual pdf download it was also necessary to add the following to the functions.php file of the theme

// 1. Registra la query var “download_media”
add_filter(‘query_vars’, function($vars) {
$vars[] = ‘download_pdf’;
return $vars;
});

// 2. Aggiungi un rewrite rule (facoltativo ma utile)
add_action(‘init’, function() {
add_rewrite_rule(‘^download-pdf/([^/]*)/?’, ‘index.php?download_pdf=$matches[1]’, ‘top’);
});

// 3. Gestione del download nel template_redirect
add_action(‘template_redirect’, function() {
$filename = get_query_var(‘download_pdf’);
if ($filename) {
$filename = sanitize_file_name($filename);

// Cerca in tutte le sottocartelle di uploads
$upload_dir = wp_upload_dir();
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($upload_dir[‘basedir’]));
foreach ($files as $file) {
if ($file->getFilename() === $filename) {
$filepath = $file->getPathname();

// Scarica
if (file_exists($filepath)) {
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/pdf’);
header(‘Content-Disposition: attachment; filename=”‘ . basename($filepath) . ‘”‘);
header(‘Content-Length: ‘ . filesize($filepath));
flush();
readfile($filepath);
exit;
}
}
}

// Se non trovato
wp_die(‘File non trovato.’);
}
});