diff --git a/inc/class-wooviet-admin-page.php b/inc/class-wooviet-admin-page.php new file mode 100644 index 0000000..6c9d500 --- /dev/null +++ b/inc/class-wooviet-admin-page.php @@ -0,0 +1,163 @@ + WooCommerce -> WooCommerce for Vietnam + * + * @author htdat + * @since 1.0 + * + */ +class WooViet_Admin_Page { + + var $message = ''; + + public function __construct() { + + if (isset($_REQUEST['wooviet_nonce']) && isset ($_REQUEST['action']) && 'wooviet_save_settings' == $_REQUEST['action']) + $this->save_settings(); + + add_action('admin_menu', array($this, 'register_submenu_page')); + + } + + public function register_submenu_page() { + add_submenu_page( + 'woocommerce', + 'WooCommerce for Vietnam Settings', + 'WooCommerce for Vietnam', + 'manage_options', + 'woocommerce-for-vietnam', + array( $this, 'admin_page_html' ) + ); + } + + public function save_settings(){ + if ( wp_verify_nonce( $_REQUEST['wooviet_nonce'], 'wooviet_save_settings') ){ + update_option('woocommerce-for-vietnam', $_REQUEST['settings']); + + $this->message = + '
' . + __('Settings saved', 'woocommerce-for-vietnam') . + '
' . + __('Please refresh this page. Can not save settings!', 'woocommerce-for-vietnam') . + '