WooCommerce Code Reference

Search results

WC_Integration_MaxMind_Geolocation extends WC_Integration

WC Integration MaxMind Geolocation

Extended by individual integrations to offer additional functionality.

Table of Contents

$database_service The service responsible for interacting with the MaxMind database. WC_Integration_MaxMind_Database_Service
$enabled Yes or no based on whether the integration is enabled. string
$method_title Integration title. string
$method_description Integration description. string
$plugin_id The plugin ID. Used for option names. string
$id ID of the class extending the settings API. Used in option names. string
$errors Validation errors. array
$settings Setting values. array
$form_fields Form option fields. array
$data The posted settings data. When empty, $_POST data will be used. array
__construct() Initialize the integration. mixed
admin_options() Override the normal options so we can print the database file path to the admin, mixed
init_form_fields() Initializes the settings fields. mixed
get_database_service() Get database service. WC_Integration_MaxMind_Database_Service|null
validate_license_key_field() Checks to make sure that the license key is valid. mixed
update_database() Updates the database used for geolocation queries. mixed
get_geolocation() Performs a geolocation lookup against the MaxMind database for the given IP address. array
get_database_prefix() Fetches the prefix for the MaxMind database file. string
add_missing_license_key_notice() Add missing license key notice. mixed
remove_missing_license_key_notice() Remove missing license key notice. mixed
display_missing_license_key_notice() Display notice if license key is missing. mixed
get_method_title() Return the title for admin screens. string
get_method_description() Return the description for admin screens. string
admin_options() Output the admin options table. mixed
init_settings() Initialise Settings. mixed
get_form_fields() Get the form fields after they are initialized. array
set_defaults() Set default required properties for each field. array
init_form_fields() Initialise settings form fields. mixed
get_option_key() Return the name of the option in the WP DB. string
get_field_type() Get a fields type. Defaults to "text" if not set. string
get_field_default() Get a fields default value. Defaults to "" if not set. string
get_field_value() Get a field's posted and validated value. string
set_post_data() Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array. mixed
get_post_data() Returns the POSTed data, to be used to save the settings. array
update_option() Update a single option. bool
process_admin_options() Processes and saves options. bool
add_error() Add an error message for display in admin on save. mixed
get_errors() Get admin error messages. mixed
display_errors() Display admin error messages. mixed
get_option() Get option from DB. string
get_field_key() Prefix key for settings. string
generate_settings_html() Generate Settings HTML. string
get_tooltip_html() Get HTML for tooltips. string
get_description_html() Get HTML for descriptions. string
get_custom_attribute_html() Get custom attributes. string
generate_text_html() Generate Text Input HTML. string
generate_price_html() Generate Price Input HTML. string
generate_decimal_html() Generate Decimal Input HTML. string
generate_password_html() Generate Password Input HTML. string
generate_color_html() Generate Color Picker Input HTML. string
generate_textarea_html() Generate Textarea HTML. string
generate_checkbox_html() Generate Checkbox HTML. string
generate_select_html() Generate Select HTML. string
generate_multiselect_html() Generate Multiselect HTML. string
generate_title_html() Generate Title HTML. string
validate_text_field() Validate Text Field. string
validate_price_field() Validate Price Field. string
validate_decimal_field() Validate Decimal Field. string
validate_password_field() Validate Password Field. No input sanitization is used to avoid corrupting passwords. string
validate_textarea_field() Validate Textarea Field. string
validate_checkbox_field() Validate Checkbox Field. string
validate_select_field() Validate Select Field. string
validate_multiselect_field() Validate Multiselect Field. string|array
validate_settings_fields() Validate the data on the "Settings" form. mixed
format_settings() Format settings if needed. array

Properties

Methods

validate_license_key_field()

Checks to make sure that the license key is valid.

public validate_license_key_field( $key : string , $value : mixed ) : mixed
Parameters
$key : string

The key of the field.

$value : mixed

The value of the field.

Tags
throws

When the license key is invalid.

Return values
mixed

update_database()

Updates the database used for geolocation queries.

public update_database( [ $new_database_path : string|null = null ] ) : mixed
Parameters
$new_database_path : string|null = null

The path to the new database file. Null will fetch a new archive.

Return values
mixed

get_geolocation()

Performs a geolocation lookup against the MaxMind database for the given IP address.

public get_geolocation( $data : array , $ip_address : string ) : array
Parameters
$data : array

Geolocation data.

$ip_address : string

The IP address to geolocate.

Return values
array

Geolocation including country code, state, city and postcode based on an IP address.

display_missing_license_key_notice()

Display notice if license key is missing.

public display_missing_license_key_notice( $old_value : mixed , $new_value : mixed ) : mixed
Parameters
$old_value : mixed

Option old value.

$new_value : mixed

Current value.

Return values
mixed

get_method_title()

Return the title for admin screens.

public get_method_title( ) : string
Return values
string

get_method_description()

Return the description for admin screens.

public get_method_description( ) : string
Return values
string

init_settings()

Initialise Settings.

public init_settings( ) : mixed

Store all settings in a single database entry and make sure the $settings array is either the default or the settings stored in the database.

Tags
since
uses

get_option(), add_option()

Return values
mixed

get_form_fields()

Get the form fields after they are initialized.

public get_form_fields( ) : array
Return values
array

of options

set_defaults()

Set default required properties for each field.

protected set_defaults( $field : array ) : array
Parameters
$field : array

Setting field array.

Return values
array

init_form_fields()

Initialise settings form fields.

public init_form_fields( ) : mixed

Add an array of fields to be displayed on the gateway's settings screen.

Tags
since
Return values
mixed

get_option_key()

Return the name of the option in the WP DB.

public get_option_key( ) : string
Tags
since
Return values
string

get_field_type()

Get a fields type. Defaults to "text" if not set.

public get_field_type( $field : array ) : string
Parameters
$field : array

Field key.

Return values
string

get_field_default()

Get a fields default value. Defaults to "" if not set.

public get_field_default( $field : array ) : string
Parameters
$field : array

Field key.

Return values
string

get_field_value()

Get a field's posted and validated value.

public get_field_value( $key : string , $field : array [, $post_data : array = array() ] ) : string
Parameters
$key : string

Field key.

$field : array

Field array.

$post_data : array = array()

Posted data.

Return values
string

set_post_data()

Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.

public set_post_data( [ $data : array = array() ] ) : mixed
Parameters
$data : array = array()

Posted data.

Return values
mixed

get_post_data()

Returns the POSTed data, to be used to save the settings.

public get_post_data( ) : array
Return values
array

update_option()

Update a single option.

public update_option( $key : string [, $value : mixed = '' ] ) : bool
Parameters
$key : string

Option key.

$value : mixed = ''

Value to set.

Tags
since
Return values
bool

was anything saved?

process_admin_options()

Processes and saves options.

public process_admin_options( ) : bool

If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.

Return values
bool

was anything saved?

add_error()

Add an error message for display in admin on save.

public add_error( $error : string ) : mixed
Parameters
$error : string

Error message.

Return values
mixed

get_option()

Get option from DB.

public get_option( $key : string [, $empty_value : mixed = null ] ) : string

Gets an option from the settings API, using defaults if necessary to prevent undefined notices.

Parameters
$key : string

Option key.

$empty_value : mixed = null

Value when empty.

Return values
string

The value specified for the option or a default value for the option.

get_field_key()

Prefix key for settings.

public get_field_key( $key : string ) : string
Parameters
$key : string

Field key.

Return values
string

generate_settings_html()

Generate Settings HTML.

public generate_settings_html( [ $form_fields : array = array() ] [, $echo : bool = true ] ) : string

Generate the HTML for the fields on the "settings" screen.

Parameters
$form_fields : array = array()

(default: array()) Array of form fields.

$echo : bool = true

Echo or return.

Tags
since
uses
Return values
string

the html for the settings

get_tooltip_html()

Get HTML for tooltips.

public get_tooltip_html( $data : array ) : string
Parameters
$data : array

Data for the tooltip.

Return values
string

get_description_html()

Get HTML for descriptions.

public get_description_html( $data : array ) : string
Parameters
$data : array

Data for the description.

Return values
string

get_custom_attribute_html()

Get custom attributes.

public get_custom_attribute_html( $data : array ) : string
Parameters
$data : array

Field data.

Return values
string

generate_text_html()

Generate Text Input HTML.

public generate_text_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_price_html()

Generate Price Input HTML.

public generate_price_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_decimal_html()

Generate Decimal Input HTML.

public generate_decimal_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_password_html()

Generate Password Input HTML.

public generate_password_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_color_html()

Generate Color Picker Input HTML.

public generate_color_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_textarea_html()

Generate Textarea HTML.

public generate_textarea_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_checkbox_html()

Generate Checkbox HTML.

public generate_checkbox_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_select_html()

Generate Select HTML.

public generate_select_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_multiselect_html()

Generate Multiselect HTML.

public generate_multiselect_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

generate_title_html()

Generate Title HTML.

public generate_title_html( $key : string , $data : array ) : string
Parameters
$key : string

Field key.

$data : array

Field data.

Tags
since
Return values
string

validate_text_field()

Validate Text Field.

public validate_text_field( $key : string , $value : string ) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_price_field()

Validate Price Field.

public validate_price_field( $key : string , $value : string ) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_decimal_field()

Validate Decimal Field.

public validate_decimal_field( $key : string , $value : string ) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_password_field()

Validate Password Field. No input sanitization is used to avoid corrupting passwords.

public validate_password_field( $key : string , $value : string ) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_textarea_field()

Validate Textarea Field.

public validate_textarea_field( $key : string , $value : string ) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_checkbox_field()

Validate Checkbox Field.

public validate_checkbox_field( $key : string , $value : string ) : string

If not set, return "no", otherwise return "yes".

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_select_field()

Validate Select Field.

public validate_select_field( $key : string , $value : string ) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_multiselect_field()

Validate Multiselect Field.

public validate_multiselect_field( $key : string , $value : string ) : string|array
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string|array

validate_settings_fields()

Validate the data on the "Settings" form.

public validate_settings_fields( [ $form_fields : array = array() ] ) : mixed
Parameters
$form_fields : array = array()

Array of fields.

Tags
deprecated

No longer used.

Return values
mixed

format_settings()

Format settings if needed.

public format_settings( $value : array ) : array
Parameters
$value : array

Value to format.

Tags
deprecated

Unused.

Return values
array
Back to the top