forked from bockhauzen/rentalshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_pdf.php
31 lines (30 loc) · 1.13 KB
/
product_pdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
// ------------- Pdf File Attachment Function ------------- \\
# Adds a pdf download section to the description of a single product page
function show_product_pdf($content){
// Only for single product pages (woocommerce)
if (is_product()){
global $post;
$custom_content = "";
if(isset($post->_pdf_id)){
$pdfs = get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf',
'orderby' => 'ID',
'order' => 'ASC'
));
if (!empty($pdfs)) {
$custom_content = __("<p><strong><u>Downloads</u></strong></p>", "rentalshop");
$custom_content.= "<p>";
foreach ( $pdfs as $attachment_id => $attachment ) {
$custom_content.='<a href="' . $attachment->guid . '" target="_blank"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> ' . $attachment->post_title . '</a><br>';
}
$custom_content.= "</p>";
$content.= $custom_content;
}
}
}
return $content;
}
?>