Merge branch 'master' into fix/18680

This commit is contained in:
Mike Jolley 2018-01-31 17:56:46 +00:00
commit e6f54912ee
14 changed files with 47 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2440,7 +2440,8 @@ table.wp-list-table {
white-space: nowrap;
}
.column-handle {
.column-handle,
.column-nosort {
width: 17px;
}

View File

@ -3,12 +3,19 @@
/* Modifided script from the simple-page-ordering plugin */
jQuery( function( $ ) {
$( 'table.widefat.wp-list-table tr' ).append(
'<td class="column-handle"></td>'
);
var table_selector = 'table.wp-list-table',
item_selector = 'tbody tr:not(.inline-edit-row, ' + '#tag-' + woocommerce_term_ordering_params.default + ')';
$( 'table.widefat.wp-list-table' ).sortable({
items: 'tbody tr:not(.inline-edit-row)',
$( 'table.wp-list-table tr:not(.inline-edit-row)' ).each( function() {
if ( 'tag-' + woocommerce_term_ordering_params.default === $( this ).prop( 'id' ) ) {
$( this ).append( '<td class="column-nosort"></td>' );
} else {
$( this ).append( '<td class="column-handle"></td>' );
}
} );
$( table_selector ).sortable({
items: item_selector,
cursor: 'move',
handle: '.column-handle',
axis: 'y',
@ -53,7 +60,7 @@ jQuery( function( $ ) {
// If previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children
if ( ( prevtermid === undefined && nexttermid === undefined ) || ( nexttermid === undefined && nexttermparent === prevtermid ) || ( nexttermid !== undefined && prevtermparent === termid ) ) {
$( 'table.widefat.wp-list-table' ).sortable( 'cancel' );
$( table_selector ).sortable( 'cancel' );
return;
}

View File

@ -328,6 +328,7 @@ class WC_Admin_Assets {
$woocommerce_term_order_params = array(
'taxonomy' => $taxonomy,
'default' => absint( get_option( 'default_product_cat' ) ),
);
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );

View File

@ -101,6 +101,10 @@ class WC_Admin_Post_Types {
new WC_Admin_List_Table_Products();
break;
}
// Ensure the table handler is only loaded once. Prevents multiple loads if a plugin calls check_ajax_referer many times.
remove_action( 'current_screen', array( $this, 'setup_screen' ) );
remove_action( 'check_ajax_referer', array( $this, 'setup_screen' ) );
}
/**

View File

@ -286,7 +286,8 @@ class WC_Helper {
$data['_actions'][] = $action;
} else {
$action = array(
'message' => sprintf( __( 'To receive updates and support for this extension, you need to <strong>purchase</strong> a new subscription or consolidate your extensions to one connected account by <strong><a href="%s" title="Sharing Docs">sharing</a> or <a href="%s" title="Transferring Docs">transferring</a></strong> this extension to this connected account.', 'woocommerce' ), 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-10', 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-5' ),
/* translators: 1: subscriptions docs 2: subscriptions docs */
'message' => sprintf( __( 'To receive updates and support for this extension, you need to <strong>purchase</strong> a new subscription or consolidate your extensions to one connected account by <strong><a href="%1$s" title="Sharing Docs">sharing</a> or <a href="%2$s" title="Transferring Docs">transferring</a></strong> this extension to this connected account.', 'woocommerce' ), 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-10', 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-5' ),
'button_label' => __( 'Purchase', 'woocommerce' ),
'button_url' => $data['_product_url'],
'status' => 'expired',

View File

@ -4,8 +4,6 @@
*
* Handles requests to the /webhooks endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.6.0
*/
@ -38,6 +36,11 @@ class WC_REST_Webhooks_Controller extends WC_REST_Webhooks_V1_Controller {
*/
public function prepare_item_for_response( $id, $request ) {
$webhook = wc_get_webhook( $id );
if ( empty( $webhook ) || is_null( $webhook ) ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
}
$data = array(
'id' => $webhook->get_id(),
'name' => $webhook->get_name(),

View File

@ -360,7 +360,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
$id = (int) $request['id'];
$webhook = wc_get_webhook( $id );
if ( empty( $id ) || is_null( $webhook->get_id() ) ) {
if ( empty( $webhook ) || is_null( $webhook ) ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
}
@ -519,12 +519,17 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
/**
* Prepare a single webhook output for response.
*
* @param int $id Webhook ID.
* @param int $id Webhook ID or object.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response( $id, $request ) {
$webhook = wc_get_webhook( (int) $id );
$webhook = wc_get_webhook( $id );
if ( empty( $webhook ) || is_null( $webhook ) ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
}
$data = array(
'id' => $webhook->get_id(),
'name' => $webhook->get_name(),

View File

@ -390,7 +390,7 @@ class WC_Structured_Data {
continue;
}
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$product = $order->get_product_from_item( $item );
$product_exists = is_object( $product );
$is_visible = $product_exists && $product->is_visible();

View File

@ -204,6 +204,8 @@ add_action( 'woocommerce_after_shop_loop', 'woocommerce_reset_loop', 999 );
* @return mixed
*/
function wc_get_loop_prop( $prop, $default = '' ) {
wc_setup_loop(); // Ensure shop loop is setup.
return isset( $GLOBALS['woocommerce_loop'], $GLOBALS['woocommerce_loop'][ $prop ] ) ? $GLOBALS['woocommerce_loop'][ $prop ] : $default;
}
@ -1852,6 +1854,7 @@ if ( ! function_exists( 'woocommerce_get_product_subcategories' ) ) {
'hierarchical' => 1,
'taxonomy' => 'product_cat',
'pad_counts' => 1,
'exclude' => get_option( 'default_product_cat' ),
) ) );
wp_cache_set( 'product-categories-' . $parent_id, $product_categories, 'product_cat' );
}

View File

@ -4,8 +4,8 @@
*
* Functions for updating data, used by the background updater.
*
* @package WooCommerce/Functions
* @version 2.6.0
* @package WooCommerce/Functions
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -1527,6 +1527,7 @@ function wc_update_330_webhooks() {
$webhook->set_secret( get_post_meta( $post->ID, '_secret', true ) );
$webhook->set_topic( get_post_meta( $post->ID, '_topic', true ) );
$webhook->set_api_version( get_post_meta( $post->ID, '_api_version', true ) );
$webhook->set_user_id( $post->post_author );
$webhook->set_pending_delivery( false );
$webhook->save();

View File

@ -2,8 +2,6 @@
/**
* WooCommerce Webhook functions
*
* @author Automattic
* @category Core
* @package WooCommerce/Functions
* @version 3.3.0
*/
@ -117,11 +115,11 @@ function wc_load_webhooks() {
/**
* Get webhook.
*
* @param int $id Webhook ID.
* @param int|WC_Webhook $id Webhook ID or object.
* @return WC_Webhook|null
*/
function wc_get_webhook( $id ) {
$webhook = new WC_Webhook( (int) $id );
$webhook = new WC_Webhook( $id );
return 0 !== $webhook->get_id() ? $webhook : null;
}

View File

@ -52,7 +52,7 @@ if ( $show_downloads ) {
do_action( 'woocommerce_order_details_before_order_table_items', $order );
foreach ( $order_items as $item_id => $item ) {
$product = apply_filters( 'woocommerce_order_item_product', $item->get_product(), $item );
$product = $item->get_product();
wc_get_template( 'order/order-details-item.php', array(
'order' => $order,