function wpa_download_show_column($name) { global $post; switch ($name) { case 'wpa-download': $value = '<center><span style="display: initial;" class="dashicons dashicons-download"></span> ' . wpa_get_downloads($post->ID) . '</center>'; echo $value; break; } }
<?php echo esc_html($atchment->post_title); ?> </a> <?php $wpatt_date = new DateTime($attachment->post_date); echo '<br><small>' . $wpatt_date->format(get_option('wpatt_option_date_localization')) . '</small>'; ?> </li> </td> <td width="10%"> <?php if (get_option('wpatt_counter')) { ?> <span style="display: initial;" class="dashicons dashicons-download"></span> <?php echo wpa_get_downloads($atchment->ID); ?> <?php } ?> </td> <td width="10%"> <?php echo pathinfo(wp_get_attachment_url($atchment->ID), PATHINFO_EXTENSION); ?> </td> <td width="10%"> <?php if (file_exists(get_attached_file($atchment->ID))) { echo wpatt_format_bytes(filesize(get_attached_file($atchment->ID))); } else {
function wpatt_content_filter($content) { global $post; $somethingtoshow = 0; $content_l = null; $checkrestrict = false; if (get_option('wpatt_option_restrictload') && !is_single() && !is_page()) { $checkrestrict = true; } if ($post->ID == '0' || $post->ID == NULL || get_post_meta($post->ID, 'wpa_off', true) || post_password_required() || $checkrestrict) { return $content; } $attachments = get_posts(array('post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 100, 'post_parent' => $post->ID)); if ($attachments) { $content_l .= '<!-- WP Attachments --> <div style="width:100%;margin:10px 0 10px 0;"><h3>' . get_option('wpatt_option_localization') . '</h3> <ul class="post-attachments">'; foreach ($attachments as $attachment) { $wpatt_option_includeimages_get = get_option('wpatt_option_includeimages'); if ($wpatt_option_includeimages_get == '1') { } else { if (wp_attachment_is_image($attachment->ID)) { continue; } } $somethingtoshow = 1; $class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type); if ($wpatt_option_targetblank_get == '1') { $content_l .= 'target="_blank" '; } if (file_exists(get_attached_file($attachment->ID))) { $wpatt_fs = wpatt_format_bytes(filesize(get_attached_file($attachment->ID))); } else { $wpatt_fs = 'ERROR'; } $wpatt_date = new DateTime($attachment->post_date); switch (get_option('wpa_template')) { case 1: //STANDARD WITH DATE $wpattachments_string = '<a href="%URL%">%TITLE%</a> <small>(%SIZE%)</small> <div style="float:right;">%DATE%</div>'; break; case 2: //EXTENDED $wpattachments_string = '<a href="%URL%">%TITLE%</a> <small>• %SIZE% • %DOWNLOADS% click</small> <div style="float:right;">%DATE%</div><br><small>%CAPTION%</small>'; break; case 3: //CUSTOM $wpattachments_string = html_entity_decode(get_option('wpa_template_custom')); break; default: //DEFAULT $wpattachments_string = '<a href="%URL%">%TITLE%</a> <small>(%SIZE%)</small>'; } if (get_option('wpatt_option_targetblank')) { $wpattachments_string = str_replace('<a href', '<a target="_blank" href', $wpattachments_string); } if (get_option('wpatt_counter')) { $url = add_query_arg('download', $attachment->ID, get_permalink()); } else { $url = wp_get_attachment_url($attachment->ID); } $wpattachments_string = str_replace("%URL%", $url, $wpattachments_string); $wpattachments_string = str_replace("%TITLE%", $attachment->post_title, $wpattachments_string); $wpattachments_string = str_replace("%SIZE%", $wpatt_fs, $wpattachments_string); $wpattachments_string = str_replace("%DATE%", $wpatt_date->format(get_option('wpatt_option_date_localization')), $wpattachments_string); $wpattachments_string = str_replace("%CAPTION%", $attachment->post_excerpt, $wpattachments_string); $wpattachments_string = str_replace("%DESCRIPTION%", $attachment->post_content, $wpattachments_string); $wpattachments_string = str_replace("%AUTHOR%", get_the_author_meta('display_name', $attachment->post_author), $wpattachments_string); $wpattachments_string = str_replace("%DOWNLOADS%", wpa_get_downloads($attachment->ID), $wpattachments_string); $content_l .= '<li class="' . $class . '">' . $wpattachments_string . '</li>'; } $content_l .= '</ul></div>'; } if ($somethingtoshow == 1) { $content .= $content_l; } return $content; }