/** * Render the sub-menu page for 'CSV Export' * * @since 3.0 */ public function render_submenu_pages() { // permissions check if (!current_user_can('manage_woocommerce')) { return; } $this->tabs = array('export' => __('Export', WC_Customer_Order_CSV_Export::TEXT_DOMAIN), 'settings' => __('Settings', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); $current_tab = empty($_GET['tab']) ? 'export' : urldecode($_GET['tab']); // settings if (!empty($_POST) && 'settings' == $current_tab) { // security check if (!wp_verify_nonce($_POST['_wpnonce'], __FILE__)) { wp_die(__('Action failed. Please refresh the page and retry.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); } if (isset($_POST['wc_customer_order_csv_export_test_method'])) { // process test $export = new WC_Customer_Order_CSV_Export_Handler(0); $result = $export->test_export_via($_POST['wc_customer_order_csv_export_test_method']); $this->message_handler->add_message($result); } else { $orig_start_inverval = get_option('wc_customer_order_csv_export_auto_export_start_time') . get_option('wc_customer_order_csv_export_auto_export_interval'); // save settings woocommerce_update_options($this->get_settings('settings')); // clear scheduled export event if export interval and/or start time were changed if ($orig_start_inverval !== get_option('wc_customer_order_csv_export_auto_export_start_time') . get_option('wc_customer_order_csv_export_auto_export_interval')) { // note this resets the next scheduled execution time to the time options were saved + the interval wp_clear_scheduled_hook('wc_customer_order_csv_export_auto_export_orders'); } $this->message_handler->add_message(__('Your settings have been saved.', WC_Customer_Order_CSV_Export::TEXT_DOMAIN)); } } ?> <div class="wrap woocommerce"> <form method="post" id="mainform" action="" enctype="multipart/form-data"> <h2 class="nav-tab-wrapper woo-nav-tab-wrapper"> <?php foreach ($this->tabs as $tab_id => $tab_title) { $class = $tab_id == $current_tab ? array('nav-tab', 'nav-tab-active') : array('nav-tab'); $url = add_query_arg('tab', $tab_id, admin_url('admin.php?page=wc_customer_order_csv_export')); printf('<a href="%s" class="%s">%s</a>', esc_url($url), implode(' ', array_map('sanitize_html_class', $class)), esc_html($tab_title)); } ?> </h2> <?php $this->message_handler->show_messages(); if ('settings' == $current_tab) { $this->render_settings_page(); } else { $this->render_export_page(); } ?> </form> </div> <?php }