Merge branch 'master' into fix/18674

This commit is contained in:
Mike Jolley 2018-01-31 16:29:08 +00:00
commit 40c59d31f2
10 changed files with 274 additions and 232 deletions

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

@ -674,7 +674,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
'context' => array( 'view', 'edit' ),
),
'date_on_sale_to_gmt' => array(
'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ),
'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
),

File diff suppressed because it is too large Load Diff

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(),
@ -148,7 +151,7 @@ class WC_REST_Webhooks_Controller extends WC_REST_Webhooks_V1_Controller {
'readonly' => true,
),
'secret' => array(
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
'type' => 'string',
'context' => array( 'edit' ),
),

View File

@ -4,8 +4,6 @@
*
* Handles requests to the /webhooks endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 3.0.0
*/
@ -362,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 ) );
}
@ -521,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(),
@ -644,7 +647,7 @@ class WC_REST_Webhooks_V1_Controller extends WC_REST_Controller {
'readonly' => true,
),
'secret' => array(
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
'type' => 'string',
'context' => array( 'edit' ),
),

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

@ -357,7 +357,7 @@ class WC_Shop_Customizer {
'woocommerce_default_catalog_orderby',
array(
'label' => __( 'Default product sorting', 'woocommerce' ),
'description' => __( 'How should products by sorted in the catalog by default?', 'woocommerce' ),
'description' => __( 'How should products be sorted in the catalog by default?', 'woocommerce' ),
'section' => 'woocommerce_product_catalog',
'settings' => 'woocommerce_default_catalog_orderby',
'type' => 'select',

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;
}
@ -323,7 +325,9 @@ function wc_get_default_products_per_row() {
$columns = apply_filters( 'loop_shop_columns', $columns );
}
return absint( $columns );
$columns = absint( $columns );
return max( 1, $columns );
}
/**

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,