Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active July 24, 2018 04:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zackkatz/7418620 to your computer and use it in GitHub Desktop.
Save zackkatz/7418620 to your computer and use it in GitHub Desktop.
Allow admins to use test payments in Easy Digital Downloads for a live store.
<?php
/*
Plugin Name: EDD Test Payments
Plugin URI: https://gist.github.com/zackkatz/7418620
Description: Allow admins to use Test Payment even when it's not enabled.
Author: Katz Web Services, Inc.
Version: 1.0
Author URI: http://katz.co
*/
add_filter( 'edd_enabled_payment_gateways', 'kws_edd_enabled_payment_gateways');
if( !function_exists( 'kws_edd_enabled_payment_gateways' ) ) {
/**
* Modify the gateways for users who can manage options so that the Test Payment gateway is activated.
* See /easy-digital-downloads/includes/gateways/functions.php
* @see edd_get_enabled_payment_gateways()
* @param array $gateways Existing activated gateways array
* @return array Modified array
*/
function kws_edd_enabled_payment_gateways($gateway_list) {
global $edd_options,$current_user;
// Is the current user admin?
if(current_user_can( 'manage_options' )) {
$gateway_list['manual'] = array(
'admin_label' => __( 'Test Payment (Admin-Only)', 'edd' ),
'checkout_label' => __( 'Test Payment (Admin-Only)', 'edd' )
);
}
// If the current user's not admin, remove the Test Payment option
else {
unset($gateway_list['manual']);
}
return $gateway_list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment