custom_info['pdf_heading'];
?>
Enter a heading and any PDF documents attached will be shown on the page.
custom_info['pdf_heading'];
if (!empty($pdf_heading) && $pdfs=$this->get_pdfs()) {
$html .= '';
$html .= "
$pdf_heading
";
$html .= '
';
foreach ($pdfs as $pdf) {
$html .= '- ';
$html .= '' . $pdf->post_title . '';
$file = get_attached_file($pdf->ID);
if (file_exists($file)) {
$filesize = $this->format_bytes(filesize($file), 0);
$html .= " (pdf, $filesize)";
}
$html .= '
';
}
$html .= '
';
$html .= '
';
}
return $html;
}
function get_pdfs() {
$pdfs = get_children( array('post_parent' => $this->post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'application/pdf', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
return $pdfs;
}
function format_bytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . $units[$pow];
}
}
?>