key = 'dfrapi_account'; add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ), 70 ); add_action( 'init', array( $this, 'load_settings' ) ); } function load_settings() { $this->options = (array) get_option( $this->key ); if ( isset( $this->options[0] ) && empty( $this->options[0] ) ) { $this->options = $status = dfrapi_api_get_status(); if ( !array_key_exists( 'dfrapi_api_error', $status ) ) { update_option( $this->key, $status ); } } } function admin_menu() { add_submenu_page( 'dfrapi', __( 'Account — Datafeedr API', 'datafeedr-api' ), __( 'Account', 'datafeedr-api' ), 'manage_options', $this->key, array( $this, 'output' ) ); } function output() { echo '
'; echo '

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

'; settings_fields( $this->page ); do_settings_sections( $this->page); echo '
'; } function register_settings() { register_setting( $this->page, $this->key, array( $this, 'validate' ) ); // Current Plan add_settings_section( 'current_plan', __( 'Current Plan', 'datafeedr-api' ), array( &$this, 'section_current_plan_desc' ), $this->page ); // Only show the following if there is no Error. if ( !array_key_exists( 'dfrapi_api_error', $this->options ) ) { // Current Usage add_settings_section( 'current_usage', __( 'Current Usage', 'datafeedr-api' ), array( &$this, 'section_current_usage_desc' ), $this->page ); } // Account Links add_settings_section( 'account', __( 'Account Links', 'datafeedr-api' ), array( &$this, 'section_account_desc' ), $this->page ); } function section_current_plan_desc() { $plans = dfrapi_get_membership_plans(); $plan_name = ''; if ( $this->options['plan_id'] > 0 ) { $plan_name .= $plans[$this->options['plan_id']]; if ( $this->options['plan_id'] != 10250000 ) { $plan_name .= ' ('; $plan_name .= '' . __( 'Upgrade', 'datafeedr-api' ) . ''; $plan_name .= ')'; } } else { $plan_name .= ''; $plan_name .= __( 'None', 'datafeedr-api' ); $plan_name .= ' ('; $plan_name .= '' . __( 'Reactivate your subscription', 'datafeedr-api' ) . ''; $plan_name .= ')'; } echo ' '; if ( !array_key_exists( 'dfrapi_api_error', $this->options ) ) { echo ' '; } echo '
' . __( 'Plan name', 'datafeedr-api' ) . ' ' . $plan_name . '
' . __( 'Requests per month (RPM)', 'datafeedr-api' ) . ' ' . number_format( $this->options['max_requests'] ) . '
' . __( 'Products per request (PPR)', 'datafeedr-api' ) . ' ' . number_format( $this->options['max_length'] ) . '
'; } function section_current_usage_desc() { echo '

'; _e( 'View your current API usage, number of API requests remaining and reset date', 'datafeedr-api' ); echo ' ' . __( 'here', 'datafeedr-api' ) . '.'; echo '

'; } function section_account_desc() { echo '

' . __( 'View your Datafeedr account', 'datafeedr-api' ) . '

'; echo '

' . __( 'Upgrade your plan', 'datafeedr-api' ) . '

'; } function validate( $input ) { return $input; } } // class Dfrapi_Account } // class_exists check