public function render_total_savings() { global $wpdb; $total_savings = 0; $result = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%' ORDER BY ID DESC", ARRAY_A); for ($i = 0; $i < sizeof($result); $i++) { $tiny_metadata = new Tiny_Metadata($result[$i]["ID"]); $savings = $tiny_metadata->get_savings(); $total_savings += $savings['input'] - $savings['output']; } echo '<p>'; if ($total_savings > 0) { printf(self::translate_escape("You have saved a total of %s on images") . '!', '<strong>' . size_format($total_savings) . '</strong>'); } else { $link = '<a href="upload.php?page=tiny-bulk-compress">' . self::translate_escape('Compress All Images') . '</a>'; printf(self::translate_escape('No images compressed yet. Use %s to compress existing images') . '.', $link); } echo '</p>'; }