Order ids the plugin created in this request. */ private static $order_ids = array(); /** * Start suppressing. * * @return void */ public static function suppress() { ++self::$depth; } /** * Stop suppressing. * * @return void */ public static function release() { if ( self::$depth > 0 ) { --self::$depth; } } /** * Remember an order the plugin owns. * * @param int $order_id Order id. * @return void */ public static function mark_order( $order_id ) { self::$order_ids[ (int) $order_id ] = true; } /** * Whether a change must be skipped. * * @param int $order_id Order id, 0 when the change is not about an order. * @return bool */ public static function is_suppressed( $order_id = 0 ) { if ( self::$depth > 0 ) { return true; } return $order_id > 0 && isset( self::$order_ids[ (int) $order_id ] ); } /** * Clear the state. Tests use this. * * @return void */ public static function reset() { self::$depth = 0; self::$order_ids = array(); } }