function woo_cd_html_page() { global $wpdb, $export; $title = apply_filters( 'woo_ce_template_header', __( 'Store Exporter Deluxe', 'woo_ce' ) ); woo_cd_template_header( $title ); $action = woo_get_action(); switch( $action ) { case 'export': if( WOO_CD_DEBUG ) { if( false === ( $export_log = get_transient( WOO_CD_PREFIX . '_debug_log' ) ) ) { $export_log = __( 'No export entries were found within the debug Transient, please try again with different export filters.', 'woo_ce' ); } else { $export_log = base64_decode( $export_log ); } delete_transient( WOO_CD_PREFIX . '_debug_log' ); $output = ' <h3>' . sprintf( __( 'Export Details: %s', 'woo_ce' ), esc_attr( $export->filename ) ) . '</h3> <p>' . __( 'This prints the $export global that contains the different export options and filters to help reproduce this on another instance of WordPress. Very useful for debugging blank or unexpected exports.', 'woo_ce' ) . '</p> <textarea id="export_log">' . esc_textarea( print_r( $export, true ) ) . '</textarea> <hr />'; if( in_array( $export->export_format, array( 'csv', 'xls' ) ) ) { $output .= ' <script> $j(function() { $j(\'#export_sheet\').CSVToTable(\'\', { startLine: 0'; if( in_array( $export->export_format, array( 'xls', 'xlsx' ) ) ) { $output .= ', separator: "\t"'; } $output .= ' }); }); </script> <h3>' . __( 'Export', 'woo_ce' ) . '</h3> <p>' . __( 'We use the <a href="http://code.google.com/p/jquerycsvtotable/" target="_blank"><em>CSV to Table plugin</em></a> to see first hand formatting errors or unexpected values within the export file.', 'woo_ce' ) . '</p> <div id="export_sheet">' . esc_textarea( $export_log ) . '</div> <p class="description">' . __( 'This jQuery plugin can fail with <code>\'Item count (#) does not match header count\'</code> notices which simply mean the number of headers detected does not match the number of cell contents.', 'woo_ce' ) . '</p> <hr />'; } $output .= ' <h3>' . __( 'Export Log', 'woo_ce' ) . '</h3> <p>' . __( 'This prints the raw export contents and is helpful when the jQuery plugin above fails due to major formatting errors.', 'woo_ce' ) . '</p> <textarea id="export_log" wrap="off">' . esc_textarea( $export_log ) . '</textarea> <hr /> '; echo $output; } woo_cd_manage_form(); break; case 'update': // Save Custom Product Meta if( isset( $_POST['custom_products'] ) ) { $custom_products = $_POST['custom_products']; $custom_products = explode( "\n", trim( $custom_products ) ); $size = count( $custom_products ); if( !empty( $size ) ) { for( $i = 0; $i < $size; $i++ ) $custom_products[$i] = sanitize_text_field( trim( $custom_products[$i] ) ); woo_ce_update_option( 'custom_products', $custom_products ); } } // Save Custom Attributes if( isset( $_POST['custom_attributes'] ) ) { $custom_attributes = $_POST['custom_attributes']; $custom_attributes = explode( "\n", trim( $custom_attributes ) ); $size = count( $custom_attributes ); if( !empty( $size ) ) { for( $i = 0; $i < $size; $i++ ) $custom_attributes[$i] = sanitize_text_field( trim( $custom_attributes[$i] ) ); woo_ce_update_option( 'custom_attributes', $custom_attributes ); } } // Save Custom Product Add-ons if( isset( $_POST['custom_product_addons'] ) ) { $custom_product_addons = $_POST['custom_product_addons']; $custom_product_addons = explode( "\n", trim( $custom_product_addons ) ); $size = count( $custom_product_addons ); if( !empty( $size ) ) { for( $i = 0; $i < $size; $i++ ) $custom_product_addons[$i] = sanitize_text_field( trim( $custom_product_addons[$i] ) ); woo_ce_update_option( 'custom_product_addons', $custom_product_addons ); } } // Save Custom Order Meta if( isset( $_POST['custom_orders'] ) ) { $custom_orders = $_POST['custom_orders']; $custom_orders = explode( "\n", trim( $custom_orders ) ); $size = count( $custom_orders ); if( $size ) { for( $i = 0; $i < $size; $i++ ) $custom_orders[$i] = sanitize_text_field( trim( $custom_orders[$i] ) ); woo_ce_update_option( 'custom_orders', $custom_orders ); } } // Save Custom Order Item Meta if( isset( $_POST['custom_order_items'] ) ) { $custom_order_items = $_POST['custom_order_items']; if( !empty( $custom_order_items ) ) { $custom_order_items = explode( "\n", trim( $custom_order_items ) ); $size = count( $custom_order_items ); if( $size ) { for( $i = 0; $i < $size; $i++ ) $custom_order_items[$i] = sanitize_text_field( trim( $custom_order_items[$i] ) ); woo_ce_update_option( 'custom_order_items', $custom_order_items ); } } else { woo_ce_update_option( 'custom_order_items', '' ); } } // Save Custom User Meta if( isset( $_POST['custom_users'] ) ) { $custom_users = $_POST['custom_users']; $custom_users = explode( "\n", trim( $custom_users ) ); $size = count( $custom_users ); if( $size ) { for( $i = 0; $i < $size; $i++ ) $custom_users[$i] = sanitize_text_field( trim( $custom_users[$i] ) ); woo_ce_update_option( 'custom_users', $custom_users ); } } // Save Custom Customer Meta if( isset( $_POST['custom_customers'] ) ) { $custom_customers = $_POST['custom_customers']; $custom_customers = explode( "\n", trim( $custom_customers ) ); $size = count( $custom_customers ); if( $size ) { for( $i = 0; $i < $size; $i++ ) $custom_customers[$i] = sanitize_text_field( trim( $custom_customers[$i] ) ); woo_ce_update_option( 'custom_customers', $custom_customers ); } } $message = __( 'Custom Fields saved. You can now select those additional fields from the Export Fields list.', 'woo_ce' ); woo_cd_admin_notice_html( $message ); woo_cd_manage_form(); break; default: woo_cd_manage_form(); break; } woo_cd_template_footer(); }
function woo_cd_html_page() { global $wpdb; $woo_ce_url = 'http://wordpress.org/extend/plugins/woocommerce-exporter/'; $woo_ce_search = add_query_arg(array('tab' => 'search', 's' => 'WooCommerce+Store+Exporter'), admin_url('plugin-install.php')); woo_cd_template_header(__('Store Exporter Deluxe', 'woo_cd')); include_once 'templates/admin/woo-admin_cd-export.php'; woo_cd_template_footer(); }