コード例 #1
0
/**
 * Get the type of the file associated to the given post
 *
 * @param int   $post_id Defaults to the current post ID from the loop
 * @param array $file    The file description
 *
 * @return string|mixed
 */
function cuar_get_the_attached_file_size($post_id = null, $file, $human = true)
{
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    if (!$post_id) {
        return '';
    }
    /** @var CUAR_PrivateFileAddOn $pf_addon */
    $pf_addon = cuar_addon('private-files');
    $size = $pf_addon->get_file_size($post_id, $file);
    if (false === $size) {
        return '';
    }
    if ($human) {
        $size = cuar_format_human_file_size($size);
    }
    return apply_filters('cuar/private-content/files/the-size', $size, $post_id);
}
コード例 #2
0
/**
 * Get the type of the file associated to the given post
 *
 * @param int $post_id
 *
 * @return string|mixed
 */
function cuar_get_the_file_size($post_id = null, $human = true)
{
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    if (!$post_id) {
        return '';
    }
    $cuar_plugin = CUAR_Plugin::get_instance();
    $pf_addon = $cuar_plugin->get_addon('private-files');
    $size = $pf_addon->get_file_size($post_id);
    if (false === $size) {
        return '';
    }
    if ($human) {
        $size = cuar_format_human_file_size($size);
    }
    return apply_filters('cuar/private-content/files/the-size', $size, $post_id);
}