Merge pull request #19710 from javorszky/issue/19704
Cast post IDs to integers in admin meta boxes for coupons, products, orders
This commit is contained in:
commit
d8502349c1
|
@ -27,7 +27,8 @@ class WC_Meta_Box_Coupon_Data {
|
|||
public static function output( $post ) {
|
||||
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
|
||||
|
||||
$coupon = new WC_Coupon( $post->ID );
|
||||
$coupon_id = absint( $post->ID );
|
||||
$coupon = new WC_Coupon( $coupon_id );
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ class WC_Order_Factory {
|
|||
global $post;
|
||||
|
||||
if ( false === $order && is_a( $post, 'WP_Post' ) && 'shop_order' === get_post_type( $post ) ) {
|
||||
return $post->ID;
|
||||
return absint( $post->ID );
|
||||
} elseif ( is_numeric( $order ) ) {
|
||||
return $order;
|
||||
} elseif ( $order instanceof WC_Abstract_Order ) {
|
||||
|
|
|
@ -102,8 +102,10 @@ class WC_Product_Factory {
|
|||
* @return int|bool false on failure
|
||||
*/
|
||||
private function get_product_id( $product ) {
|
||||
if ( false === $product && isset( $GLOBALS['post'], $GLOBALS['post']->ID ) && 'product' === get_post_type( $GLOBALS['post']->ID ) ) {
|
||||
return $GLOBALS['post']->ID;
|
||||
global $post;
|
||||
|
||||
if ( false === $product && isset( $post, $post->ID ) && 'product' === get_post_type( $post->ID ) ) {
|
||||
return absint( $post->ID );
|
||||
} elseif ( is_numeric( $product ) ) {
|
||||
return $product;
|
||||
} elseif ( $product instanceof WC_Product ) {
|
||||
|
|
Loading…
Reference in New Issue