key = 'dfrapi_networks';
$this->all_networks = dfrapi_api_get_all_networks();
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 api_errors() {
if ( array_key_exists( 'dfrapi_api_error', $this->all_networks ) ) {
return $this->all_networks;
}
return false;
}
function admin_menu() {
add_submenu_page(
'dfrapi',
__( 'Networks', DFRAPI_DOMAIN ),
__( 'Networks', DFRAPI_DOMAIN ),
'manage_options',
$this->key,
array( $this, 'output' )
);
}
function admin_notice() {
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == true && isset( $_GET['page'] ) && $this->key == $_GET['page'] ) {
echo '
';
_e( 'Networks successfully updated!', DFRAPI_DOMAIN );
echo '
';
}
}
function output() {
echo '';
echo '
' . dfrapi_setting_pages( $this->page ) . '
';
if ( $errors = $this->api_errors() ) {
echo dfrapi_html_output_api_error( $errors );
} else {
echo '
';
}
echo '
' . __( 'You have unsaved changes', DFRAPI_DOMAIN ) . '
';
echo '
';
}
function load_settings() {
$this->options = (array) get_option( $this->key );
$this->options = array_merge( array(
'ids' => array(),
), $this->options );
}
function register_settings() {
register_setting( $this->page, $this->key, array( $this, 'validate' ) );
add_settings_section( 'networks', __( 'Select Networks', DFRAPI_DOMAIN ), array( &$this, 'section_networks_desc' ), $this->page );
add_settings_field( 'ids', __( 'Networks', DFRAPI_DOMAIN ), array( &$this, 'field_network_ids' ), $this->page, 'networks', array( 'label_for' => 'DFRAPI_HIDE_LABEL' ) );
}
function section_networks_desc() {
echo __( 'Select the affiliate networks that you belong to and enter your affiliate ID for each.', DFRAPI_DOMAIN );
}
function field_network_ids() {
$groups = $this->get_network_group_names();
foreach ( $groups as $group ) {
$num_networks_checked_in_group = $this->num_networks_checked_in_group( $group );
$active = ( $num_networks_checked_in_group != '' ) ? 'active' : '';
echo '
' . $group . '
' . $this->num_missing_affiliate_ids_in_group( $group ) . '
' . $num_networks_checked_in_group . '
' . $this->num_networks_in_group( $group ) . '
' . $this->num_merchants_in_group( $group ) . '
' . $this->num_products_in_group( $group ) . '
' . $this->get_groups_networks( $group ) . '
';
}
}
function get_groups_networks( $group_name ) {
$html = '
';
return $html;
}
function get_network_group_names() {
$networks = $this->all_networks;
$groups = array();
foreach ( $networks as $network ) {
$groups[] = $network['group'];
}
return array_unique( $groups );
}
/**
* This returns