Code Duplication    Length = 16-17 lines in 2 locations

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

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

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

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