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

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