*/
class apptivo_ecommerce_payment_gateway {
var $id;
var $title;
var $enabled;
var $icon;
var $description;
var $plugin_id = 'apptivo_ecommerce_';
var $settings = array();
var $form_fields = array();
var $sanitized_fields = array();
function is_available() {
if ($this->enabled=="yes") :
return true;
endif;
return false;
}
function icon() {
global $apptivo_ecommerce;
if ($this->icon) :
return '';
endif;
}
function admin_options() {}
function process_payment() {}
function validate_fields() { return true; }
public function process_admin_options() {
$this->validate_settings_fields();
update_option( $this->plugin_id . $this->id . '_settings', $this->sanitized_fields );
}
function init_settings () {
if ( ! is_array( $this->settings ) ) { return; }
$settings = array();
$existing_settings = get_option( $this->plugin_id . $this->id . '_settings' );
$defaults = array();
foreach ( $this->form_fields as $k => $v ) {
if ( isset( $v['default'] ) ) {
$defaults[$k] = $v['default'];
} else {
$defaults[$k] = '';
}
}
if ( ! $existing_settings ) {
$existing_settings = $defaults;
} else {
// Prevent "undefined index" errors.
foreach ( $existing_settings as $k => $v ) {
if ( ! isset( $existing_settings[$k] ) ) {
$existing_settings[$k] = $v;
}
}
}
$this->settings = $existing_settings;
if ( isset( $this->settings['enabled'] ) && ( $this->settings['enabled'] == 'yes' ) ) { $this->enabled = 'yes'; }
} // End init_settings()
function generate_settings_html () {
$html = '';
foreach ( $this->form_fields as $k => $v ) {
if ( ! isset( $v['type'] ) || ( $v['type'] == '' ) ) { $v['type'] == 'text'; } // Default to "text" field type.
if ( method_exists( $this, 'generate_' . $v['type'] . '_html' ) ) {
$html .= $this->{'generate_' . $v['type'] . '_html'}( $k, $v );
}
}
echo $html;
}
function generate_text_html ( $key, $data ) {
$html = '';
if ( isset( $data['title'] ) && $data['title'] != '' ) { $title = $data['title']; }
$html .= '