/** * 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, 'service' => 'instant', '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($args['service']) as $gateway) { if ($args['recurring'] && !$gateway->is_recurring()) { continue; } $text = $gateway->display_name('dropdown'); if (!APP_Gateway_registry::is_gateway_enabled($gateway->identifier(), $args['service'])) { 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']); } }
/** * Creates the tabs for the page * @return void */ protected function init_tabs() { $this->tabs->add('general', __('General', APP_TD)); $this->tab_sections['general']['regional'] = array('title' => __('Regional', APP_TD), 'fields' => array(array('title' => __('Currency', APP_TD), 'type' => 'select', 'name' => 'currency_code', 'values' => APP_Currencies::get_currency_string_array()), array('title' => __('Identifier', APP_TD), 'type' => 'radio', 'name' => 'currency_identifier', 'values' => array('symbol' => sprintf(__('Symbol (%s)', APP_TD), '{symbol}'), 'code' => sprintf(__('Code (%s)', APP_TD), '{code}'))), array('title' => __('Position', APP_TD), 'type' => 'radio', 'name' => 'currency_position', 'values' => array('left' => '{symbol}1.00', 'left_space' => '{symbol} 1.00', 'right' => '1.00{symbol}', 'right_space' => '1.00 {symbol}')), array('title' => __('Thousands Separator', APP_TD), 'type' => 'text', 'name' => 'thousands_separator', 'tip' => __('This sets the thousand separator of displayed prices.', APP_TD), 'extra' => array('style' => 'width: 50px'), 'default' => ','), array('title' => __('Decimal Separator', APP_TD), 'type' => 'text', 'name' => 'decimal_separator', 'tip' => __('This sets the decimal separator of displayed prices.', APP_TD), 'extra' => array('style' => 'width: 50px'), 'default' => '.'), array('title' => __('Tax Charge', APP_TD), 'type' => 'text', 'name' => 'tax_charge', 'desc' => __('%', APP_TD), 'extra' => array('style' => 'width: 50px'), 'default' => 0))); $this->tab_sections['general']['gateways'] = array('title' => __('Installed Gateways', APP_TD), 'fields' => array()); $gateways = APP_Gateway_Registry::get_gateways(); foreach ($gateways as $gateway) { $this->tab_sections['general']['gateways']['fields'][] = $this->load_gateway_tabs($gateway); } add_action('admin_notices', array($this, 'disabled_gateway_warning')); }
/** * Creates the tabs for the page * @return void */ protected function init_tabs() { $this->tabs->add('general', __('General', APP_TD)); $this->tab_sections['general']['regional'] = array('title' => __('Regional', APP_TD), 'desc' => __('The following options affect how prices are displayed on your website.', APP_TD), 'fields' => array(array('title' => __('Currency', APP_TD), 'type' => 'select', 'name' => 'currency_code', 'values' => APP_Currencies::get_currency_string_array()), array('title' => __('Identifier', APP_TD), 'type' => 'select', 'name' => 'currency_identifier', 'values' => array('symbol' => sprintf(__('Symbol (%s)', APP_TD), '{symbol}'), 'code' => sprintf(__('Code (%s)', APP_TD), '{code}'))), array('title' => __('Position', APP_TD), 'type' => 'select', 'name' => 'currency_position', 'values' => array('left' => 'Left ({symbol}1.00)', 'right' => 'Right (1.00{symbol})', 'left_space' => 'Left with space ({symbol} 1.00)', 'right_space' => 'Right with space (1.00 {symbol})')), array('title' => __('Thousand Separator', APP_TD), 'type' => 'text', 'name' => 'thousands_separator', 'tip' => __('The thousand separator of displayed prices.', APP_TD), 'extra' => array('class' => 'small-text'), 'default' => ','), array('title' => __('Decimal Separator', APP_TD), 'type' => 'text', 'name' => 'decimal_separator', 'tip' => __('The decimal separator of displayed prices.', APP_TD), 'extra' => array('class' => 'small-text'), 'default' => '.'))); $this->tab_sections['general']['tax'] = array('title' => __('Tax', APP_TD), 'desc' => __('The following options affect how taxes are applied to all purchases.', APP_TD), 'fields' => array(array('title' => __('Rate', APP_TD), 'type' => 'text', 'name' => 'tax_charge', 'desc' => __('%', APP_TD), 'tip' => __('Set to zero to disable taxes.', APP_TD), 'extra' => array('class' => 'small-text'), 'default' => 0))); $this->tab_sections['general']['gateways'] = array('title' => __('Installed Gateways', APP_TD), 'fields' => array()); $gateways = APP_Gateway_Registry::get_gateways(); foreach ($gateways as $gateway) { $this->tab_sections['general']['gateways']['fields'][] = $this->load_gateway_tabs($gateway); } add_action('admin_notices', array($this, 'disabled_gateway_warning')); }
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'))); }
public function test_get_gateways() { $this->assertInternalType('array', APP_Gateway_Registry::get_gateways()); }