From 3d135ac02aba4a6a2a10ad2bcf96b19e90460cdc Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Sun, 1 Jan 2017 00:36:22 +0700 Subject: [PATCH] Add: The class to create the admin page under wp-admin -> WooCommerce -> WooCommerce for Vietnam --- inc/class-wooviet-admin-page.php | 163 +++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 inc/class-wooviet-admin-page.php 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') . + '

' + ; + + } else { + + $this->message = + '

' . + __('Please refresh this page. Can not save settings!', 'woocommerce-for-vietnam') . + '

' + ; + } + } + public function admin_page_html() { + // check user capabilities + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + + $settings = WooViet::get_settings(); + //var_dump($settings); exit; + + + ?> +
+

+
+ message ?> + + + + + + + + + + + + + + + + + + + + + + +
+ + > + +
+ + > + +
+
+ + +
000 of prices to K (or anything)', 'woocommerce-for-vietnam')?> + + > + + +

+ + +
+
the Paypal Standard gateway','woocommerce-for-vietnam'), 'https://docs.woocommerce.com/document/paypal-standard/') ?> + + > + + +

+ + +
+
+ + +
+ +
+ +

+ +

+ +
+