/** * custom_columns function. * * @access public * @param mixed $column * @return void */ public function custom_columns($column) { global $post, $download_monitor; $download = new DLM_Download($post->ID); $file = $download->get_file_version(); switch ($column) { case "thumb": echo $download->get_the_image(); break; case "download_id": echo $post->ID; break; case "download_cat": if (!($terms = get_the_term_list($post->ID, 'dlm_download_category', '', ', ', ''))) { echo '<span class="na">–</span>'; } else { echo $terms; } break; case "download_tag": if (!($terms = get_the_term_list($post->ID, 'dlm_download_tag', '', ', ', ''))) { echo '<span class="na">–</span>'; } else { echo $terms; } break; case "featured": if ($download->is_featured()) { echo '<span class="yes">' . __('Yes', 'download-monitor') . '</span>'; } else { echo '<span class="na">–</span>'; } break; case "members_only": if ($download->is_members_only()) { echo '<span class="yes">' . __('Yes', 'download-monitor') . '</span>'; } else { echo '<span class="na">–</span>'; } break; case "redirect_only": if ($download->redirect_only()) { echo '<span class="yes">' . __('Yes', 'download-monitor') . '</span>'; } else { echo '<span class="na">–</span>'; } break; case "file": if ($file) { echo '<a href="' . $download->get_the_download_link() . '"><code>' . $file->filename; if ($size = $download->get_the_filesize()) { echo ' – ' . $size; } echo '</code></a>'; } else { echo '<span class="na">–</span>'; } break; case "version": if ($file && $file->version) { echo $file->version; } else { echo '<span class="na">–</span>'; } break; case "download_count": echo number_format($download->get_the_download_count(), 0, '.', ','); break; case "featured": if ($download->is_featured()) { echo '<img src="' . $download_monitor->plugin_url() . '/assets/images/on.png" alt="yes" />'; } else { echo '<span class="na">–</span>'; } break; } }
/** * download_data function. * * @access public * @param mixed $atts * @param mixed $content * @return void */ public function download_data($atts) { global $download_monitor; extract(shortcode_atts(array('id' => '', 'data' => '', 'version_id' => '', 'version' => ''), $atts)); $id = apply_filters('dlm_shortcode_download_id', $id); if (empty($id) || empty($data)) { return; } $download = new DLM_Download($id); if ($version) { $version_id = $download->get_version_id($version); } if ($version_id) { $download->set_version($version_id); } switch ($data) { // File / Version Info case 'filename': return $download->get_the_filename(); case 'filetype': return $download->get_the_filetype(); case 'filesize': return $download->get_the_filesize(); case 'version': return $download->get_the_version_number(); // Download Info // Download Info case 'title': return $download->get_the_title(); case 'short_description': return $download->get_the_short_description(); case 'download_link': return $download->get_the_download_link(); case 'download_count': return $download->get_the_download_count(); case 'post_content': return wpautop(wptexturize(do_shortcode($download->post->post_content))); case 'post_date': return date_i18n(get_option('date_format', $download->post->post_date)); case 'author': return $download->get_the_author(); // Images // Images case 'image': return $download->get_the_image('full'); case 'thumbnail': return $download->get_the_image('thumbnail'); // Taxonomies // Taxonomies case 'tags': return get_the_term_list($id, 'dlm_download_tags', '', ', ', ''); case 'categories': return get_the_term_list($id, 'dlm_download_category', '', ', ', ''); } }