Ein kleines Plugin, um alle Downloads mittels WordPress Download Monitor 3 an den CDN Host umzuleiten, indem vor dem Download die URL on-the-fly geändert wird.
Notwendige Anpassungen
Der Aufruf der Aktion download_ready_to_start
muss in der Datei plugins/download-monitor/download.php
vor die Auswahl des Mirrors verschoben werden:
$wpdb->query( $wpdb->prepare( "INSERT INTO $wp_dlm_db_log (download_id, user_id, date, ip_address) VALUES (%s, %s, %s, %s);", $d->id, $user, date("Y-m-d H:i:s" ,$timestamp), $ipAddress ) ); } /* Do action - should allow custom functions to allow/disallow the download */ do_action('download_ready_to_start', $d); // Select a mirror $mirrors = trim($d->mirrors);
Der Hostname ist direkt im Plugin anzupassen ($cdn_host
).
Source
<?php /* Plugin Name: WordPress Download Monitor Force CDN Plugin URI: https://sezz.at/projects/wordpress/download-monitor-force-cdn Description: Forces WordPress Download Monitor to get all files from your CDN by changing the URL when requesting a download. Version: 0.1 Author: Martin Karer Author URI: https://sezz.at/ */ function download_ready_to_start_cdn($d) { $cdn_host = 'your.cdn.host'; # CHANGE THIS! $urldata = parse_url($d->filename); $d->filename = $urldata['scheme'] . '://' . $cdn_host . $urldata['path']; return $d; } add_action('download_ready_to_start', 'download_ready_to_start_cdn'); ?>