[Plugin: WP Publication Archive] display filesize
-
I want to display my downloads other than it’s in the original code, so I missed the filesize, so I added a new function to the plugin, maybe it will help you. (You have to make a copy of the plugin to not overwrite it on updates.) This will only work correct if your are only using internal documents.
open class.publication-markup.php and add
public function get_the_reallink() { $uri = apply_filters( 'wpa-uri', $this->uri, $this->ID ); $uri = str_replace('|', '://', $uri); return $uri; } public function get_the_size() { clearstatcaches; $uri = $this->get_the_reallink(); $uri = str_replace(get_option('home'), $_SERVER['DOCUMENT_ROOT'], $uri, $count); if ($count = 0) { $uri = str_replace(get_option('home'), $_SERVER['DOCUMENT_ROOT'], $uri); } return $this->format_bytes(filesize($uri)); } private function format_bytes($a_bytes) { if ($a_bytes < 1024) { return number_format ($a_bytes , 2, ',', '.') .' B'; } elseif ($a_bytes < 1048576) { return number_format (round($a_bytes / 1024, 2) , 2, ',', '.') .' KiB'; } elseif ($a_bytes < 1073741824) { return number_format (round($a_bytes / 1048576, 2) , 2, ',', '.') . ' MiB'; } else { return number_format (round($a_bytes / 1073741824, 2) , 2, ',', '.') . ' GiB'; } }open class.wp-publication-archive.php and edit the function shortcode_handler to display the filesize
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘[Plugin: WP Publication Archive] display filesize’ is closed to new replies.