| 2203 | if ( !function_exists( 'get_avatar_url' ) ) : |
| 2204 | /** |
| 2205 | * Retrieve the avatar url for a user who provided a user ID or email address. |
| 2206 | * |
| 2207 | * @uses get_avatar() Retrieves img tag string for user's avatar. |
| 2208 | * |
| 2209 | * @param int|string|object $id_or_email A user ID, email address, or comment object |
| 2210 | * @return string Empty string url not found or avatar URL. |
| 2211 | */ |
| 2212 | function get_avatar_url( $id_or_email ) { |
| 2213 | $avatar_html = get_avatar( $id_or_email ); |
| 2214 | |
| 2215 | preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches ); |
| 2216 | |
| 2217 | if ( ! empty( $matches[1] ) ) { |
| 2218 | return esc_url_raw( $matches[1] ); |
| 2219 | } |
| 2220 | |
| 2221 | return ''; |
| 2222 | } |
| 2223 | endif; |
| 2224 | |