installed plugin Easy Digital Downloads
version 3.1.0.3
This commit is contained in:
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Contextual Help
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Admin/Downloads
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 1.2.3
|
||||
*/
|
||||
|
||||
use EDD\Admin\Pass_Manager;
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Adds the Contextual Help for the main Downloads page
|
||||
*
|
||||
* @since 1.2.3
|
||||
* @return void
|
||||
*/
|
||||
function edd_downloads_contextual_help() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( $screen->id != 'download' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pass_manager = new Pass_Manager();
|
||||
if ( $pass_manager->isFree() ) {
|
||||
$docs_url = edd_link_helper(
|
||||
'https://easydigitaldownloads.com/docs/',
|
||||
array(
|
||||
'utm_medium' => 'downloads-contextual-help',
|
||||
'utm_content' => 'documentation',
|
||||
)
|
||||
);
|
||||
|
||||
$upgrade_url = edd_link_helper(
|
||||
'https://easydigitaldownloads.com/lite-upgrade/',
|
||||
array(
|
||||
'utm_medium' => 'downloads-contextual-help',
|
||||
'utm_content' => 'lite-upgrade',
|
||||
)
|
||||
);
|
||||
|
||||
$screen->set_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:', 'easy-digital-downloads' ) . '</strong></p>' .
|
||||
'<p>' . sprintf( __( 'Visit the <a href="%s">documentation</a> on the Easy Digital Downloads website.', 'easy-digital-downloads' ), $docs_url ) . '</p>' .
|
||||
'<p>' . sprintf(
|
||||
__( 'Need more from your Easy Digital Downloads store? <a href="%s">Upgrade Now</a>!', 'easy-digital-downloads' ),
|
||||
$upgrade_url
|
||||
) . '</p>'
|
||||
);
|
||||
}
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-download-configuration',
|
||||
'title' => sprintf( __( '%s Settings', 'easy-digital-downloads' ), edd_get_label_singular() ),
|
||||
'content' =>
|
||||
'<p>' . __( '<strong>File Download Limit</strong> - Define how many times customers are allowed to download their purchased files. Leave at 0 for unlimited. Resending the purchase receipt will permit the customer one additional download if their limit has already been reached.', 'easy-digital-downloads' ) . '</p>' .
|
||||
|
||||
'<p>' . __( '<strong>Accounting Options</strong> - If enabled, define an individual SKU or product number for this download.', 'easy-digital-downloads' ) . '</p>' .
|
||||
|
||||
'<p>' . __( '<strong>Button Options</strong> - Disable the automatic output of the purchase button. If disabled, no button will be added to the download page unless the <code>[purchase_link]</code> shortcode is used.', 'easy-digital-downloads' ) . '</p>'
|
||||
) );
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-download-prices',
|
||||
'title' => sprintf( __( '%s Prices', 'easy-digital-downloads' ), edd_get_label_singular() ),
|
||||
'content' =>
|
||||
'<p>' . __( '<strong>Enable variable pricing</strong> - By enabling variable pricing, multiple download options and prices can be configured.', 'easy-digital-downloads' ) . '</p>' .
|
||||
|
||||
'<p>' . __( '<strong>Enable multi-option purchases</strong> - By enabling multi-option purchases customers can add multiple variable price items to their cart at once.', 'easy-digital-downloads' ) . '</p>'
|
||||
) );
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-download-files',
|
||||
'title' => sprintf( __( '%s Files', 'easy-digital-downloads' ), edd_get_label_singular() ),
|
||||
'content' =>
|
||||
'<p>' . __( '<strong>Product Type Options</strong> - Choose a default product type or a bundle. Bundled products automatically include access to other download's files when purchased.', 'easy-digital-downloads' ) . '</p>' .
|
||||
|
||||
'<p>' . __( '<strong>File Downloads</strong> - Define download file names and their respective file URL. Multiple files can be assigned to a single price, or variable prices.', 'easy-digital-downloads' ) . '</p>'
|
||||
) );
|
||||
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-product-notes',
|
||||
'title' => sprintf( __( '%s Instructions', 'easy-digital-downloads' ), edd_get_label_singular() ),
|
||||
'content' => '<p>' . sprintf( __( 'Special instructions for this %s. These will be added to the sales receipt, and may be used by some extensions or themes.', 'easy-digital-downloads' ), strtolower( edd_get_label_singular() ) ) . '</p>'
|
||||
) );
|
||||
|
||||
$colors = array(
|
||||
'gray', 'pink', 'blue', 'green', 'teal', 'black', 'dark gray', 'orange', 'purple', 'slate'
|
||||
);
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-purchase-shortcode',
|
||||
'title' => __( 'Purchase Shortcode', 'easy-digital-downloads' ),
|
||||
'content' =>
|
||||
'<p>' . __( '<strong>Purchase Shortcode</strong> - If the automatic output of the purchase button has been disabled via the Download Configuration box, a shortcode can be used to output the button or link.', 'easy-digital-downloads' ) . '</p>' .
|
||||
'<p><code>[purchase_link id="#" price="1" text="Add to Cart" color="blue"]</code></p>' .
|
||||
'<ul>
|
||||
<li><strong>id</strong> - ' . __( 'The ID of a specific download to purchase.', 'easy-digital-downloads' ) . '</li>
|
||||
<li><strong>price</strong> - ' . __( 'Whether to show the price on the purchase button. 1 to show the price, 0 to disable it.', 'easy-digital-downloads' ) . '</li>
|
||||
<li><strong>text</strong> - ' . __( 'The text to be displayed on the button or link.', 'easy-digital-downloads' ) . '</li>
|
||||
<li><strong>style</strong> - ' . __( '<em>button</em> | <em>text</em> - The style of the purchase link.', 'easy-digital-downloads' ) . '</li>
|
||||
<li><strong>color</strong> - <em>' . implode( '</em> | <em>', $colors ) . '</em></li>
|
||||
<li><strong>class</strong> - ' . __( 'One or more custom CSS classes you want applied to the button.', 'easy-digital-downloads' ) . '</li>
|
||||
</ul>' .
|
||||
'<p>' . sprintf( __( 'For more information, see <a href="%s">using Shortcodes</a> on the WordPress.org Codex or <a href="%s">Easy Digital Downloads Documentation</a>', 'easy-digital-downloads' ), 'https://codex.wordpress.org/Shortcode', 'https://docs.easydigitaldownloads.com/article/229-purchaselink' ) . '</p>'
|
||||
) );
|
||||
|
||||
/**
|
||||
* Fires off in the EDD Downloads Contextual Help Screen
|
||||
*
|
||||
* @since 1.2.3
|
||||
* @param object $screen The current admin screen
|
||||
*/
|
||||
do_action( 'edd_downloads_contextual_help', $screen );
|
||||
}
|
||||
add_action( 'load-post.php', 'edd_downloads_contextual_help' );
|
||||
add_action( 'load-post-new.php', 'edd_downloads_contextual_help' );
|
@ -0,0 +1,378 @@
|
||||
<?php
|
||||
/**
|
||||
* Dashboard Columns
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Admin/Downloads
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Download Columns
|
||||
*
|
||||
* Defines the custom columns and their order
|
||||
*
|
||||
* @since 1.0
|
||||
* @param array $download_columns Array of download columns
|
||||
* @return array $download_columns Updated array of download columns for Downloads
|
||||
* Post Type List Table
|
||||
*/
|
||||
function edd_download_columns( $download_columns ) {
|
||||
$category_labels = edd_get_taxonomy_labels( 'download_category' );
|
||||
$tag_labels = edd_get_taxonomy_labels( 'download_tag' );
|
||||
|
||||
return apply_filters( 'edd_download_columns', array(
|
||||
'cb' => '<input type="checkbox"/>',
|
||||
'title' => __( 'Name', 'easy-digital-downloads' ),
|
||||
'download_category' => $category_labels['menu_name'],
|
||||
'download_tag' => $tag_labels['menu_name'],
|
||||
'price' => __( 'Price', 'easy-digital-downloads' ),
|
||||
'sales' => __( 'Net Sales', 'easy-digital-downloads' ),
|
||||
'earnings' => __( 'Net Revenue', 'easy-digital-downloads' ),
|
||||
'date' => __( 'Date', 'easy-digital-downloads' )
|
||||
) );
|
||||
}
|
||||
add_filter( 'manage_edit-download_columns', 'edd_download_columns' );
|
||||
|
||||
/**
|
||||
* Render Download Columns
|
||||
*
|
||||
* @since 1.0
|
||||
* @param string $column_name Column name
|
||||
* @param int $post_id Download (Post) ID
|
||||
* @return void
|
||||
*/
|
||||
function edd_render_download_columns( $column_name, $post_id ) {
|
||||
|
||||
// Bail if not a download
|
||||
if ( get_post_type( $post_id ) !== 'download' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( $column_name ) {
|
||||
case 'download_category':
|
||||
$terms = get_the_term_list( $post_id, 'download_category', '', ', ', '');
|
||||
echo ! empty( $terms )
|
||||
? $terms
|
||||
: '—';
|
||||
break;
|
||||
case 'download_tag':
|
||||
$terms = get_the_term_list( $post_id, 'download_tag', '', ', ', '');
|
||||
echo ! empty( $terms )
|
||||
? $terms
|
||||
: '—';
|
||||
break;
|
||||
case 'price':
|
||||
if ( edd_has_variable_prices( $post_id ) ) {
|
||||
echo edd_price_range( $post_id );
|
||||
} else {
|
||||
echo edd_price( $post_id, false );
|
||||
echo '<input type="hidden" class="downloadprice-' . absint( $post_id ) . '" value="' . esc_attr( edd_get_download_price( $post_id ) ) . '" />';
|
||||
}
|
||||
break;
|
||||
case 'sales':
|
||||
if ( current_user_can( 'view_product_stats', $post_id ) ) {
|
||||
$sales_url = add_query_arg( array(
|
||||
'page' => 'edd-payment-history',
|
||||
'product-id' => urlencode( $post_id )
|
||||
), edd_get_admin_base_url() );
|
||||
|
||||
echo '<a href="' . esc_url( $sales_url ) . '">';
|
||||
echo edd_get_download_sales_stats( $post_id );
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo '-';
|
||||
}
|
||||
break;
|
||||
case 'earnings':
|
||||
if ( current_user_can( 'view_product_stats', $post_id ) ) {
|
||||
$report_url = edd_get_admin_url( array(
|
||||
'page' => 'edd-reports',
|
||||
'view' => 'downloads',
|
||||
'products' => absint( $post_id ),
|
||||
) );
|
||||
|
||||
echo '<a href="' . esc_url( $report_url ) . '">';
|
||||
echo edd_currency_filter( edd_format_amount( edd_get_download_earnings_stats( $post_id ) ) );
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo '-';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'edd_render_download_columns', 10, 2 );
|
||||
|
||||
/**
|
||||
* Registers the sortable columns in the list table
|
||||
*
|
||||
* @since 1.0
|
||||
* @param array $columns Array of the columns
|
||||
* @return array $columns Array of sortable columns
|
||||
*/
|
||||
function edd_sortable_download_columns( $columns ) {
|
||||
$columns['price'] = 'price';
|
||||
$columns['sales'] = 'sales';
|
||||
$columns['earnings'] = 'earnings';
|
||||
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-download_sortable_columns', 'edd_sortable_download_columns' );
|
||||
|
||||
/**
|
||||
* Sorts Columns in the Downloads List Table
|
||||
*
|
||||
* @since 1.0
|
||||
* @param array $vars Array of all the sort variables
|
||||
* @return array $vars Array of all the sort variables
|
||||
*/
|
||||
function edd_sort_downloads( $vars ) {
|
||||
// Check if we're viewing the "download" post type
|
||||
if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) {
|
||||
// Check if 'orderby' is set to "sales"
|
||||
if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
|
||||
$vars = array_merge(
|
||||
$vars,
|
||||
array(
|
||||
'meta_key' => '_edd_download_sales',
|
||||
'orderby' => 'meta_value_num'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Check if "orderby" is set to "earnings"
|
||||
if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
|
||||
$vars = array_merge(
|
||||
$vars,
|
||||
array(
|
||||
'meta_key' => '_edd_download_earnings',
|
||||
'orderby' => 'meta_value_num'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Check if "orderby" is set to "earnings"
|
||||
if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
|
||||
$vars = array_merge(
|
||||
$vars,
|
||||
array(
|
||||
'meta_key' => 'edd_price',
|
||||
'orderby' => 'meta_value_num'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets restrictions on author of Downloads List Table
|
||||
*
|
||||
* @since 2.2
|
||||
* @param array $vars Array of all sort variables
|
||||
* @return array Array of all sort variables
|
||||
*/
|
||||
function edd_filter_downloads( $vars ) {
|
||||
if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) {
|
||||
|
||||
// If an author ID was passed, use it
|
||||
if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_shop_reports' ) ) {
|
||||
|
||||
$author_id = $_REQUEST['author'];
|
||||
if ( (int) $author_id !== get_current_user_id() ) {
|
||||
// Tried to view the products of another person, sorry
|
||||
wp_die( __( 'You do not have permission to view this data.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
$vars = array_merge(
|
||||
$vars,
|
||||
array(
|
||||
'author' => get_current_user_id()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download Load
|
||||
*
|
||||
* Sorts the downloads.
|
||||
*
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
function edd_download_load() {
|
||||
add_filter( 'request', 'edd_sort_downloads' );
|
||||
add_filter( 'request', 'edd_filter_downloads' );
|
||||
}
|
||||
add_action( 'load-edit.php', 'edd_download_load', 9999 );
|
||||
|
||||
/**
|
||||
* Add Download Filters
|
||||
*
|
||||
* Adds taxonomy drop down filters for downloads.
|
||||
*
|
||||
* @since 1.0
|
||||
* @return void
|
||||
*/
|
||||
function edd_add_download_filters() {
|
||||
global $typenow;
|
||||
|
||||
// Checks if the current post type is 'download'
|
||||
if ( $typenow !== 'download') {
|
||||
return;
|
||||
}
|
||||
|
||||
$terms = get_terms( 'download_category' );
|
||||
if ( count( $terms ) > 0 ) {
|
||||
echo "<select name='download_category' id='download_category' class='postform'>";
|
||||
$category_labels = edd_get_taxonomy_labels( 'download_category' );
|
||||
echo "<option value=''>" . sprintf( __( 'All %s', 'easy-digital-downloads' ), strtolower( $category_labels['name'] ) ) . "</option>";
|
||||
foreach ( $terms as $term ) {
|
||||
$selected = isset( $_GET['download_category'] ) && $_GET['download_category'] === $term->slug ? ' selected="selected"' : '';
|
||||
echo '<option value="' . esc_attr( $term->slug ) . '"' . $selected . '>' . esc_html( $term->name ) .' (' . $term->count .')</option>';
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
|
||||
$terms = get_terms( 'download_tag' );
|
||||
if ( count( $terms ) > 0 ) {
|
||||
echo "<select name='download_tag' id='download_tag' class='postform'>";
|
||||
$tag_labels = edd_get_taxonomy_labels( 'download_tag' );
|
||||
echo "<option value=''>" . sprintf( __( 'All %s', 'easy-digital-downloads' ), strtolower( $tag_labels['name'] ) ) . "</option>";
|
||||
foreach ( $terms as $term ) {
|
||||
$selected = isset( $_GET['download_tag']) && $_GET['download_tag'] === $term->slug ? ' selected="selected"' : '';
|
||||
echo '<option value="' . esc_attr( $term->slug ) . '"' . $selected . '>' . esc_html( $term->name ) .' (' . $term->count .')</option>';
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
|
||||
echo '<input type="hidden" name="all_posts" value="1" />';
|
||||
} else if ( ! current_user_can( 'view_shop_reports' ) ) {
|
||||
$author_id = get_current_user_id();
|
||||
echo '<input type="hidden" name="author" value="' . esc_attr( $author_id ) . '" />';
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'edd_add_download_filters', 100 );
|
||||
|
||||
/**
|
||||
* Remove Download Month Filter
|
||||
*
|
||||
* Removes the drop down filter for downloads by date.
|
||||
*
|
||||
* @author Daniel J Griffiths
|
||||
* @since 2.1
|
||||
* @param array $dates The preset array of dates
|
||||
* @global $typenow The post type we are viewing
|
||||
* @return array Empty array disables the dropdown
|
||||
*/
|
||||
function edd_remove_month_filter( $dates ) {
|
||||
global $typenow;
|
||||
|
||||
if ( 'download' === $typenow ) {
|
||||
$dates = array();
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
add_filter( 'months_dropdown_results', 'edd_remove_month_filter', 99 );
|
||||
|
||||
/**
|
||||
* Adds price field to Quick Edit options
|
||||
*
|
||||
* @since 1.1.3.4
|
||||
* @param string $column_name Name of the column
|
||||
* @param string $post_type Current Post Type (i.e. download)
|
||||
* @return void
|
||||
*/
|
||||
function edd_price_field_quick_edit( $column_name, $post_type ) {
|
||||
|
||||
// Bail if not price or download
|
||||
if ( $column_name !== 'price' || $post_type !== 'download' ) {
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<fieldset class="inline-edit-col-left">
|
||||
<div id="edd-download-data" class="inline-edit-col">
|
||||
<h4><?php echo sprintf( __( '%s Configuration', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></h4>
|
||||
<label>
|
||||
<span class="title"><?php _e( 'Price', 'easy-digital-downloads' ); ?></span>
|
||||
<span class="input-text-wrap">
|
||||
<input type="text" name="_edd_regprice" class="text regprice" />
|
||||
</span>
|
||||
</label>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php
|
||||
}
|
||||
add_action( 'quick_edit_custom_box', 'edd_price_field_quick_edit', 10, 2 );
|
||||
add_action( 'bulk_edit_custom_box', 'edd_price_field_quick_edit', 10, 2 );
|
||||
|
||||
/**
|
||||
* Updates price when saving post
|
||||
*
|
||||
* @since 1.1.3.4
|
||||
* @param int $post_id Download (Post) ID
|
||||
* @return void
|
||||
*/
|
||||
function edd_price_save_quick_edit( $post_id ) {
|
||||
if ( ! isset( $_POST['post_type']) || 'download' !== $_POST['post_type'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( edd_doing_autosave() ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['_edd_regprice'] ) ) {
|
||||
update_post_meta( $post_id, 'edd_price', strip_tags( stripslashes( $_REQUEST['_edd_regprice'] ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'save_post', 'edd_price_save_quick_edit' );
|
||||
|
||||
/**
|
||||
* Process bulk edit actions via AJAX
|
||||
*
|
||||
* @since 1.4.4
|
||||
* @return void
|
||||
*/
|
||||
function edd_save_bulk_edit() {
|
||||
|
||||
$post_ids = ! empty( $_POST['post_ids'] )
|
||||
? wp_parse_id_list( $_POST['post_ids'] )
|
||||
: array();
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
$price = isset( $_POST['price'] )
|
||||
? strip_tags( stripslashes( $_POST['price'] ) )
|
||||
: 0;
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $price ) ) {
|
||||
update_post_meta( $post_id, 'edd_price', edd_sanitize_amount( $price ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
add_action( 'wp_ajax_edd_save_bulk_edit', 'edd_save_bulk_edit' );
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user