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

@@ 151-166 (lines=16) @@
148
	 *
149
	 * @return mixed.
150
	 */
151
	public function remove_from_cart_attributes( $url, $key ) {
152
		if ( false !== strpos( $url, 'data-product_id' ) ) {
153
			return $url;
154
		}
155
156
		$item    = WC()->cart->get_cart_item( $key );
157
		$product = $item['data'];
158
159
		$new_attributes = sprintf(
160
			'" data-product_id="%s">',
161
			esc_attr( $product->get_id() )
162
		);
163
164
		$url = str_replace( '">', $new_attributes, $url );
165
		return $url;
166
	}
167
168
	/**
169
	 * Gather relevant product information