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' ), 10 );
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
}
function admin_menu() {
add_submenu_page(
'dfrapi',
__( 'Configuration — Datafeedr API', 'datafeedr-api' ),
__( 'Configuration', 'datafeedr-api' ),
'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!', 'datafeedr-api' );
echo '
';
}
}
function output() {
echo '';
echo '
' . dfrapi_setting_pages( $this->page ) . ' — Datafeedr API
';
echo '';
echo '';
}
function load_settings() {
$this->options = (array) get_option( $this->key );
$this->options = array_merge(
array(
'access_id' => '',
'secret_key' => '',
'transport_method' => 'curl',
'disable_api' => 'no',
'zanox_connection_key' => '',
'zanox_secret_key' => '',
'amazon_access_key_id' => '',
'amazon_secret_access_key' => '',
'amazon_tracking_id' => '',
'amazon_locale' => 'us',
'ph_application_key' => '',
'ph_user_api_key' => '',
'ph_publisher_id' => '',
'effiliation_key' => '',
'awin_access_token' => '',
'affiliate_gateway_sid' => '',
'belboon_aid' => '',
'hs_beacon' => 'on',
),
$this->options
);
}
function register_settings() {
register_setting( $this->page, $this->key, array( $this, 'validate' ) );
add_settings_section( 'api_settings', __( 'Datafeedr API Settings', 'datafeedr-api' ), array( &$this, 'section_api_settings_desc' ), $this->page );
add_settings_field( 'access_id', __( 'API Access ID', 'datafeedr-api' ), array( &$this, 'field_access_id' ), $this->page, 'api_settings' );
add_settings_field( 'secret_key', __( 'API Secret Key', 'datafeedr-api' ), array( &$this, 'field_secret_key' ), $this->page, 'api_settings' );
// add_settings_field( 'transport_method', __( 'Transport Method', 'datafeedr-api' ), array( &$this, 'field_transport_method' ), $this->page, 'api_settings' );
/*
add_settings_field(
'disable_api',
__( 'Disable API', 'datafeedr-api' ),
array( &$this, 'field_disable_api' ),
$this->page,
'api_settings'
);
*/
add_settings_section( 'awin_settings', __( 'Awin Settings', 'datafeedr-api' ), array( &$this, 'section_awin_settings_desc' ), $this->page );
add_settings_field( 'awin_access_token', __( 'Awin API Token', 'datafeedr-api' ), array( &$this, 'field_awin_access_token' ), $this->page, 'awin_settings' );
add_settings_section( 'affiliate_gateway_settings', __( 'The Affiliate Gateway Settings', 'datafeedr-api' ), array( &$this, 'section_affiliate_gateway_settings_desc' ), $this->page );
add_settings_field( 'affiliate_gateway_sid', __( 'The Affiliate Gateway SID', 'datafeedr-api' ), array( &$this, 'field_affiliate_gateway_sid' ), $this->page, 'affiliate_gateway_settings' );
add_settings_section( 'belboon_settings', __( 'Belboon Settings', 'datafeedr-api' ), array( &$this, 'section_belboon_settings_desc' ), $this->page );
add_settings_field( 'belboon_aid', __( 'Adspace ID', 'datafeedr-api' ), array( &$this, 'field_belboon_aid' ), $this->page, 'belboon_settings' );
if ( defined( 'DFRCS_VERSION' ) ) {
add_settings_section( 'amazon_api_settings', __( 'Amazon Settings', 'datafeedr-api' ), array( &$this, 'section_amazon_api_settings_desc' ), $this->page );
add_settings_field( 'amazon_access_key_id', __( 'Amazon Access Key ID', 'datafeedr-api' ), array( &$this, 'field_amazon_access_key_id' ), $this->page, 'amazon_api_settings' );
add_settings_field( 'amazon_secret_access_key', __( 'Amazon Secret Access Key', 'datafeedr-api' ), array( &$this, 'field_amazon_secret_access_key' ), $this->page, 'amazon_api_settings' );
add_settings_field( 'amazon_tracking_id', __( 'Amazon Tracking ID', 'datafeedr-api' ), array( &$this, 'field_amazon_tracking_id' ), $this->page, 'amazon_api_settings' );
add_settings_field( 'amazon_locale', __( 'Amazon Locale', 'datafeedr-api' ), array( &$this, 'field_amazon_locale' ), $this->page, 'amazon_api_settings' );
}
add_settings_section( 'ph_api_settings', __( 'Partnerize Settings', 'datafeedr-api' ), array( &$this, 'section_ph_api_settings_desc' ), $this->page );
add_settings_field( 'ph_application_key', __( 'Application Key', 'datafeedr-api' ), array( &$this, 'field_ph_application_key' ), $this->page, 'ph_api_settings' );
add_settings_field( 'ph_user_api_key', __( 'User API Key', 'datafeedr-api' ), array( &$this, 'field_ph_user_api_key' ), $this->page, 'ph_api_settings' );
add_settings_field( 'ph_publisher_id', __( 'Publisher ID', 'datafeedr-api' ), array( &$this, 'field_ph_publisher_id' ), $this->page, 'ph_api_settings' );
add_settings_section( 'effiliation_api_settings', __( 'Effiliation Settings', 'datafeedr-api' ), array( &$this, 'section_effiliation_api_settings_desc' ), $this->page );
add_settings_field( 'effiliation_key', __( 'Effiliation Key', 'datafeedr-api' ), array( &$this, 'field_effiliation_key' ), $this->page, 'effiliation_api_settings' );
add_settings_section( 'hs_beacon_settings', __( 'Datafeedr Documentation & Support Link', 'datafeedr-api' ), array( &$this, 'section_hs_beacon_settings_desc' ), $this->page );
add_settings_field( 'hs_beacon_status', __( 'Enabled', 'datafeedr-api' ), array( &$this, 'field_hs_beacon_status' ), $this->page, 'hs_beacon_settings' );
}
function section_api_settings_desc() {
echo __( 'Add your ', 'datafeedr-api' );
echo ' ';
echo __( 'Datafeedr API Keys', 'datafeedr-api' );
echo '.';
}
function field_access_id() {
?>
';
echo __( 'Partnerize Keys', 'datafeedr-api' );
echo '.';
}
function field_ph_application_key() {
?>
';
echo __( 'Effiliation Key', 'datafeedr-api' );
echo '.';
}
function field_effiliation_key() {
?>
';
echo __( 'Learn how to find your Awin API Token', 'datafeedr-api' );
echo '.';
}
function field_awin_access_token() {
?>
';
echo __( 'Learn how to get your Affiliate Gateway SID', 'datafeedr-api' );
echo '.';
}
function field_affiliate_gateway_sid() {
?>
';
echo __( 'Learn how to get your Belboon Adspace ID', 'datafeedr-api' );
echo '.';
}
function field_belboon_aid() {
?>
options['disable_api'], 'yes', true ); ?> />
options['disable_api'], 'no', true ); ?> />
';
echo __( 'Amazon Product Advertising API keys', 'datafeedr-api' );
echo '.';
echo '
';
echo __( 'These are ONLY compatible with the Datafeedr Comparison Sets plugin.', 'datafeedr-api' );
echo '';
}
function field_amazon_access_key_id() {
?>
.
options['hs_beacon'], 'on', true ); ?> />
options['hs_beacon'], 'off', true ); ?> />
$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 "disable_api"
if ( $key == 'disable_api' ) {
$new_input['disable_api'] = trim( $value );
}
// Validate Amazon Access Key ID
if ( $key == 'amazon_access_key_id' ) {
$new_input['amazon_access_key_id'] = trim( $value );
}
// Validate Amazon Secret Access Key
if ( $key == 'amazon_secret_access_key' ) {
$new_input['amazon_secret_access_key'] = trim( $value );
}
// Validate Amazon Tracking ID
if ( $key == 'amazon_tracking_id' ) {
$new_input['amazon_tracking_id'] = trim( $value );
}
// Validate Amazon Locale
if ( $key == 'amazon_locale' ) {
$new_input['amazon_locale'] = trim( $value );
}
// Validate PH Application Key
if ( $key == 'ph_application_key' ) {
$new_input['ph_application_key'] = trim( $value );
}
// Validate PH User API Key
if ( $key == 'ph_user_api_key' ) {
$new_input['ph_user_api_key'] = trim( $value );
}
// Validate PH Publisher Key
if ( $key == 'ph_publisher_id' ) {
$new_input['ph_publisher_id'] = trim( $value );
}
// Validate Effiliation Key
if ( $key == 'effiliation_key' ) {
$new_input['effiliation_key'] = trim( $value );
}
// Validate Awin Acceess Token
if ( $key == 'awin_access_token' ) {
$new_input['awin_access_token'] = trim( $value );
}
// Validate The Affiliate Gateway SID
if ( $key == 'affiliate_gateway_sid' ) {
$new_input['affiliate_gateway_sid'] = trim( $value );
}
// Validate Belboon AID
if ( $key == 'belboon_aid' ) {
$new_input['belboon_aid'] = trim( $value );
}
// Enable HelpScout Beacon
if ( $key == 'hs_beacon' ) {
$new_input['hs_beacon'] = ( 'on' == $value ) ? 'on' : 'off';
}
} // foreach
// Override setting so it's always enabled.
$new_input['disable_api'] = trim( 'no' );
return $new_input;
}
} // class Dfrapi_Configuration
} // class_exists check