html-admin-dashboard-setup.php
5 months ago
html-admin-page-addons-category-nav.php
4 years ago
html-admin-page-product-export.php
1 year ago
html-admin-page-reports.php
2 years ago
html-admin-page-status-logs-db.php
2 years ago
html-admin-page-status-logs.php
2 years ago
html-admin-page-status-report.php
1 month ago
html-admin-page-status-tools.php
2 years ago
html-admin-page-status.php
8 years ago
html-admin-settings.php
1 month ago
html-bulk-edit-product.php
1 year ago
html-email-template-preview.php
1 year ago
html-notice-base-table-missing.php
3 years ago
html-notice-custom.php
8 years ago
html-notice-download-dir-sync-complete.php
2 years ago
html-notice-install.php
5 years ago
html-notice-legacy-shipping.php
11 months ago
html-notice-maxmind-license-key.php
6 years ago
html-notice-no-shipping-methods.php
2 years ago
html-notice-redirect-only-download.php
4 years ago
html-notice-regenerating-lookup-table.php
5 years ago
html-notice-regenerating-thumbnails.php
8 years ago
html-notice-secure-connection.php
2 years ago
html-notice-sync-on-read-disabled.php
3 months ago
html-notice-template-check.php
2 years ago
html-notice-update.php
4 months ago
html-notice-updated.php
7 years ago
html-notice-updating.php
6 years ago
html-notice-uploads-directory-is-unprotected.php
2 years ago
html-notice-wp-php-minimum-requirements.php
2 years ago
html-quick-edit-product.php
1 year ago
html-report-by-date.php
5 years ago
html-admin-page-product-export.php
149 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin View: Product Export |
| 4 | * |
| 5 | * @package WooCommerce\Admin\Export |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | wp_enqueue_script( 'wc-product-export' ); |
| 13 | |
| 14 | $exporter = new WC_Product_CSV_Exporter(); |
| 15 | |
| 16 | $product_ids_to_export = array(); |
| 17 | $is_exporting_product_ids = false; |
| 18 | |
| 19 | if ( ! empty( $_GET['product_ids'] ) ) { |
| 20 | check_admin_referer( 'export-selected-products' ); |
| 21 | |
| 22 | $ids_raw = explode( ',', sanitize_text_field( wp_unslash( $_GET['product_ids'] ) ) ); |
| 23 | $product_ids_to_export = array_filter( array_map( 'absint', $ids_raw ) ); |
| 24 | $is_exporting_product_ids = ! empty( $product_ids_to_export ) ? true : false; |
| 25 | } |
| 26 | ?> |
| 27 | <div class="wrap woocommerce"> |
| 28 | <h1><?php esc_html_e( 'Export Products', 'woocommerce' ); ?></h1> |
| 29 | |
| 30 | <?php |
| 31 | if ( $is_exporting_product_ids ) { |
| 32 | $clear_url = remove_query_arg( 'product_ids' ); |
| 33 | $count = count( $product_ids_to_export ); |
| 34 | $notice = sprintf( |
| 35 | // translators: %1$d: Number of products, %2$s: URL to clear selection. |
| 36 | _n( |
| 37 | 'You are about to export %1$d product. To export all products, <a href="%2$s">clear your selection</a>.', |
| 38 | 'You are about to export %1$d products. To export all products, <a href="%2$s">clear your selection</a>.', |
| 39 | $count, |
| 40 | 'woocommerce' |
| 41 | ), |
| 42 | $count, |
| 43 | esc_url( $clear_url ) |
| 44 | ); |
| 45 | ?> |
| 46 | <div id="selected-product-export-notice" class="notice notice-info inline"> |
| 47 | <p><?php echo wp_kses_post( $notice ); ?></p> |
| 48 | </div> |
| 49 | <?php |
| 50 | } |
| 51 | ?> |
| 52 | |
| 53 | <div class="woocommerce-exporter-wrapper"> |
| 54 | <form class="woocommerce-exporter"> |
| 55 | <?php |
| 56 | // Add hidden input if exporting product IDs, so JS can potentially pick it up. |
| 57 | if ( $is_exporting_product_ids ) { |
| 58 | echo '<input type="hidden" name="product_ids" value="' . esc_attr( implode( ',', $product_ids_to_export ) ) . '" />'; |
| 59 | } |
| 60 | ?> |
| 61 | <header> |
| 62 | <span class="spinner is-active"></span> |
| 63 | <h2><?php esc_html_e( 'Export products to a CSV file', 'woocommerce' ); ?></h2> |
| 64 | <p> |
| 65 | <?php |
| 66 | if ( $is_exporting_product_ids ) { |
| 67 | esc_html_e( 'This tool allows you to generate and download a CSV file containing the selected products.', 'woocommerce' ); |
| 68 | } else { |
| 69 | esc_html_e( 'This tool allows you to generate and download a CSV file containing a list of all products.', 'woocommerce' ); |
| 70 | } |
| 71 | ?> |
| 72 | </p> |
| 73 | </header> |
| 74 | <section> |
| 75 | <table class="form-table woocommerce-exporter-options"> |
| 76 | <tbody> |
| 77 | <tr> |
| 78 | <th scope="row"> |
| 79 | <label for="woocommerce-exporter-columns"><?php esc_html_e( 'Which columns should be exported?', 'woocommerce' ); ?></label> |
| 80 | </th> |
| 81 | <td> |
| 82 | <select id="woocommerce-exporter-columns" class="woocommerce-exporter-columns wc-enhanced-select" style="width:100%;" multiple data-placeholder="<?php esc_attr_e( 'Export all columns', 'woocommerce' ); ?>"> |
| 83 | <?php |
| 84 | foreach ( $exporter->get_default_column_names() as $column_id => $column_name ) { |
| 85 | echo '<option value="' . esc_attr( $column_id ) . '">' . esc_html( $column_name ) . '</option>'; |
| 86 | } |
| 87 | ?> |
| 88 | <option value="downloads"><?php esc_html_e( 'Downloads', 'woocommerce' ); ?></option> |
| 89 | <option value="attributes"><?php esc_html_e( 'Attributes', 'woocommerce' ); ?></option> |
| 90 | </select> |
| 91 | </td> |
| 92 | </tr> |
| 93 | <?php if ( ! $is_exporting_product_ids ) : ?> |
| 94 | <tr> |
| 95 | <th scope="row"> |
| 96 | <label for="woocommerce-exporter-types"><?php esc_html_e( 'Which product types should be exported?', 'woocommerce' ); ?></label> |
| 97 | </th> |
| 98 | <td> |
| 99 | <select id="woocommerce-exporter-types" class="woocommerce-exporter-types wc-enhanced-select" style="width:100%;" multiple data-placeholder="<?php esc_attr_e( 'Export all products', 'woocommerce' ); ?>"> |
| 100 | <?php |
| 101 | foreach ( WC_Admin_Exporters::get_product_types() as $value => $label ) { |
| 102 | echo '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>'; |
| 103 | } |
| 104 | ?> |
| 105 | </select> |
| 106 | </td> |
| 107 | </tr> |
| 108 | <tr> |
| 109 | <th scope="row"> |
| 110 | <label for="woocommerce-exporter-category"><?php esc_html_e( 'Which product category should be exported?', 'woocommerce' ); ?></label> |
| 111 | </th> |
| 112 | <td> |
| 113 | <select id="woocommerce-exporter-category" class="woocommerce-exporter-category wc-enhanced-select" style="width:100%;" multiple data-placeholder="<?php esc_attr_e( 'Export all categories', 'woocommerce' ); ?>"> |
| 114 | <?php |
| 115 | $categories = get_categories( |
| 116 | array( |
| 117 | 'taxonomy' => 'product_cat', |
| 118 | 'hide_empty' => false, |
| 119 | ) |
| 120 | ); |
| 121 | foreach ( $categories as $category ) { |
| 122 | echo '<option value="' . esc_attr( $category->slug ) . '">' . esc_html( $category->name ) . '</option>'; |
| 123 | } |
| 124 | ?> |
| 125 | </select> |
| 126 | </td> |
| 127 | </tr> |
| 128 | <?php endif; ?> |
| 129 | <tr> |
| 130 | <th scope="row"> |
| 131 | <label for="woocommerce-exporter-meta"><?php esc_html_e( 'Export custom meta?', 'woocommerce' ); ?></label> |
| 132 | </th> |
| 133 | <td> |
| 134 | <input type="checkbox" id="woocommerce-exporter-meta" value="1" /> |
| 135 | <label for="woocommerce-exporter-meta"><?php esc_html_e( 'Yes, export all custom meta', 'woocommerce' ); ?></label> |
| 136 | </td> |
| 137 | </tr> |
| 138 | <?php do_action( 'woocommerce_product_export_row' ); ?> |
| 139 | </tbody> |
| 140 | </table> |
| 141 | <progress class="woocommerce-exporter-progress" max="100" value="0"></progress> |
| 142 | </section> |
| 143 | <div class="wc-actions"> |
| 144 | <button type="submit" class="woocommerce-exporter-button button button-primary" value="<?php esc_attr_e( 'Generate CSV', 'woocommerce' ); ?>"><?php esc_html_e( 'Generate CSV', 'woocommerce' ); ?></button> |
| 145 | </div> |
| 146 | </form> |
| 147 | </div> |
| 148 | </div> |
| 149 |