key = 'dfrapi_configuration'; $this->account = (array) get_option( 'dfrapi_account', array( 'max_length' => 50 ) ); add_action( 'init', array( &$this, 'load_settings' ) ); add_action( 'admin_init', array( &$this, 'register_settings' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'admin_notices', array( $this, 'admin_notice' ) ); } function admin_menu() { add_submenu_page( 'dfrapi', __( 'Configuration — Datafeedr API', DFRAPI_DOMAIN ), __( 'Configuration', DFRAPI_DOMAIN ), 'manage_options', 'dfrapi', array( $this, 'output' ) ); } function admin_notice() { if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == true && isset( $_GET['page'] ) && 'dfrapi' == $_GET['page'] ) { echo '

'; _e( 'Configuration successfully updated!', DFRAPI_DOMAIN ); echo '

'; } } function output() { echo '
'; echo '

' . dfrapi_setting_pages( $this->page ) . ' — Datafeedr API

'; echo '
'; wp_nonce_field( 'update-options' ); settings_fields( $this->page ); do_settings_sections( $this->page); submit_button(); echo '
'; echo '
'; } function load_settings() { $this->options = (array) get_option( $this->key ); $this->options = array_merge( array( 'access_id' => '', 'secret_key' => '', 'transport_method' => 'curl', 'zanox_connection_key' => '', 'zanox_secret_key' => '', ), $this->options ); } function register_settings() { register_setting( $this->page, $this->key, array( $this, 'validate' ) ); add_settings_section( 'api_settings', __( 'Datafeedr API Settings', DFRAPI_DOMAIN ), array( &$this, 'section_api_settings_desc' ), $this->page ); add_settings_field( 'access_id', __( 'API Access ID', DFRAPI_DOMAIN ), array( &$this, 'field_access_id' ), $this->page, 'api_settings' ); add_settings_field( 'secret_key', __( 'API Secret Key', DFRAPI_DOMAIN ), array( &$this, 'field_secret_key' ), $this->page, 'api_settings' ); add_settings_field( 'transport_method', __( 'Transport Method', DFRAPI_DOMAIN ), array( &$this, 'field_transport_method' ), $this->page, 'api_settings' ); add_settings_section( 'zanox_api_settings', __( 'Zanox Settings', DFRAPI_DOMAIN ), array( &$this, 'section_zanox_api_settings_desc' ), $this->page ); add_settings_field( 'zanox_connection_key', __( 'Connection Key', DFRAPI_DOMAIN ), array( &$this, 'field_zanox_connection_key' ), $this->page, 'zanox_api_settings' ); add_settings_field( 'zanox_secret_key', __( 'Secret Key', DFRAPI_DOMAIN ), array( &$this, 'field_zanox_secret_key' ), $this->page, 'zanox_api_settings' ); } function section_api_settings_desc() { echo __( 'Add your ', DFRAPI_DOMAIN ); echo ' '; echo __( 'Datafeedr API Keys', DFRAPI_DOMAIN ); echo '.'; } function field_access_id() { ?> '; echo __( 'Zanox Keys', DFRAPI_DOMAIN ); echo '.'; } function field_zanox_connection_key() { ?>

$value ) { // Validate "access_id" if ( $key == 'access_id' ) { $new_input['access_id'] = trim( $value ); } // Validate "secret_key" if ( $key == 'secret_key' ) { $new_input['secret_key'] = trim( $value ); } // Validate "transport_method" if ( $key == 'transport_method' ) { $new_input['transport_method'] = trim( $value ); } // Validate "zanox_connection_key" if ( $key == 'zanox_connection_key' ) { $new_input['zanox_connection_key'] = trim( $value ); } // Validate "zanox_secret_key" if ( $key == 'zanox_secret_key' ) { $new_input['zanox_secret_key'] = trim( $value ); } } // foreach return $new_input; } } // class Dfrapi_Configuration } // class_exists check