From def805022d741b3d9b0a1a800be7cbfe684a89a7 Mon Sep 17 00:00:00 2001 From: htdat Date: Sun, 26 Feb 2017 15:56:45 +0700 Subject: [PATCH] Add the new option "add_city" and better manage the options when upgrading --- woo-viet.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/woo-viet.php b/woo-viet.php index 237d540..e6b5ca8 100644 --- a/woo-viet.php +++ b/woo-viet.php @@ -7,7 +7,7 @@ * Author URI: https://profiles.wordpress.org/htdat * Text Domain: woo-viet * Domain Path: /languages - * Version: 1.2 + * Version: 1.2-dev * License: GPLv2+ */ @@ -40,6 +40,10 @@ class WooViet { array( 'enabled' => 'yes', ), + 'add_city' => + array( + 'enabled' => 'yes', + ), 'change_currency_symbol' => array( 'enabled' => 'yes', @@ -133,6 +137,12 @@ class WooViet { if ( 'yes' == $settings['add_province']['enabled'] ) { include( WOO_VIET_DIR . 'inc/class-wooviet-provinces.php' ); $this->Provinces = new WooViet_Provinces(); + + // Enable "Add cities for Vietnam" if the province option is selected. + if ( 'yes' == $settings['add_city']['enabled'] ) { + include( WOO_VIET_DIR . 'inc/class-wooviet-cities.php' ); + new WooViet_Cities(); + } } include( WOO_VIET_DIR . 'inc/class-wooviet-currency.php' ); @@ -165,7 +175,9 @@ class WooViet { * @return array */ static function get_settings() { - return get_option( 'woo-viet', self::$default_settings ); + $settings = get_option( 'woo-viet', self::$default_settings ); + $settings = wp_parse_args( $settings, self::$default_settings ); + return $settings; } } \ No newline at end of file