_( 'Easy Digital Downloads Order', 'pronamic_ideal' );
}
/**
* Source URL.
*
* @param string $url URL.
* @param Payment $payment Payment.
*
* @return string
*/
public function source_url( $url, Payment $payment ) {
return EasyDigitalDownloads::get_payment_url( $payment->source_id );
}
/**
* Accepted payment icons
*
* @link https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.1.3/includes/admin/settings/register-settings.php#L261-L268
* @link https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.1.3/includes/checkout/template.php#L573-L609
*
* @param array $icons Icons.
*
* @return array
*/
public static function accepted_payment_icons( $icons ) {
$payment_methods = self::get_payment_methods();
foreach ( $payment_methods as $id => $payment_method ) {
$icon = sprintf(
'/images/%s/icon-64x48.png',
str_replace( '_', '-', $payment_method )
);
// Check if file exists.
if ( ! is_readable( plugin_dir_path( Plugin::$file ) . $icon ) ) {
continue;
}
// Add icon URL.
$url = plugins_url( $icon, Plugin::$file );
$icons[ $url ] = PaymentMethods::get_name( $payment_method );
}
return $icons;
}
/**
* Easy Digital Downloads payment statuses.
*
* The Easy Digital Downloads plugin is equipped with a "Set To Cancelled" bulk action.
* This bulk action will set the status of payments to 'cancelled', this is however not
* a registered payment status. Therefor we will register 'cancelled' as an payment
* status.
*
* @link https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.20/includes/admin/payments/class-payments-table.php#L427-L517
* @link https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.9.20/includes/payments/functions.php#L761-L779
* @param array $payment_statuses Easy Digital Downloads payment statuses.
* @return array
*/
public static function edd_payment_statuses( $payment_statuses ) {
if ( array_key_exists( 'cancelled', $payment_statuses ) ) {
return $payment_statuses;
}
$payment_statuses['cancelled'] = __( 'Cancelled', 'pronamic_ideal' );
return $payment_statuses;
}
/**
* Register cancelled post status.
*
* @return void
*/
private function register_cancelled_post_status() {
register_post_status(
'cancelled',
array(
'label' => _x( 'Cancelled', 'Easy Digital Downloads cancelled payment status', 'pronamic_ideal' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
/* translators: %s: count value */
'label_count' => _n_noop( 'Cancelled (%s)', 'Cancelled (%s)', 'pronamic_ideal' ),
)
);
}
/**
* Payments table views.
*
* @param array $views Payments table views.
*
* @return array
*/
public function payments_table_views( $views ) {
$count = \wp_count_posts( 'edd_payment' );
$views['cancelled'] = sprintf(
'%3$s (%4$s)',
add_query_arg(
array(
'status' => 'cancelled',
'paged' => false,
)
),
\filter_input( \INPUT_GET, 'status' ) === 'cancelled' ? ' class="current"' : '',
_x( 'Cancelled', 'Easy Digital Downloads cancelled payment status', 'pronamic_ideal' ),
\esc_html( $count->cancelled )
);
return $views;
}
}