|
|
|
@ -35,6 +35,7 @@ class WC_Admin_Assets {
|
|
|
|
|
global $wp_scripts;
|
|
|
|
|
|
|
|
|
|
$screen = get_current_screen();
|
|
|
|
|
$screen_id = $screen ? $screen->id : '';
|
|
|
|
|
$jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2';
|
|
|
|
|
|
|
|
|
|
// Register admin styles
|
|
|
|
@ -48,17 +49,17 @@ class WC_Admin_Assets {
|
|
|
|
|
wp_enqueue_style( 'woocommerce_admin_menu_styles' );
|
|
|
|
|
|
|
|
|
|
// Admin styles for WC pages only
|
|
|
|
|
if ( in_array( $screen->id, wc_get_screen_ids() ) ) {
|
|
|
|
|
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
|
|
|
|
wp_enqueue_style( 'woocommerce_admin_styles' );
|
|
|
|
|
wp_enqueue_style( 'jquery-ui-style' );
|
|
|
|
|
wp_enqueue_style( 'wp-color-picker' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
|
|
|
|
|
wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( in_array( $screen->id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
|
|
|
|
|
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,6 +81,7 @@ class WC_Admin_Assets {
|
|
|
|
|
global $wp_query, $post;
|
|
|
|
|
|
|
|
|
|
$screen = get_current_screen();
|
|
|
|
|
$screen_id = $screen ? $screen->id : '';
|
|
|
|
|
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
|
|
|
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
|
|
|
|
|
|
|
@ -132,7 +134,7 @@ class WC_Admin_Assets {
|
|
|
|
|
) );
|
|
|
|
|
|
|
|
|
|
// WooCommerce admin pages
|
|
|
|
|
if ( in_array( $screen->id, wc_get_screen_ids() ) ) {
|
|
|
|
|
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
|
|
|
|
wp_enqueue_script( 'iris' );
|
|
|
|
|
wp_enqueue_script( 'woocommerce_admin' );
|
|
|
|
|
wp_enqueue_script( 'wc-enhanced-select' );
|
|
|
|
@ -155,18 +157,18 @@ class WC_Admin_Assets {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Edit product category pages
|
|
|
|
|
if ( in_array( $screen->id, array( 'edit-product_cat' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
|
|
|
|
|
wp_enqueue_media();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Products
|
|
|
|
|
if ( in_array( $screen->id, array( 'edit-product' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
|
|
|
|
|
wp_register_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
|
|
|
|
wp_enqueue_script( 'woocommerce_quick-edit' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Meta boxes
|
|
|
|
|
if ( in_array( $screen->id, array( 'product', 'edit-product' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
|
|
|
|
|
wp_enqueue_media();
|
|
|
|
|
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
|
|
|
|
|
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
|
|
|
|
@ -207,7 +209,7 @@ class WC_Admin_Assets {
|
|
|
|
|
|
|
|
|
|
wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
|
|
|
|
|
}
|
|
|
|
|
if ( in_array( str_replace( 'edit-', '', $screen->id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
|
|
|
|
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
|
|
|
|
wp_register_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
|
|
|
|
|
wp_register_script( 'wc-admin-order-meta-boxes-modal', WC()->plugin_url() . '/assets/js/admin/order-backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util', 'wc-admin-order-meta-boxes' ), WC_VERSION );
|
|
|
|
|
|
|
|
|
@ -221,11 +223,11 @@ class WC_Admin_Assets {
|
|
|
|
|
|
|
|
|
|
wp_localize_script( 'wc-admin-order-meta-boxes', 'woocommerce_admin_meta_boxes_order', $params );
|
|
|
|
|
}
|
|
|
|
|
if ( in_array( $screen->id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
|
|
|
|
|
wp_register_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
|
|
|
|
|
wp_enqueue_script( 'wc-admin-coupon-meta-boxes' );
|
|
|
|
|
}
|
|
|
|
|
if ( in_array( str_replace( 'edit-', '', $screen->id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
|
|
|
|
|
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
|
|
|
|
|
$params = array(
|
|
|
|
|
'remove_item_notice' => __( 'Are you sure you want to remove the selected items? If you have previously reduced this item\'s stock, or this order was submitted by a customer, you will need to manually restore the item\'s stock.', 'woocommerce' ),
|
|
|
|
|
'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
|
|
|
|
@ -285,7 +287,7 @@ class WC_Admin_Assets {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Term ordering - only when sorting by term_order
|
|
|
|
|
if ( ( strstr( $screen->id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
|
|
|
|
|
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
|
|
|
|
|
|
|
|
|
|
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION );
|
|
|
|
|
wp_enqueue_script( 'woocommerce_term_ordering' );
|
|
|
|
@ -300,13 +302,13 @@ class WC_Admin_Assets {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Product sorting - only when sorting by menu order on the products page
|
|
|
|
|
if ( current_user_can( 'edit_others_pages' ) && $screen->id == 'edit-product' && isset( $wp_query->query['orderby'] ) && $wp_query->query['orderby'] == 'menu_order title' ) {
|
|
|
|
|
if ( current_user_can( 'edit_others_pages' ) && $screen_id == 'edit-product' && isset( $wp_query->query['orderby'] ) && $wp_query->query['orderby'] == 'menu_order title' ) {
|
|
|
|
|
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
|
|
|
|
|
wp_enqueue_script( 'woocommerce_product_ordering' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reports Pages
|
|
|
|
|
if ( in_array( $screen->id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
|
|
|
|
|
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION );
|
|
|
|
|
|
|
|
|
|
wp_enqueue_script( 'wc-reports' );
|
|
|
|
@ -318,7 +320,7 @@ class WC_Admin_Assets {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// API settings
|
|
|
|
|
if ( $wc_screen_id . '_page_wc-settings' === $screen->id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
|
|
|
|
|
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
|
|
|
|
|
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'zeroclipboard' ), WC_VERSION, true );
|
|
|
|
|
wp_enqueue_script( 'wc-api-keys' );
|
|
|
|
|
wp_localize_script(
|
|
|
|
@ -332,11 +334,11 @@ class WC_Admin_Assets {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// System status
|
|
|
|
|
if ( $wc_screen_id . '_page_wc-status' === $screen->id ) {
|
|
|
|
|
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
|
|
|
|
|
wp_enqueue_script( 'zeroclipboard' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( in_array( $screen->id, array( 'user-edit', 'profile' ) ) ) {
|
|
|
|
|
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
|
|
|
|
|
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select' ), WC_VERSION, true );
|
|
|
|
|
wp_enqueue_script( 'wc-users' );
|
|
|
|
|
wp_localize_script(
|
|
|
|
|