Last active
July 24, 2018 04:51
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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