Skip to content

Commit

Permalink
Merge pull request woocommerce#27054 from woocommerce/fix/27036
Browse files Browse the repository at this point in the history
add/update correct deprecated notices on existing deprecations
  • Loading branch information
Konamiman authored Jul 29, 2020
2 parents 7f4df9e + d8edcb4 commit 0f134ca
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 62 deletions.
3 changes: 2 additions & 1 deletion includes/admin/class-wc-admin-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,10 @@ public function woocommerce_media_upload_downloadable_product() {
* @param int $product_id product identifier.
* @param int $variation_id optional product variation identifier.
* @param array $downloadable_files newly set files.
* @deprecated and moved to post-data class.
* @deprecated 3.3.0 and moved to post-data class.
*/
public function process_product_file_download_paths( $product_id, $variation_id, $downloadable_files ) {
wc_deprecated_function( 'WC_Admin_Post_Types::process_product_file_download_paths', '3.3', '' );
WC_Post_Data::process_product_file_download_paths( $product_id, $variation_id, $downloadable_files );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,12 @@ public function render_products_stock_status_filter() {
/**
* Search by SKU or ID for products.
*
* @deprecated Logic moved to query_filters.
* @deprecated 4.4.0 Logic moved to query_filters.
* @param string $where Where clause SQL.
* @return string
*/
public function sku_search( $where ) {
wc_deprecated_function( 'WC_Admin_List_Table_Products::sku_search', '4.4.0', 'Logic moved to query_filters.' );
return $where;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/admin/meta-boxes/views/html-variation-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @var int $variation_id
* @var WP_POST $variation
* @var WC_Product_Variation $variation_object
* @var array $variation_data array of variation data @deprecated.
* @var array $variation_data array of variation data @deprecated 4.4.0.
*/

defined( 'ABSPATH' ) || exit;
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/views/html-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
self::show_messages();

do_action( 'woocommerce_settings_' . $current_tab );
do_action( 'woocommerce_settings_tabs_' . $current_tab ); // @deprecated hook. @todo remove in 4.0.
do_action( 'woocommerce_settings_tabs_' . $current_tab ); // @deprecated 3.4.0 hook.
?>
<p class="submit">
<?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?>
Expand Down
10 changes: 5 additions & 5 deletions includes/class-wc-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ public function create_order_line_items( &$order, $cart ) {
*/
$item = apply_filters( 'woocommerce_checkout_create_order_line_item_object', new WC_Order_Item_Product(), $cart_item_key, $values, $order );
$product = $values['data'];
$item->legacy_values = $values; // @deprecated For legacy actions.
$item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions.
$item->legacy_values = $values; // @deprecated 4.4.0 For legacy actions.
$item->legacy_cart_item_key = $cart_item_key; // @deprecated 4.4.0 For legacy actions.
$item->set_props(
array(
'quantity' => $values['quantity'],
Expand Down Expand Up @@ -502,8 +502,8 @@ public function create_order_line_items( &$order, $cart ) {
public function create_order_fee_lines( &$order, $cart ) {
foreach ( $cart->get_fees() as $fee_key => $fee ) {
$item = new WC_Order_Item_Fee();
$item->legacy_fee = $fee; // @deprecated For legacy actions.
$item->legacy_fee_key = $fee_key; // @deprecated For legacy actions.
$item->legacy_fee = $fee; // @deprecated 4.4.0 For legacy actions.
$item->legacy_fee_key = $fee_key; // @deprecated 4.4.0 For legacy actions.
$item->set_props(
array(
'name' => $fee->name,
Expand Down Expand Up @@ -541,7 +541,7 @@ public function create_order_shipping_lines( &$order, $chosen_shipping_methods,
if ( isset( $chosen_shipping_methods[ $package_key ], $package['rates'][ $chosen_shipping_methods[ $package_key ] ] ) ) {
$shipping_rate = $package['rates'][ $chosen_shipping_methods[ $package_key ] ];
$item = new WC_Order_Item_Shipping();
$item->legacy_package_key = $package_key; // @deprecated For legacy actions.
$item->legacy_package_key = $package_key; // @deprecated 4.4.0 For legacy actions.
$item->set_props(
array(
'method_title' => $shipping_rate->label,
Expand Down
6 changes: 4 additions & 2 deletions includes/class-wc-download-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ private static function check_download_login_required( $download ) {
/**
* Count download.
*
* @deprecated unknown
* @deprecated 4.4.0
* @param array $download_data Download data.
*/
public static function count_download( $download_data ) {}
public static function count_download( $download_data ) {
wc_deprecated_function( 'WC_Download_Handler::count_download', '4.4.0', '' );
}

/**
* Download a file - hook into init function.
Expand Down
6 changes: 4 additions & 2 deletions includes/class-wc-order-item-coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ public function get_discount_tax( $context = 'view' ) {
/**
* OffsetGet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Offset.
* @return mixed
*/
public function offsetGet( $offset ) {
wc_deprecated_function( 'WC_Order_Item_Coupon::offsetGet', '4.4.0', '' );
if ( 'discount_amount' === $offset ) {
$offset = 'discount';
} elseif ( 'discount_amount_tax' === $offset ) {
Expand All @@ -152,11 +153,12 @@ public function offsetGet( $offset ) {
/**
* OffsetSet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Offset.
* @param mixed $value Value.
*/
public function offsetSet( $offset, $value ) {
wc_deprecated_function( 'WC_Order_Item_Coupon::offsetSet', '4.4.0', '' );
if ( 'discount_amount' === $offset ) {
$offset = 'discount';
} elseif ( 'discount_amount_tax' === $offset ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-order-item-fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ public function get_taxes( $context = 'view' ) {
/**
* OffsetGet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @param string $offset Offset.
* @return mixed
*/
Expand All @@ -308,11 +307,12 @@ public function offsetGet( $offset ) {
/**
* OffsetSet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Offset.
* @param mixed $value Value.
*/
public function offsetSet( $offset, $value ) {
wc_deprecated_function( 'WC_Order_Item_Fee::offsetSet', '4.4.0', '' );
if ( 'line_total' === $offset ) {
$offset = 'total';
} elseif ( 'line_tax' === $offset ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-order-item-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ public function get_tax_status() {
/**
* OffsetGet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @param string $offset Offset.
* @return mixed
*/
Expand All @@ -449,11 +448,12 @@ public function offsetGet( $offset ) {
/**
* OffsetSet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Offset.
* @param mixed $value Value.
*/
public function offsetSet( $offset, $value ) {
wc_deprecated_function( 'WC_Order_Item_Product::offsetSet', '4.4.0', '' );
if ( 'line_subtotal' === $offset ) {
$offset = 'subtotal';
} elseif ( 'line_subtotal_tax' === $offset ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-order-item-shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public function get_tax_class( $context = 'view' ) {
/**
* Offset get: for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @param string $offset Key.
* @return mixed
*/
Expand All @@ -290,11 +289,12 @@ public function offsetGet( $offset ) {
/**
* Offset set: for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Key.
* @param mixed $value Value to set.
*/
public function offsetSet( $offset, $value ) {
wc_deprecated_function( 'WC_Order_Item_Shipping::offsetSet', '4.4.0', '' );
if ( 'cost' === $offset ) {
$offset = 'total';
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-order-item-tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ public function get_rate_percent( $context = 'view' ) {
/**
* O for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @param string $offset Offset.
* @return mixed
*/
Expand All @@ -260,11 +259,12 @@ public function offsetGet( $offset ) {
/**
* OffsetSet for ArrayAccess/Backwards compatibility.
*
* @deprecated Add deprecation notices in future release.
* @deprecated 4.4.0
* @param string $offset Offset.
* @param mixed $value Value.
*/
public function offsetSet( $offset, $value ) {
wc_deprecated_function( 'WC_Order_Item_Tax::offsetSet', '4.4.0', '' );
if ( 'tax_amount' === $offset ) {
$offset = 'tax_total';
} elseif ( 'shipping_tax_amount' === $offset ) {
Expand Down
3 changes: 1 addition & 2 deletions includes/class-wc-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,7 @@ public function needs_shipping_address() {
$needs_address = false;

foreach ( $this->get_shipping_methods() as $shipping_method ) {
// Remove any instance IDs after ":".
$shipping_method_id = current( explode( ':', $shipping_method['method_id'] ) );
$shipping_method_id = $shipping_method->get_method_id();

if ( ! in_array( $shipping_method_id, $hide, true ) ) {
$needs_address = true;
Expand Down
10 changes: 5 additions & 5 deletions includes/class-wc-structured-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function generate_product_data( $product = null ) {

if ( '' !== $product->get_price() ) {
// Assume prices will be valid until the end of next year, unless on sale and there is an end date.
$price_valid_until = date( 'Y-12-31', time() + YEAR_IN_SECONDS );
$price_valid_until = gmdate( 'Y-12-31', time() + YEAR_IN_SECONDS );

if ( $product->is_type( 'variable' ) ) {
$lowest = $product->get_variation_price( 'min', false );
Expand All @@ -243,7 +243,7 @@ public function generate_product_data( $product = null ) {
}
} else {
if ( $product->is_on_sale() && $product->get_date_on_sale_to() ) {
$price_valid_until = date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() );
$price_valid_until = gmdate( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() );
}
$markup_offer = array(
'@type' => 'Offer',
Expand Down Expand Up @@ -459,7 +459,7 @@ public function generate_order_data( $order, $sent_to_admin = false, $plain_text
continue;
}

$product = $order->get_product_from_item( $item );
$product = $item->get_product();
$product_exists = is_object( $product );
$is_visible = $product_exists && $product->is_visible();

Expand All @@ -472,12 +472,12 @@ public function generate_order_data( $order, $sent_to_admin = false, $plain_text
'priceCurrency' => $order->get_currency(),
'eligibleQuantity' => array(
'@type' => 'QuantitativeValue',
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ),
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ),
),
),
'itemOffered' => array(
'@type' => 'Product',
'name' => apply_filters( 'woocommerce_order_item_name', $item['name'], $item, $is_visible ),
'name' => apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, $is_visible ),
'sku' => $product_exists ? $product->get_sku() : '',
'image' => $product_exists ? wp_get_attachment_image_url( $product->get_image_id() ) : '',
'url' => $is_visible ? get_permalink( $product->get_id() ) : get_home_url(),
Expand Down
2 changes: 1 addition & 1 deletion includes/class-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public function add_image_sizes() {
/**
* Legacy image sizes.
*
* @deprecated These sizes will be removed in 4.0.
* @deprecated 3.3.0 These sizes will be removed in 4.6.0.
*/
add_image_size( 'shop_catalog', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] );
add_image_size( 'shop_single', $single['width'], $single['height'], $single['crop'] );
Expand Down
5 changes: 3 additions & 2 deletions includes/legacy/abstract-wc-legacy-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,12 @@ public function update_tax( $item, $args ) {

/**
* Get a product (either product or variation).
* @deprecated Add deprecation notices in future release. Replaced with $item->get_product()
* @deprecated 4.4.0
* @param object $item
* @return WC_Product|bool
*/
public function get_product_from_item( $item ) {
wc_deprecated_function( 'WC_Abstract_Legacy_Order::get_product_from_item', '4.4.0', '$item->get_product()' );
if ( is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
} else {
Expand Down Expand Up @@ -461,7 +462,7 @@ public function __get( $key ) {
* has_meta function for order items. This is different to the WC_Data
* version and should be removed in future versions.
*
* @deprecated
* @deprecated 3.0
*
* @param int $order_item_id
*
Expand Down
7 changes: 4 additions & 3 deletions includes/legacy/class-wc-legacy-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,24 +274,25 @@ private function handle_v2_rest_api_request() {
/**
* Rest API Init.
*
* @deprecated since 3.7.0 - REST API clases autoload.
* @deprecated 3.7.0 - REST API clases autoload.
*/
public function rest_api_init() {}

/**
* Include REST API classes.
*
* @deprecated since 3.7.0 - REST API clases autoload.
* @deprecated 3.7.0 - REST API clases autoload.
*/
public function rest_api_includes() {
$this->rest_api_init();
}
/**
* Register REST API routes.
*
* @deprecated since 3.7.0 - Not used.
* @deprecated 3.7.0
*/
public function register_rest_routes() {
wc_deprecated_function( 'WC_Legacy_API::register_rest_routes', '3.7.0', '' );
$this->register_wp_admin_settings();
}
}
15 changes: 8 additions & 7 deletions includes/legacy/class-wc-legacy-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function init() {
/**
* Function to apply discounts to a product and get the discounted price (before tax is applied).
*
* @deprecated Calculation and coupon logic is handled in WC_Cart_Totals.
* @deprecated 3.2.0 Calculation and coupon logic is handled in WC_Cart_Totals.
* @param mixed $values Cart item.
* @param mixed $price Price of item.
* @param bool $add_totals Legacy.
Expand Down Expand Up @@ -377,17 +377,18 @@ public function ship_to_billing_address_only() {
/**
* Coupons enabled function. Filterable.
*
* @deprecated 2.5.0 in favor to wc_coupons_enabled()
* @deprecated 2.5.0
* @return bool
*/
public function coupons_enabled() {
wc_deprecated_function( 'WC_Legacy_Cart::coupons_enabled', '2.5.0', 'wc_coupons_enabled' );
return wc_coupons_enabled();
}

/**
* Gets the total (product) discount amount - these are applied before tax.
*
* @deprecated Order discounts (after tax) removed in 2.3 so multiple methods for discounts are no longer required.
* @deprecated 2.3.0 Order discounts (after tax) removed in 2.3 so multiple methods for discounts are no longer required.
* @return mixed formatted price or false if there are none.
*/
public function get_discounts_before_tax() {
Expand All @@ -403,7 +404,7 @@ public function get_discounts_before_tax() {
/**
* Get the total of all order discounts (after tax discounts).
*
* @deprecated Order discounts (after tax) removed in 2.3.
* @deprecated 2.3.0 Order discounts (after tax) removed in 2.3.
* @return int
*/
public function get_order_discount_total() {
Expand All @@ -414,7 +415,7 @@ public function get_order_discount_total() {
/**
* Function to apply cart discounts after tax.
*
* @deprecated Coupons can not be applied after tax.
* @deprecated 2.3.0 Coupons can not be applied after tax.
* @param $values
* @param $price
*/
Expand All @@ -425,7 +426,7 @@ public function apply_cart_discounts_after_tax( $values, $price ) {
/**
* Function to apply product discounts after tax.
*
* @deprecated Coupons can not be applied after tax.
* @deprecated 2.3.0 Coupons can not be applied after tax.
*
* @param $values
* @param $price
Expand All @@ -437,7 +438,7 @@ public function apply_product_discounts_after_tax( $values, $price ) {
/**
* Gets the order discount amount - these are applied after tax.
*
* @deprecated Coupons can not be applied after tax.
* @deprecated 2.3.0 Coupons can not be applied after tax.
*/
public function get_discounts_after_tax() {
wc_deprecated_function( 'get_discounts_after_tax', '2.3' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function init() {
$this->tax_status = $this->get_option( 'tax_status' );
$this->cost = $this->get_option( 'cost' );
$this->type = $this->get_option( 'type', 'class' );
$this->options = $this->get_option( 'options', false ); // @deprecated in 2.4.0
$this->options = $this->get_option( 'options', false ); // @deprecated 2.4.0
}

/**
Expand Down
Loading

0 comments on commit 0f134ca

Please sign in to comment.