Code Duplication    Length = 16-17 lines in 2 locations

modules/google-analytics/classes/wp-google-analytics-universal.php 1 location

@@ 258-274 (lines=17) @@
255
	 * @param string $url Full HTML a tag of the link to remove an item from the cart.
256
	 * @param string $key Unique Key ID for a cart item.
257
	 */
258
	public function remove_from_cart_attributes( $url, $key ) {
259
		if ( false !== strpos( $url, 'data-product_id' ) ) {
260
			return $url;
261
		}
262
263
		$item    = WC()->cart->get_cart_item( $key );
264
		$product = $item['data'];
265
266
		$new_attributes = sprintf(
267
			'" data-product_id="%1$s" data-product_sku="%2$s">',
268
			esc_attr( $product->get_id() ),
269
			esc_attr( $product->get_sku() )
270
		);
271
272
		$url = str_replace( '">', $new_attributes, $url );
273
		return $url;
274
	}
275
276
	public function listing_impression() {
277
		if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {

modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php 1 location

@@ 203-218 (lines=16) @@
200
	 *
201
	 * @return mixed.
202
	 */
203
	public function remove_from_cart_attributes( $url, $key ) {
204
		if ( false !== strpos( $url, 'data-product_id' ) ) {
205
			return $url;
206
		}
207
208
		$item    = WC()->cart->get_cart_item( $key );
209
		$product = $item['data'];
210
211
		$new_attributes = sprintf(
212
			'" data-product_id="%s">',
213
			esc_attr( $product->get_id() )
214
		);
215
216
		$url = str_replace( '">', $new_attributes, $url );
217
		return $url;
218
	}
219
220
	/**
221
	 * Gather relevant product information