array( 'enabled' => 'yes', ), 'change_currency_symbol' => array( 'enabled' => 'yes', 'text' => 'VND', ), 'convert_price' => array( 'enabled' => 'yes', 'text' => 'K', ), 'vnd_paypal_standard' => array( 'enabled' => 'yes', 'currency' => 'USD', 'rate' => '22770', ), ); /** * The properties to manage all classes under the "inc/" folder * Example: * - File name: class-wooviet-provinces.php * - Class Name: \WooViet_Provinces * - Method Name: WooViet->Provinces */ protected $Provinces; protected $Currency; protected $VND_PayPal_Standard; protected $Admin_Page; /** * Setup class. * * @since 1.0 */ public function __construct() { add_action( 'init', array( $this, 'init' ) ); } /** * Throw a notice if WooCommerce is NOT active */ public function notice_if_not_woocommerce() { $class = 'notice notice-error'; $message = __( 'Woo Viet is not running because WooCommerce is not active. Please activate both plugins', 'woo-viet' ); printf( '

%2$s

', $class, $message ); } /** * Run this method under the "init" action */ public function init() { // Load the localization feature $this->i18n(); if ( class_exists( 'WooCommerce' ) ) { // Run this plugin normally if WooCommerce is active $this->main(); } else { // Throw a notice if WooCommerce is NOT active add_action( 'admin_notices', array( $this, 'notice_if_not_woocommerce' ) ); } } /** * Localize the plugin * @since 1.0 */ public function i18n() { load_plugin_textdomain( 'freshfunbits', false, basename( dirname( __FILE__ ) ) . '/languages/' ); } /** * The main method to load the components */ public function main() { if ( is_admin() ) { // Add the admin setting page include( WOO_VIET_DIR . 'inc/class-wooviet-admin-page.php' ); $this->Admin_Page = new WooViet_Admin_Page(); } $settings = self::get_settings(); // Check if "Add provinces for Vietnam " is enabled. if ( 'yes' == $settings['add_province']['enabled'] ) { include( WOO_VIET_DIR . 'inc/class-wooviet-provinces.php' ); $this->Provinces = new WooViet_Provinces(); } include( WOO_VIET_DIR . 'inc/class-wooviet-currency.php' ); $this->Currency = new WooViet_Currency(); // Check if "Change VND currency symbol" is enabled if ( 'yes' == $settings['change_currency_symbol']['enabled'] ) { $this->Currency->change_currency_symbol( $settings['change_currency_symbol']['text'] ); } // Check if "Convert 000 of prices to K (or anything)" is enabled if ( 'yes' == $settings['convert_price']['enabled'] ) { $this->Currency->convert_price_thousand_to_k( $settings['convert_price']['text'] ); } // Check if "Support VND for the PayPal Standard gateway" is enabled if ( 'yes' == $settings['vnd_paypal_standard']['enabled'] ) { include( WOO_VIET_DIR . 'inc/class-wooviet-vnd-paypal-standard.php' ); $this->VND_PayPal_Standard = new WooViet_VND_PayPal_Standard( $settings['vnd_paypal_standard']['rate'], $settings['vnd_paypal_standard']['currency'] ); } } /** * The wrapper method to get the settings of the plugin * @return array */ static function get_settings() { return get_option( 'woo-viet', self::$default_settings ); } }