Code Duplication    Length = 12-12 lines in 3 locations

includes/wc-user-functions.php 1 location

@@ 673-684 (lines=12) @@
670
 * @param string $email the customer's email.
671
 * @return string the URL to the customer's avatar.
672
 */
673
function wc_get_customer_avatar_url( $email ) {
674
	$avatar_html = get_avatar( $email );
675
676
	// Get the URL of the avatar from the provided HTML.
677
	preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
678
679
	if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
680
		return esc_url_raw( $matches[1] );
681
	}
682
683
	return null;
684
}
685

includes/cli/class-wc-cli-customer.php 1 location

@@ 634-645 (lines=12) @@
631
	 * @param  string $email the customer's email
632
	 * @return string the URL to the customer's avatar
633
	 */
634
	protected function get_avatar_url( $email ) {
635
		$avatar_html = get_avatar( $email );
636
637
		// Get the URL of the avatar from the provided HTML
638
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
639
640
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
641
			return esc_url_raw( $matches[1] );
642
		}
643
644
		return null;
645
	}
646
647
	/**
648
	 * Add/Update customer data.

includes/class-wc-customer.php 1 location

@@ 389-400 (lines=12) @@
386
	 * @since 2.7.0
387
	 * @return string
388
	 */
389
	public function get_avatar_url() {
390
		$avatar_html = get_avatar( $this->get_email() );
391
392
		// Get the URL of the avatar from the provided HTML
393
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
394
395
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
396
			return esc_url( $matches[1] );
397
		}
398
399
		return '';
400
	}
401
402
	/**
403
	 * Return the date this customer was created.