Update view-order-details.php

Updated to allow a plugin user to add additional columns to the order download section.  These changes are used in conjunction with changes to admin-script.js.  The .js file is changed so that added downloads are reflected in any subsequent post.

Using these changes is similar to adding extra columns to a list table: there is a filter allowing the user to define the additional columns and one to return any existing values.  There is also an additional action which allows the user to render the element to be used to allow page visitor to select/enter an appropriate value.

Here are some examples:

/** Return an array of extra column names to be presented. 
 *  The array key will be the css selector to is while the value will be the title
 *
 */
add_filter('edd_view_order_details_extra_columns', 'view_order_details_extra_columns');
function view_order_details_extra_columns($extra_columns)
{
	return array( 'currency' => 'Currency' );
}

/** Used to add the 'hidden' values that will be posted back
 * @param int $item_id Is the EDD id of the row
 * @param int $key Is ordinal number of the row for which a value is being requested
 * @param string $extra_column Is the extra column for which a value is being requested
 * @param array $cart_item Is the cart content for the row being rendered
 */
add_action('edd_view_order_details_downloads_extra_column_value', 'view_order_details_downloads_extra_column_value', 10, 4);
function view_order_details_downloads_extra_column_value($item_id, $key, $extra_column, $cart_item)
{
	return esc_attr( 'XXX' );
}

/** Used to render the element to capture the value
 * @param int $item_id Is the EDD id of the row
 * @param int $key Is ordinal number of the row for which a value is being requested
 * @param string $extra_column Is the extra column for which a value is being requested
 * @param array $cart_item Is the cart content for the row being rendered
 * @param string $name The value that should be used as the 'name' attribute's value on the rendered element
 * @param string $id The value that should be used as the 'id' attribute's value on the rendered element
 */
add_action('edd_view_order_details_download_extra_column_render', 'view_order_details_download_extra_column_render', 10, 6);
function view_order_details_download_extra_column_render($item_id, $key, $extra_column, $cart_item, $name, $id)
{
	if ($extra_column !== "currency") return;
?>
	<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="" placeholder="" class="small-text edd-order-download-currency">
<?php
}