Merge pull request #15100 from woocommerce/feature/import-export-ui-prep
Import export admin links
This commit is contained in:
commit
3705b45477
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -673,6 +673,10 @@ table.wc_status_table {
|
|||
}
|
||||
}
|
||||
|
||||
.edit-php.post-type-product .top .bulkactions {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#woocommerce-fields.inline-edit-col {
|
||||
clear: left;
|
||||
|
||||
|
@ -4961,6 +4965,7 @@ table.bar_chart {
|
|||
font-size: 1.2em;
|
||||
padding: 0.75em 1.5em;
|
||||
height: auto;
|
||||
display: inline-block !important
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,6 +16,7 @@ body {
|
|||
.wc-setup-content {
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
|
||||
padding: 24px 24px 0;
|
||||
margin: 0 0 20px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
|
@ -238,11 +239,6 @@ body {
|
|||
}
|
||||
.setup-product {
|
||||
a {
|
||||
background-color: #bb77ae;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
||||
font-size: 1em;
|
||||
height: auto;
|
||||
line-height: 1.75em;
|
||||
|
@ -250,6 +246,13 @@ body {
|
|||
opacity: 1;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
a.button-primary {
|
||||
background-color: #bb77ae;
|
||||
border-color: #a36597;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
||||
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
||||
|
||||
&:hover, &:focus, &:active {
|
||||
background: #a36597;
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
/* global woocommerce_admin */
|
||||
|
||||
/**
|
||||
* WooCommerce Admin JS
|
||||
*/
|
||||
jQuery( function ( $ ) {
|
||||
|
||||
// Add buttons to product screen.
|
||||
var $product_screen = $( '.edit-php.post-type-product' ),
|
||||
$title_action = $product_screen.find( '.page-title-action:first' ),
|
||||
$blankslate = $product_screen.find( '.woocommerce-BlankState' );
|
||||
|
||||
if ( 0 === $blankslate.length ) {
|
||||
$title_action.after( '<a href="' + woocommerce_admin.urls.export_products + '" class="page-title-action">' + woocommerce_admin.strings.export_products + '</a>' );
|
||||
$title_action.after( '<a href="' + woocommerce_admin.urls.import_products + '" class="page-title-action">' + woocommerce_admin.strings.import_products + '</a>' );
|
||||
} else {
|
||||
$title_action.hide();
|
||||
}
|
||||
|
||||
// Field validation error tips
|
||||
$( document.body )
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -72,7 +72,6 @@ class WC_Admin_Assets {
|
|||
/**
|
||||
* @deprecated 2.3
|
||||
*/
|
||||
|
||||
if ( has_action( 'woocommerce_admin_css' ) ) {
|
||||
do_action( 'woocommerce_admin_css' );
|
||||
wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
|
||||
|
@ -155,6 +154,14 @@ class WC_Admin_Assets {
|
|||
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
|
||||
'decimal_point' => $decimal,
|
||||
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
||||
'strings' => array(
|
||||
'import_products' => __( 'Import', 'woocommerce' ),
|
||||
'export_products' => __( 'Export', 'woocommerce' ),
|
||||
),
|
||||
'urls' => array(
|
||||
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
|
||||
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
|
||||
|
|
|
@ -51,7 +51,8 @@ class WC_Admin_Post_Types {
|
|||
add_filter( 'post_row_actions', array( $this, 'row_actions' ), 2, 100 );
|
||||
|
||||
// Views
|
||||
add_filter( 'views_edit-product', array( $this, 'product_sorting_link' ) );
|
||||
add_filter( 'views_edit-product', array( $this, 'product_views' ) );
|
||||
add_filter( 'disable_months_dropdown', array( $this, 'disable_months_dropdown' ), 10, 2 );
|
||||
|
||||
// Bulk / quick edit
|
||||
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit' ), 10, 2 );
|
||||
|
@ -774,29 +775,43 @@ class WC_Admin_Post_Types {
|
|||
}
|
||||
|
||||
/**
|
||||
* Product sorting link.
|
||||
*
|
||||
* Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/).
|
||||
* Change views on the edit product screen.
|
||||
*
|
||||
* @param array $views
|
||||
* @return array
|
||||
*/
|
||||
public function product_sorting_link( $views ) {
|
||||
global $post_type, $wp_query;
|
||||
public function product_views( $views ) {
|
||||
global $wp_query;
|
||||
|
||||
if ( ! current_user_can( 'edit_others_pages' ) ) {
|
||||
return $views;
|
||||
// Products do not have authors.
|
||||
unset( $views['mine'] );
|
||||
|
||||
// Add sorting link.
|
||||
if ( current_user_can( 'edit_others_pages' ) ) {
|
||||
$class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';
|
||||
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
|
||||
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
|
||||
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
|
||||
$views['byorder'] = '<a href="' . esc_url( $query_string ) . '" class="' . esc_attr( $class ) . '">' . __( 'Sorting', 'woocommerce' ) . '</a>';
|
||||
}
|
||||
|
||||
$class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';
|
||||
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
|
||||
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
|
||||
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
|
||||
$views['byorder'] = '<a href="' . esc_url( $query_string ) . '" class="' . esc_attr( $class ) . '">' . __( 'Sort products', 'woocommerce' ) . '</a>';
|
||||
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.1
|
||||
*/
|
||||
public function product_sorting_link( $views ) {
|
||||
$this->product_views( $views );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable months dropdown on product screen.
|
||||
*/
|
||||
public function disable_months_dropdown( $bool, $post_type ) {
|
||||
return 'product' === $post_type ? true : $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom bulk edit - form.
|
||||
*
|
||||
|
@ -1442,12 +1457,12 @@ class WC_Admin_Post_Types {
|
|||
global $wp_query;
|
||||
|
||||
// Category Filtering
|
||||
wc_product_dropdown_categories();
|
||||
wc_product_dropdown_categories( array( 'option_select_text' => __( 'Filter by category', 'woocommerce' ) ) );
|
||||
|
||||
// Type filtering
|
||||
$terms = get_terms( 'product_type' );
|
||||
$output = '<select name="product_type" id="dropdown_product_type">';
|
||||
$output .= '<option value="">' . __( 'Show all product types', 'woocommerce' ) . '</option>';
|
||||
$output .= '<option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$output .= '<option value="' . sanitize_title( $term->name ) . '" ';
|
||||
|
@ -1931,6 +1946,7 @@ class WC_Admin_Post_Types {
|
|||
?>
|
||||
<h2 class="woocommerce-BlankState-message"><?php _e( 'Ready to start selling something awesome?', 'woocommerce' ); ?></h2>
|
||||
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=product&tutorial=true' ) ); ?>"><?php _e( 'Create your first product!', 'woocommerce' ); ?></a>
|
||||
<a class="woocommerce-BlankState-cta button" href="<?php echo esc_url( admin_url( 'edit.php?post_type=product&page=product_importer' ) ); ?>"><?php _e( 'Import products from a CSV file', 'woocommerce' ); ?></a>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ class WC_Admin_Product_Export {
|
|||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 55 );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
||||
add_action( 'admin_head', array( $this, 'admin_menu_hide' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'admin_init', array( $this, 'download_export_file' ) );
|
||||
add_action( 'wp_ajax_woocommerce_do_ajax_product_export', array( $this, 'do_ajax_product_export' ) );
|
||||
|
@ -33,6 +34,21 @@ class WC_Admin_Product_Export {
|
|||
add_submenu_page( 'edit.php?post_type=product', __( 'Product Export', 'woocommerce' ), __( 'Export', 'woocommerce' ), 'edit_products', 'product_exporter', array( $this, 'admin_screen' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide menu item from view.
|
||||
*/
|
||||
public function admin_menu_hide() {
|
||||
global $submenu;
|
||||
|
||||
if ( isset( $submenu['edit.php?post_type=product'] ) ) {
|
||||
foreach ( $submenu['edit.php?post_type=product'] as $key => $menu ) {
|
||||
if ( 'product_exporter' === $menu[2] ) {
|
||||
unset( $submenu['edit.php?post_type=product'][ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Handles the product CSV importer UI in admin.
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.1.0
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Admin_Product_Import Class.
|
||||
*/
|
||||
class WC_Admin_Product_Import {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
||||
add_action( 'admin_head', array( $this, 'admin_menu_hide' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu items.
|
||||
*/
|
||||
public function admin_menu() {
|
||||
add_submenu_page( 'edit.php?post_type=product', __( 'Product Import', 'woocommerce' ), __( 'Import', 'woocommerce' ), 'edit_products', 'product_importer', array( $this, 'admin_screen' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide menu item from view.
|
||||
*/
|
||||
public function admin_menu_hide() {
|
||||
global $submenu;
|
||||
|
||||
if ( isset( $submenu['edit.php?post_type=product'] ) ) {
|
||||
foreach ( $submenu['edit.php?post_type=product'] as $key => $menu ) {
|
||||
if ( 'product_importer' === $menu[2] ) {
|
||||
unset( $submenu['edit.php?post_type=product'][ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import page UI.
|
||||
*/
|
||||
public function admin_screen() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new WC_Admin_Product_Import();
|
|
@ -804,6 +804,7 @@ class WC_Admin_Setup_Wizard {
|
|||
<h2><?php esc_html_e( 'Next steps', 'woocommerce' ); ?></h2>
|
||||
<ul>
|
||||
<li class="setup-product"><a class="button button-primary button-large" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=product&tutorial=true' ) ); ?>"><?php esc_html_e( 'Create your first product!', 'woocommerce' ); ?></a></li>
|
||||
<li class="setup-product"><a class="button button-large" href="<?php echo esc_url( admin_url( 'edit.php?post_type=product&page=product_importer' ) ); ?>"><?php esc_html_e( 'Import products from a CSV file', 'woocommerce' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="wc-setup-next-steps-last">
|
||||
|
|
|
@ -54,6 +54,7 @@ class WC_Admin {
|
|||
include_once( dirname( __FILE__ ) . '/class-wc-admin-api-keys.php' );
|
||||
include_once( dirname( __FILE__ ) . '/class-wc-admin-webhooks.php' );
|
||||
include_once( dirname( __FILE__ ) . '/class-wc-admin-pointers.php' );
|
||||
include_once( dirname( __FILE__ ) . '/class-wc-admin-product-import.php' );
|
||||
include_once( dirname( __FILE__ ) . '/class-wc-admin-product-export.php' );
|
||||
|
||||
// Help Tabs
|
||||
|
|
|
@ -204,6 +204,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
|
|||
'orderby' => 'name',
|
||||
'selected' => $current_product_cat,
|
||||
'menu_order' => false,
|
||||
'option_select_text' => __( 'Select a category', 'woocommerce' ),
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
@ -220,7 +221,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
|
|||
}
|
||||
|
||||
$output = "<select name='product_cat' class='dropdown_product_cat'>";
|
||||
$output .= '<option value="" ' . selected( $current_product_cat, '', false ) . '>' . esc_html__( 'Select a category', 'woocommerce' ) . '</option>';
|
||||
$output .= '<option value="" ' . selected( $current_product_cat, '', false ) . '>' . esc_html( $args['option_select_text'] ) . '</option>';
|
||||
$output .= wc_walk_category_dropdown_tree( $terms, 0, $args );
|
||||
if ( $args['show_uncategorized'] ) {
|
||||
$output .= '<option value="0" ' . selected( $current_product_cat, '0', false ) . '>' . esc_html__( 'Uncategorized', 'woocommerce' ) . '</option>';
|
||||
|
|
Loading…
Reference in New Issue