/** * Displays a dropdown form with currently active gateways * @param string $input_name Name of the input field * @return void */ function appthemes_list_gateway_dropdown($input_name = 'payment_gateway', $recurring = false, $args = array()) { if (is_array($input_name)) { $args = $input_name; $input_name = 'payment_gateway'; } $args = wp_parse_args($args, array('input_name' => $input_name, 'recurring' => $recurring, 'empty_text' => __('No payment gateways are available.', APP_TD), 'disabled_text' => __(' (disabled)', APP_TD), 'admin_text' => __('Note: Disabled gateways are only available to administrators.', APP_TD))); $gateways = array(); foreach (APP_Gateway_Registry::get_gateways() as $gateway) { if ($args['recurring'] && !$gateway->is_recurring()) { continue; } $text = $gateway->display_name('dropdown'); if (!APP_Gateway_registry::is_gateway_enabled($gateway->identifier())) { if (current_user_can('manage_options')) { $text .= $args['disabled_text']; } else { continue; } } $gateways[$gateway->identifier()] = $text; } if (empty($gateways)) { $gateways[''] = $args['empty_text']; } echo scbForms::input(array('type' => 'select', 'name' => $input_name, 'values' => $gateways, 'extra' => array('class' => 'required'))); if (current_user_can('manage_options')) { echo html('p', array(), $args['admin_text']); } }
function appthemes_list_gateway_dropdown($input_name = 'payment_gateway') { $gateways = array(); foreach (APP_Gateway_Registry::get_gateways() as $gateway) { // Skip disabled gateways if (!APP_Gateway_registry::is_gateway_enabled($gateway->identifier())) { continue; } $gateways[$gateway->identifier()] = $gateway->display_name('dropdown'); } echo scbForms::input(array('type' => 'select', 'name' => $input_name, 'values' => $gateways, 'extra' => array('class' => 'required'))); }