From 755bf74c7b49facd7c2b55e97adb1c52e29001b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Thu, 26 Jun 2014 09:16:09 +0000 Subject: [PATCH] fix reference passing, add simple d-link support --- freifunk-versions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index c4ee2c3..fca0913 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -15,9 +15,11 @@ define('FF_HH_CACHETIME', 15); /* gets metadata from URL, handles caching */ function ff_hh_getmanifest ($basedir) { // Caching - if ( false === ( $manifest = get_transient( "ff_hh_manifest" ) ) ) { - $manifest = array(); - $input = wp_remote_retrieve_body( wp_remote_get($basedir . 'sysupgrade/manifest') ); + if ( WP_DEBUG || ( false === ( $manifest = get_transient( "ff_hh_manifest" ) ) ) ) { + $manifest = array(); + $url = $basedir . 'sysupgrade/manifest'; + $http_response = wp_remote_get( $url ); // TODO: error handling + $input = wp_remote_retrieve_body( $http_response ); foreach ( explode("\n", $input) as $line ) { $ret = sscanf($line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename); if ($ret === 4) { @@ -104,6 +106,10 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $hw = str_replace('-m', ' M2', $hw); $hw = str_replace('-', ' ', $hw); $hw = ucwords($hw); + } elseif (!strncmp($hw, 'd-link', 6)) { + if ($grep) $hw = str_replace($grep, '', $hw); + $hw = str_replace('-', ' ', $hw); + $hw = str_replace('d link dir ', 'D-Link DIR-', $hw); } $outstr .= sprintf("\n%s", $hw);