Don't download GeoIP Database until geolocation option is enabled in settings.

This commit is contained in:
Mike Jolley 2015-02-18 12:53:24 +00:00
parent b6e7e4e8ad
commit 470b259a8a
3 changed files with 34 additions and 15 deletions

View File

@ -46,6 +46,7 @@ return apply_filters( 'woocommerce_tax_settings', array(
'title' => __( 'Default Customer Address:', 'woocommerce' ),
'id' => 'woocommerce_default_customer_address',
'desc_tip' => __( 'This option determines the customers default address (before they input their details).', 'woocommerce' ),
'desc' => sprintf( __( 'Note: If you choose to Geolocate the user address, the %sMaxMind GeoLite Database%s will be periodically downloaded and stored in your wp-content directory.', 'woocommerce' ), '<a href="http://dev.maxmind.com/geoip/legacy/geolite/">', '</a>' ),
'default' => 'geolocation',
'type' => 'select',
'class' => 'wc-enhanced-select',
@ -78,7 +79,7 @@ return apply_filters( 'woocommerce_tax_settings', array(
array(
'title' => __( 'Additional Tax Classes', 'woocommerce' ),
'desc' => __( 'List additional tax classes below (1 per line). This is in addition to the default <code>Standard Rate</code>. Tax classes can be assigned to products.', 'woocommerce' ),
'desc_tip' => __( 'List additional tax classes below (1 per line). This is in addition to the default "Standard Rate".', 'woocommerce' ),
'id' => 'woocommerce_tax_classes',
'css' => 'width:100%; height: 65px;',
'type' => 'textarea',
@ -86,7 +87,7 @@ return apply_filters( 'woocommerce_tax_settings', array(
),
array(
'title' => __( 'Display prices in the shop:', 'woocommerce' ),
'title' => __( 'Display Prices in the Shop:', 'woocommerce' ),
'id' => 'woocommerce_tax_display_shop',
'default' => 'excl',
'type' => 'select',
@ -98,15 +99,7 @@ return apply_filters( 'woocommerce_tax_settings', array(
),
array(
'title' => __( 'Price display suffix:', 'woocommerce' ),
'id' => 'woocommerce_price_display_suffix',
'default' => '',
'type' => 'text',
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'woocommerce' ),
),
array(
'title' => __( 'Display prices during cart/checkout:', 'woocommerce' ),
'title' => __( 'Display Prices During Cart and Checkout:', 'woocommerce' ),
'id' => 'woocommerce_tax_display_cart',
'default' => 'excl',
'type' => 'select',
@ -119,7 +112,16 @@ return apply_filters( 'woocommerce_tax_settings', array(
),
array(
'title' => __( 'Display tax totals:', 'woocommerce' ),
'title' => __( 'Price Display Suffix:', 'woocommerce' ),
'id' => 'woocommerce_price_display_suffix',
'default' => '',
'placeholder' => __( 'N/A', 'woocommerce' ),
'type' => 'text',
'desc_tip' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: {price_including_tax}, {price_excluding_tax}.', 'woocommerce' ),
),
array(
'title' => __( 'Display Tax Totals:', 'woocommerce' ),
'id' => 'woocommerce_tax_total_display',
'default' => 'itemized',
'type' => 'select',

View File

@ -4,7 +4,7 @@
*
* Handles geolocation and updating the geolocation database.
*
* This product uses GeoLite2 data created by MaxMind, available from http://www.maxmind.com
* This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com.
*
* @author WooThemes
* @category Admin
@ -45,8 +45,24 @@ class WC_Geolocation {
* Hook in tabs.
*/
public static function init() {
add_action( 'woocommerce_geoip_updater', array( __CLASS__, 'update_database' ) );
add_action( 'woocommerce_installed', array( __CLASS__, 'update_database' ) );
// Only download the database from MaxMind if the geolocation function is enabled, or a plugin specifically requests it
if ( 'geolocation' === get_option( 'woocommerce_default_customer_address' ) || apply_filters( 'woocommerce_geolocation_update_database_periodically', false ) ) {
add_action( 'woocommerce_geoip_updater', array( __CLASS__, 'update_database' ) );
}
add_filter( 'pre_update_option_woocommerce_default_customer_address', array( __CLASS__, 'maybe_update_database' ), 10, 2 );
}
/**
* Maybe trigger a DB update for the first time
* @param string $new_value
* @param string $old_value
* @return string
*/
public static function maybe_update_database( $new_value, $old_value ) {
if ( $new_value !== $old_value && 'geolocation' === $new_value ) {
self::update_database();
}
return $new_value;
}
/**

View File

@ -139,6 +139,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
* Tweak - Improve category coupon message.
* Tweak - Don't download GeoIP Database until geolocation option is enabled in settings.
= 2.3.4 - 17/02/2015 =
* Fix - limit_usage_to_x_items option in coupons.