Merge branch 'scrutinizer/major-issues'
This commit is contained in:
commit
cefa76e58b
|
@ -890,17 +890,21 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Apply a coupon to the order and recalculate totals.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @param string|WC_Coupon $coupon Coupon code or object.
|
||||
* @param string|WC_Coupon $raw_coupon Coupon code or object.
|
||||
* @return true|WP_Error True if applied, error if not.
|
||||
*/
|
||||
public function apply_coupon( $coupon ) {
|
||||
if ( ! is_a( $coupon, 'WC_Coupon' ) ) {
|
||||
$code = wc_format_coupon_code( $coupon );
|
||||
public function apply_coupon( $raw_coupon ) {
|
||||
if ( is_a( $raw_coupon, 'WC_Coupon' ) ) {
|
||||
$coupon = $raw_coupon;
|
||||
} elseif ( is_string( $raw_coupon ) ) {
|
||||
$code = wc_format_coupon_code( $raw_coupon );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
|
||||
if ( $coupon->get_code() !== $code || ! $coupon->is_valid() ) {
|
||||
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon code', 'woocommerce' ) );
|
||||
}
|
||||
} else {
|
||||
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
// Check to make sure coupon is not already applied.
|
||||
|
@ -1017,7 +1021,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$coupons = $this->get_items( 'coupon' );
|
||||
$coupon_code_to_id = wc_list_pluck( $coupons, 'get_id', 'get_code' );
|
||||
$all_discounts = $discounts->get_discounts();
|
||||
$item_discounts = $discounts->get_discounts_by_item();
|
||||
$coupon_discounts = $discounts->get_discounts_by_coupon();
|
||||
|
||||
if ( $coupon_discounts ) {
|
||||
|
|
|
@ -1190,7 +1190,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* Set download limit.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $download_limit
|
||||
* @param int|string $download_limit
|
||||
*/
|
||||
public function set_download_limit( $download_limit ) {
|
||||
$this->set_prop( 'download_limit', -1 === (int) $download_limit || '' === $download_limit ? -1 : absint( $download_limit ) );
|
||||
|
@ -1200,7 +1200,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* Set download expiry.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $download_expiry
|
||||
* @param int|string $download_limit
|
||||
*/
|
||||
public function set_download_expiry( $download_expiry ) {
|
||||
$this->set_prop( 'download_expiry', -1 === (int) $download_expiry || '' === $download_expiry ? -1 : absint( $download_expiry ) );
|
||||
|
|
|
@ -205,7 +205,6 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
public function validate_setting_text_field( $value, $setting ) {
|
||||
$value = is_null( $value ) ? '' : $value;
|
||||
return wp_kses_post( trim( stripslashes( $value ) ) );
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* Get object.
|
||||
*
|
||||
* @param int $id Object ID.
|
||||
* @return WP_Error|WC_Data
|
||||
* @return object WC_Data object or WP_Error object.
|
||||
*/
|
||||
protected function get_object( $id ) {
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
|
@ -376,7 +376,6 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @return WP_REST_Response|WP_Error
|
||||
*/
|
||||
public function delete_item( $request ) {
|
||||
$id = (int) $request['id'];
|
||||
$force = (bool) $request['force'];
|
||||
$object = $this->get_object( (int) $request['id'] );
|
||||
$result = false;
|
||||
|
|
|
@ -477,6 +477,15 @@ class WC_Admin_Addons {
|
|||
$theme = wp_get_theme();
|
||||
$section_keys = array_keys( $sections );
|
||||
$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
|
||||
|
||||
/**
|
||||
* Addon page view.
|
||||
*
|
||||
* @uses $sections
|
||||
* @uses $theme
|
||||
* @uses $section_keys
|
||||
* @uses $current_section
|
||||
*/
|
||||
include_once( dirname( __FILE__ ) . '/views/html-admin-page-addons.php' );
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class WC_Helper_API {
|
|||
$request_uri = parse_url( $url, PHP_URL_PATH );
|
||||
$query_string = parse_url( $url, PHP_URL_QUERY );
|
||||
|
||||
if ( $query_string ) {
|
||||
if ( is_string( $query_string ) ) {
|
||||
$request_uri .= '?' . $query_string;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ class WC_Helper_Plugin_Info {
|
|||
|
||||
// Look through local Woo plugins by slugs.
|
||||
foreach ( WC_Helper::get_local_woo_plugins() as $plugin ) {
|
||||
$slug = dirname( $plugin['_filename'] );
|
||||
if ( dirname( $plugin['_filename'] ) === $args->slug ) {
|
||||
$plugin['_slug'] = $args->slug;
|
||||
$found_plugin = $plugin;
|
||||
|
|
|
@ -615,7 +615,7 @@ class WC_Helper {
|
|||
'wc-helper-status' => 'helper-disconnected',
|
||||
), admin_url( 'admin.php' ) );
|
||||
|
||||
$result = WC_Helper_API::post( 'oauth/invalidate_token', array(
|
||||
WC_Helper_API::post( 'oauth/invalidate_token', array(
|
||||
'authenticated' => true,
|
||||
) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue