Location: PHPKode > scripts > WP Deals > wp-deals/wpdeals-classes/gateways/gateways.class.php
<?php
/**
 * WPDeals Payment Gateways class
 * 
 * Loads payment gateways via hooks for use in the store.
 *
 * @class 		wpdeals_payment_gateways
 * @package		WPDeals
 * @category	Payment Gateways
 * @author		Tokokoo
 */
class wpdeals_payment_gateways {
	
	var $payment_gateways;
   
    function init() {
    
    	$load_gateways = apply_filters('wpdeals_payment_gateways', array());
		
		// Get order option
		$ordering 	= (array) get_option('wpdeals_gateway_order');
		$order_end 	= 999;
		
		// Load gateways in order
		foreach ($load_gateways as $gateway) :
			
			$load_gateway = &new $gateway();
			
			if (isset($ordering[$load_gateway->id]) && is_numeric($ordering[$load_gateway->id])) :
				// Add in position
				$this->payment_gateways[$ordering[$load_gateway->id]] = $load_gateway;
			else :
				// Add to end of the array
				$this->payment_gateways[$order_end] = $load_gateway;
				$order_end++;
			endif;
			
		endforeach;
		
		ksort($this->payment_gateways);
		
		add_action('wpdeals_update_options_payment_gateways', array(&$this, 'process_admin_options'));
    	
    }

    function payment_gateways() {
		
		$_available_gateways = array();
		
		if (sizeof($this->payment_gateways) > 0) :
			foreach ( $this->payment_gateways as $gateway ) :
				
				$_available_gateways[$gateway->id] = $gateway;
				
			endforeach;
		endif;

		return $_available_gateways;
	}
	
	function get_available_payment_gateways() {
		
		$_available_gateways = array();
	
		foreach ( $this->payment_gateways as $gateway ) :
			
			if ($gateway->is_available()) $_available_gateways[$gateway->id] = $gateway;
			
		endforeach;

		return $_available_gateways;
	}
	
	function process_admin_options() {
		
		$default_gateway = (isset($_POST['default_gateway'])) ? esc_attr($_POST['default_gateway']) : '';
		$gateway_order = (isset($_POST['gateway_order'])) ? $_POST['gateway_order'] : '';
		
		$order = array();
		
		if (is_array($gateway_order) && sizeof($gateway_order)>0) :
			$loop = 0;
			foreach ($gateway_order as $gateway_id) :
				$order[$gateway_id] = $loop;
				$loop++;
			endforeach;
		endif;
		
		update_option( 'wpdeals_default_gateway', $default_gateway );
		update_option( 'wpdeals_gateway_order', $order );
		
	}
		
}
Return current item: WP Deals