当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_get_download_files函数代码示例

本文整理汇总了PHP中edd_get_download_files函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_download_files函数的具体用法?PHP edd_get_download_files怎么用?PHP edd_get_download_files使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_get_download_files函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ck_edd_user_download_button

function ck_edd_user_download_button($purchase_form, $args)
{
    global $edd_options;
    if (!is_user_logged_in()) {
        return $purchase_form;
    }
    $download_id = (string) $args['download_id'];
    $current_user_id = get_current_user_id();
    // If the user has purchased this item, itterate through their purchases to get the specific
    // purchase data and pull out the key and email associated with it. This is necessary for the
    // generation of the download link
    if (edd_has_user_purchased($current_user_id, $download_id, $variable_price_id = null)) {
        $user_purchases = edd_get_users_purchases($current_user_id, -1, false, 'complete');
        foreach ($user_purchases as $purchase) {
            $cart_items = edd_get_payment_meta_cart_details($purchase->ID);
            $item_ids = wp_list_pluck($cart_items, 'id');
            if (in_array($download_id, $item_ids)) {
                $email = edd_get_payment_user_email($purchase->ID);
                $payment_key = edd_get_payment_key($purchase->ID);
            }
        }
        $download_ids = array();
        if (edd_is_bundled_product($download_id)) {
            $download_ids = edd_get_bundled_products($download_id);
        } else {
            $download_ids[] = $download_id;
        }
        // Setup the style and colors associated with the settings
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $new_purchase_form = '';
        foreach ($download_ids as $item) {
            // Attempt to get the file data associated with this download
            $download_data = edd_get_download_files($item, null);
            if ($download_data) {
                foreach ($download_data as $filekey => $file) {
                    // Generate the file URL and then make a link to it
                    $file_url = edd_get_download_file_url($payment_key, $email, $filekey, $item, null);
                    $new_purchase_form .= '<a href="' . $file_url . '" class="' . $style . ' ' . $color . ' edd-submit"><span class="edd-add-to-cart-label">Download ' . $file['name'] . '</span></a>&nbsp;';
                }
            }
            // As long as we ended up with links to show, use them.
            if (!empty($new_purchase_form)) {
                $purchase_form = '<h4>' . __('You already own this product. Download it now:', 'edd') . '</h4>' . $new_purchase_form;
            }
        }
    }
    return $purchase_form;
}
开发者ID:mintplugins,项目名称:library,代码行数:49,代码来源:replace-add-to-cart-with-download.php

示例2: edd_email_templage_tags

/**
 * Email Template Tags
 *
 * @access      private
 * @since       1.0 
 * @return      string
*/
function edd_email_templage_tags($message, $payment_data, $payment_id)
{
    $user_info = maybe_unserialize($payment_data['user_info']);
    if (isset($user_info['id']) && $user_info['id'] > 0) {
        $user_data = get_userdata($user_info['id']);
        $name = $user_data->display_name;
    } elseif (isset($user_info['first_name'])) {
        $name = $user_info['first_name'];
    } else {
        $name = $user_info['email'];
    }
    $download_list = '<ul>';
    $downloads = maybe_unserialize($payment_data['downloads']);
    if ($downloads) {
        foreach (maybe_unserialize($payment_data['downloads']) as $download) {
            $id = isset($payment_data['cart_details']) ? $download['id'] : $download;
            $download_list .= '<li>' . get_the_title($id) . '<br/>';
            $download_list .= '<ul>';
            $price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
            $files = edd_get_download_files($id, $price_id);
            if ($files) {
                foreach ($files as $filekey => $file) {
                    $download_list .= '<li>';
                    $file_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $filekey, $id);
                    $download_list .= '<a href="' . $file_url . '">' . $file['name'] . '</a>';
                    $download_list .= '</li>';
                }
            }
            $download_list .= '</ul></li>';
        }
    }
    $download_list .= '</ul>';
    $price = edd_currency_filter($payment_data['amount']);
    $gateway = edd_get_gateway_checkout_label(get_post_meta($payment_id, '_edd_payment_gateway', true));
    $receipt_id = $payment_data['key'];
    $message = str_replace('{name}', $name, $message);
    $message = str_replace('{download_list}', $download_list, $message);
    $message = str_replace('{date}', date(get_option('date_format'), strtotime($payment_data['date'])), $message);
    $message = str_replace('{sitename}', get_bloginfo('name'), $message);
    $message = str_replace('{price}', $price, $message);
    $message = str_replace('{payment_method}', $gateway, $message);
    $message = str_replace('{receipt_id}', $receipt_id, $message);
    $message = apply_filters('edd_email_template_tags', $message, $payment_data);
    return $message;
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:52,代码来源:email-template.php

示例3: edd_block_attachments

/**
 * Blocks access to Download attachments
 *
 * Only blocks files that are listed as downloadable files for the product
 *
 * @since 1.2.2
 * @return void
 */
function edd_block_attachments()
{
    if (!is_attachment()) {
        return;
    }
    $parent = get_post_field('post_parent', get_the_ID());
    $uri = wp_get_attachment_url(get_the_ID());
    $edd_file = strpos($uri, '/edd/');
    if (!$parent && false === $edd_file) {
        return;
    }
    if ('download' != get_post_type($parent) && false === $edd_file) {
        return;
    }
    $files = edd_get_download_files($parent);
    $restricted = wp_list_pluck($files, 'file');
    if (!in_array($uri, $restricted)) {
        return;
    }
    wp_die(__('You do not have permission to view this file.', 'edd'), __('Error', 'edd'), array('response' => 403));
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:29,代码来源:query-filters.php

示例4: vp_edd_fd_filelist

/**
 * Output filelist in ul li list format
 */
function vp_edd_fd_filelist($atts, $content = null)
{
    extract(shortcode_atts(array(), $atts));
    $did = isset($_GET['did']) ? $_GET['did'] : '';
    $files = array();
    if ($did !== '') {
        $files = edd_get_download_files($did);
    }
    // begin output
    ?>
	<ul>
		<?php 
    foreach ($files as $file_key => $file) {
        ?>
		<li><a href="<?php 
        echo vp_edd_fd_build_download_gateway_url($did, $file_key);
        ?>
"><?php 
        echo $file['name'];
        ?>
</a></li>
		<?php 
    }
    ?>
	</ul>
	<?php 
    // end of output
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:31,代码来源:shortcodes.php

示例5: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.4
  * @global object $edd_logs EDD Logs Object
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     global $edd_logs;
     $data = array();
     $args = array('log_type' => 'file_download', 'posts_per_page' => 30, 'paged' => $this->step);
     if (!empty($this->start) || !empty($this->end)) {
         $args['date_query'] = array(array('after' => date('Y-n-d H:i:s', strtotime($this->start)), 'before' => date('Y-n-d H:i:s', strtotime($this->end)), 'inclusive' => true));
     }
     $logs = $edd_logs->get_connected_logs($args);
     if ($logs) {
         foreach ($logs as $log) {
             $user_info = get_post_meta($log->ID, '_edd_log_user_info', true);
             $files = edd_get_download_files($log->post_parent);
             $file_id = (int) get_post_meta($log->ID, '_edd_log_file_id', true);
             $file_name = isset($files[$file_id]['name']) ? $files[$file_id]['name'] : null;
             $user = get_userdata($user_info['id']);
             $user = $user ? $user->user_login : $user_info['email'];
             $data[] = array('date' => $log->post_date, 'user' => $user, 'ip' => get_post_meta($log->ID, '_edd_log_ip', true), 'download' => get_the_title($log->post_parent), 'file' => $file_name);
         }
         $data = apply_filters('edd_export_get_data', $data);
         $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
开发者ID:harish94,项目名称:Easy-Digital-Downloads,代码行数:33,代码来源:class-batch-export-file-downloads.php

示例6: edd_ck_show_file_sizes

function edd_ck_show_file_sizes($post_id)
{
    $files = edd_get_download_files($post_id, null);
    $decimals = 2;
    $sz = 'BKMGTP';
    $header = _n('File Size', 'File Sizes', count($files), 'edd');
    echo '<h5>' . $header . '</h5>';
    echo '<ul>';
    foreach ($files as $file) {
        $bytes = filesize(get_attached_file($file['attachment_id']));
        $factor = floor((strlen($bytes) - 1) / 3);
        echo '<li>' . $file['name'] . ' - ' . sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor] . '</li>';
    }
    echo '</ul>';
}
开发者ID:mintplugins,项目名称:library,代码行数:15,代码来源:download-file-sizes.php

示例7: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 1.4.4
  * @global object $edd_logs EDD Logs Object
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     global $edd_logs;
     $data = array();
     $args = array('nopaging' => true, 'log_type' => 'file_download', 'monthnum' => isset($_POST['month']) ? absint($_POST['month']) : date('n'), 'year' => isset($_POST['year']) ? absint($_POST['year']) : date('Y'));
     $logs = $edd_logs->get_connected_logs($args);
     if ($logs) {
         foreach ($logs as $log) {
             $user_info = get_post_meta($log->ID, '_edd_log_user_info', true);
             $files = edd_get_download_files($log->post_parent);
             $file_id = (int) get_post_meta($log->ID, '_edd_log_file_id', true);
             $file_name = isset($files[$file_id]['name']) ? $files[$file_id]['name'] : null;
             $user = get_userdata($user_info['id']);
             $user = $user ? $user->user_login : $user_info['email'];
             $data[] = array('date' => $log->post_date, 'user' => $user, 'ip' => get_post_meta($log->ID, '_edd_log_ip', true), 'download' => get_the_title($log->post_parent), 'file' => $file_name);
         }
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:29,代码来源:class-export-download-history.php

示例8: edd_render_files_field

/**
 * File Downloads section.
 *
 * Outputs a table of all current files. Extensions can add column heads to the table
 * via the `edd_download_file_table_head` hook, and actual columns via
 * `edd_download_file_table_row`
 *
 * @since 1.0
 * @see edd_render_file_row()
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_files_field($post_id = 0)
{
    $type = edd_get_download_type($post_id);
    $files = edd_get_download_files($post_id);
    $variable_pricing = edd_has_variable_prices($post_id);
    $display = $type == 'bundle' ? ' style="display:none;"' : '';
    $variable_display = $variable_pricing ? '' : 'display:none;';
    ?>
	<div id="edd_download_files"<?php 
    echo $display;
    ?>
>
		<p>
			<strong><?php 
    _e('File Downloads:', 'edd');
    ?>
</strong>
		</p>

		<input type="hidden" id="edd_download_files" class="edd_repeatable_upload_name_field" value=""/>

		<div id="edd_file_fields" class="edd_meta_table_wrap">
			<table class="widefat edd_repeatable_table" width="100%" cellpadding="0" cellspacing="0">
				<thead>
					<tr>
						<!--drag handle column. Disabled until we can work out a way to solve the issues raised here: https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/1066
						<th style="width: 20px"></th>
						-->
						<th style="width: 20%"><?php 
    _e('File Name', 'edd');
    ?>
</th>
						<th><?php 
    _e('File URL', 'edd');
    ?>
</th>
						<th class="pricing" style="width: 20%; <?php 
    echo $variable_display;
    ?>
"><?php 
    _e('Price Assignment', 'edd');
    ?>
</th>
						<?php 
    do_action('edd_download_file_table_head', $post_id);
    ?>
						<th style="width: 2%"></th>
					</tr>
				</thead>
				<tbody>
				<?php 
    if (!empty($files) && is_array($files)) {
        foreach ($files as $key => $value) {
            $name = isset($value['name']) ? $value['name'] : '';
            $file = isset($value['file']) ? $value['file'] : '';
            $condition = isset($value['condition']) ? $value['condition'] : false;
            $attachment_id = isset($value['attachment_id']) ? absint($value['attachment_id']) : false;
            $args = apply_filters('edd_file_row_args', compact('name', 'file', 'condition', 'attachment_id'), $value);
            ?>
						<tr class="edd_repeatable_upload_wrapper edd_repeatable_row" data-key="<?php 
            echo esc_attr($key);
            ?>
">
							<?php 
            do_action('edd_render_file_row', $key, $args, $post_id);
            ?>
						</tr>
				<?php 
        }
    } else {
        ?>
					<tr class="edd_repeatable_upload_wrapper edd_repeatable_row">
						<?php 
        do_action('edd_render_file_row', 0, array(), $post_id);
        ?>
					</tr>
				<?php 
    }
    ?>
					<tr>
						<td class="submit" colspan="4" style="float: none; clear:both; background: #fff;">
							<a class="button-secondary edd_add_repeatable" style="margin: 6px 0 10px;"><?php 
    _e('Add New File', 'edd');
    ?>
</a>
						</td>
					</tr>
				</tbody>
//.........这里部分代码省略.........
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:101,代码来源:metabox.php

示例9: is_print_ticket_item

 /**
  * @param $item
  * @return bool
  */
 protected function is_print_ticket_item($item)
 {
     static $download_files = array();
     if (empty($download_files)) {
         $download_files = edd_get_download_files($item['download_id']);
     }
     foreach ($download_files as $index => $download) {
         if ($item['file'] != $index) {
             continue;
         }
         if (self::TICKET_DOWNLOAD === $download['file']) {
             return true;
         }
         if (self::LEGACY_TICKET_DOWNLOAD === $download['file']) {
             return true;
         }
     }
     return false;
 }
开发者ID:jamestrevorlees,项目名称:odd-web-v1.00,代码行数:23,代码来源:Main.php

示例10: edd_get_purchase_download_links

/**
 * Gets the download links for each item purchased
 *
 * @since 1.1.5
 * @param int $payment_id The ID of the payment to retrieve download links for
 * @return string
 */
function edd_get_purchase_download_links($payment_id = 0)
{
    $downloads = edd_get_payment_meta_cart_details($payment_id, true);
    $payment_key = edd_get_payment_key($payment_id);
    $email = edd_get_payment_user_email($payment_id);
    $links = '<ul class="edd_download_links">';
    foreach ($downloads as $download) {
        $links .= '<li>';
        $links .= '<h3 class="edd_download_link_title">' . esc_html(get_the_title($download['id'])) . '</h3>';
        $price_id = isset($download['options']) && isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
        $files = edd_get_download_files($download['id'], $price_id);
        if (is_array($files)) {
            foreach ($files as $filekey => $file) {
                $links .= '<div class="edd_download_link_file">';
                $links .= '<a href="' . esc_url(edd_get_download_file_url($payment_key, $email, $filekey, $download['id'], $price_id)) . '">';
                if (isset($file['name'])) {
                    $links .= esc_html($file['name']);
                } else {
                    $links .= esc_html($file['file']);
                }
                $links .= '</a>';
                $links .= '</div>';
            }
        }
        $links .= '</li>';
    }
    $links .= '</ul>';
    return $links;
}
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:36,代码来源:template-functions.php

示例11: edd_ajax_generate_file_download_link

/**
 * Retrieves a new download link for a purchased file
 *
 * @since 2.0
 * @return string
*/
function edd_ajax_generate_file_download_link()
{
    if (!current_user_can('view_shop_reports')) {
        die('-1');
    }
    $payment_id = absint($_POST['payment_id']);
    $download_id = absint($_POST['download_id']);
    $price_id = absint($_POST['price_id']);
    if (empty($payment_id)) {
        die('-2');
    }
    if (empty($download_id)) {
        die('-3');
    }
    $payment_key = edd_get_payment_key($payment_id);
    $email = edd_get_payment_user_email($payment_id);
    $limit = edd_get_file_download_limit($download_id);
    if (!empty($limit)) {
        // Increase the file download limit when generating new links
        edd_set_file_download_limit_override($download_id, $payment_id);
    }
    $files = edd_get_download_files($download_id, $price_id);
    if (!$files) {
        die('-4');
    }
    $file_urls = '';
    foreach ($files as $file_key => $file) {
        $file_urls .= edd_get_download_file_url($payment_key, $email, $file_key, $download_id, $price_id);
        $file_urls .= "\n\n";
    }
    die($file_urls);
}
开发者ID:CoolWP,项目名称:Easy-Digital-Downloads,代码行数:38,代码来源:actions.php

示例12: edd_get_file_price_condition

/**
 * Gets the Price ID that can download a file
 *
 * @since 1.0.9
 * @param int $download_id Download ID
 * @param string $file_key File Key
 * @return string - the price ID if restricted, "all" otherwise
 */
function edd_get_file_price_condition($download_id, $file_key)
{
    $files = edd_get_download_files($download_id);
    if (!$files) {
        return false;
    }
    $condition = isset($files[$file_key]['condition']) ? $files[$file_key]['condition'] : 'all';
    return $condition;
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:17,代码来源:download-functions.php

示例13: get_file_price_condition

 /**
  * Retrieve the price option that has access to the specified file
  *
  * @since 2.2
  * @return int|string
  */
 public function get_file_price_condition($file_key = 0)
 {
     $files = edd_get_download_files($this->ID);
     $condition = isset($files[$file_key]['condition']) ? $files[$file_key]['condition'] : 'all';
     return apply_filters('edd_get_file_price_condition', $condition, $this->ID, $files);
 }
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:12,代码来源:class-edd-download.php

示例14: foreach

    foreach ($purchases as $payment) {
        $downloads = edd_get_payment_meta_cart_details($payment->ID, true);
        $purchase_data = edd_get_payment_meta($payment->ID);
        $email = edd_get_payment_user_email($payment->ID);
        if ($downloads) {
            foreach ($downloads as $download) {
                // Skip over Bundles. Products included with a bundle will be displayed individually
                if (edd_is_bundled_product($download['id'])) {
                    continue;
                }
                ?>

					<tr class="edd_download_history_row">
						<?php 
                $price_id = edd_get_cart_item_price_id($download);
                $download_files = edd_get_download_files($download['id'], $price_id);
                $name = get_the_title($download['id']);
                // Retrieve and append the price option name
                if (!empty($price_id)) {
                    $name .= ' - ' . edd_get_price_option_name($download['id'], $price_id, $payment->ID);
                }
                do_action('edd_download_history_row_start', $payment->ID, $download['id']);
                ?>
						<td class="edd_download_download_name"><?php 
                echo esc_html($name);
                ?>
</td>

						<?php 
                if (!edd_no_redownload()) {
                    ?>
开发者ID:benjaminprojas,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:history-downloads.php

示例15: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 2.5
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     $data = array();
     $meta = array('edd_price', '_edd_files', '_edd_download_limit', '_thumbnail_id', 'edd_sku', 'edd_product_notes', '_edd_download_sales', '_edd_download_earnings');
     $args = array('post_type' => 'download', 'posts_per_page' => 30, 'paged' => $this->step);
     $downloads = new WP_Query($args);
     if ($downloads->posts) {
         foreach ($downloads->posts as $download) {
             $row = array();
             foreach ($this->csv_cols() as $key => $value) {
                 // Setup default value
                 $row[$key] = '';
                 if (in_array($key, $meta)) {
                     switch ($key) {
                         case '_thumbnail_id':
                             $image_id = get_post_thumbnail_id($download->ID);
                             $row[$key] = wp_get_attachment_url($image_id);
                             break;
                         case 'edd_price':
                             if (edd_has_variable_prices($download->ID)) {
                                 $prices = array();
                                 foreach (edd_get_variable_prices($download->ID) as $price) {
                                     $prices[] = $price['name'] . ': ' . $price['amount'];
                                 }
                                 $row[$key] = implode(' | ', $prices);
                             } else {
                                 $row[$key] = edd_get_download_price($download->ID);
                             }
                             break;
                         case '_edd_files':
                             $files = array();
                             foreach (edd_get_download_files($download->ID) as $file) {
                                 $f = $file['file'];
                                 if (edd_has_variable_prices($download->ID)) {
                                     $condition = isset($file['condition']) ? $file['condition'] : 'all';
                                     $f .= ';' . $condition;
                                 }
                                 $files[] = $f;
                                 unset($file);
                             }
                             $row[$key] = implode(' | ', $files);
                             break;
                         default:
                             $row[$key] = get_post_meta($download->ID, $key, true);
                             break;
                     }
                 } elseif (isset($download->{$key})) {
                     switch ($key) {
                         case 'post_author':
                             $row[$key] = get_the_author_meta('user_login', $download->post_author);
                             break;
                         default:
                             $row[$key] = $download->{$key};
                             break;
                     }
                 } elseif ('tags' == $key) {
                     $terms = get_the_terms($download->ID, 'download_tag');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 } elseif ('categories' == $key) {
                     $terms = get_the_terms($download->ID, 'download_category');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 }
             }
             $data[] = $row;
         }
         $data = apply_filters('edd_export_get_data', $data);
         $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
开发者ID:pderksen,项目名称:Easy-Digital-Downloads,代码行数:84,代码来源:class-batch-export-downloads.php


注:本文中的edd_get_download_files函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。