: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$email = $user->user_email;
$email_hash = md5( strtolower( trim( $email ) ) );
$args['found_avatar'] = true;
$gravatar_server = hexdec( $email_hash[0] ) % 3;
$gravatar_server = rand( 0, 2 );
'f' => $args['force_default'] ? 'y' : false,
$url = 'https://secure.gravatar.com/avatar/' . $email_hash;
$url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash );
rawurlencode_deep( array_filter( $url_args ) ),
set_url_scheme( $url, $args['scheme'] )
* Filters the avatar URL.
* @param string $url The URL of the avatar.
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
* @param array $args Arguments passed to get_avatar_data(), after processing.
$args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args );
* Filters the avatar data.
* @param array $args Arguments passed to get_avatar_data(), after processing.
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
return apply_filters( 'get_avatar_data', $args, $id_or_email );
* Retrieves the URL of a file in the theme.
* Searches in the stylesheet directory before the template directory so themes
* which inherit from a parent theme can just override one file.
* @param string $file Optional. File to search for in the stylesheet directory.
* @return string The URL of the file.
function get_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
$stylesheet_directory = get_stylesheet_directory();
$url = get_stylesheet_directory_uri();
} elseif ( get_template_directory() !== $stylesheet_directory && file_exists( $stylesheet_directory . '/' . $file ) ) {
$url = get_stylesheet_directory_uri() . '/' . $file;
$url = get_template_directory_uri() . '/' . $file;
* Filters the URL to a file in the theme.
* @param string $url The file URL.
* @param string $file The requested file to search for.
return apply_filters( 'theme_file_uri', $url, $file );
* Retrieves the URL of a file in the parent theme.
* @param string $file Optional. File to return the URL for in the template directory.
* @return string The URL of the file.
function get_parent_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
$url = get_template_directory_uri();
$url = get_template_directory_uri() . '/' . $file;
* Filters the URL to a file in the parent theme.
* @param string $url The file URL.
* @param string $file The requested file to search for.
return apply_filters( 'parent_theme_file_uri', $url, $file );
* Retrieves the path of a file in the theme.
* Searches in the stylesheet directory before the template directory so themes
* which inherit from a parent theme can just override one file.
* @param string $file Optional. File to search for in the stylesheet directory.
* @return string The path of the file.
function get_theme_file_path( $file = '' ) {
$file = ltrim( $file, '/' );
$stylesheet_directory = get_stylesheet_directory();
$template_directory = get_template_directory();
$path = $stylesheet_directory;
} elseif ( $stylesheet_directory !== $template_directory && file_exists( $stylesheet_directory . '/' . $file ) ) {
$path = $stylesheet_directory . '/' . $file;
$path = $template_directory . '/' . $file;
* Filters the path to a file in the theme.
* @param string $path The file path.
* @param string $file The requested file to search for.
return apply_filters( 'theme_file_path', $path, $file );
* Retrieves the path of a file in the parent theme.
* @param string $file Optional. File to return the path for in the template directory.
* @return string The path of the file.
function get_parent_theme_file_path( $file = '' ) {
$file = ltrim( $file, '/' );
$path = get_template_directory();
$path = get_template_directory() . '/' . $file;
* Filters the path to a file in the parent theme.
* @param string $path The file path.
* @param string $file The requested file to search for.
return apply_filters( 'parent_theme_file_path', $path, $file );
* Retrieves the URL to the privacy policy page.
* @return string The URL to the privacy policy page. Empty string if it doesn't exist.
function get_privacy_policy_url() {
$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
if ( ! empty( $policy_page_id ) && get_post_status( $policy_page_id ) === 'publish' ) {
$url = (string) get_permalink( $policy_page_id );
* Filters the URL of the privacy policy page.
* @param string $url The URL to the privacy policy page. Empty string
* @param int $policy_page_id The ID of privacy policy page.
return apply_filters( 'privacy_policy_url', $url, $policy_page_id );
* Displays the privacy policy link with formatting, when applicable.
* @param string $before Optional. Display before privacy policy link. Default empty.
* @param string $after Optional. Display after privacy policy link. Default empty.
function the_privacy_policy_link( $before = '', $after = '' ) {
echo get_the_privacy_policy_link( $before, $after );
* Returns the privacy policy link with formatting, when applicable.
* @since 6.2.0 Added 'privacy-policy' rel attribute.
* @param string $before Optional. Display before privacy policy link. Default empty.
* @param string $after Optional. Display after privacy policy link. Default empty.
* @return string Markup for the link and surrounding elements. Empty string if it
function get_the_privacy_policy_link( $before = '', $after = '' ) {
$privacy_policy_url = get_privacy_policy_url();
$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
$page_title = ( $policy_page_id ) ? get_the_title( $policy_page_id ) : '';
if ( $privacy_policy_url && $page_title ) {
'<a class="privacy-policy-link" href="%s" rel="privacy-policy">%s</a>',
esc_url( $privacy_policy_url ),
* Filters the privacy policy link.
* @param string $link The privacy policy link. Empty string if it
* @param string $privacy_policy_url The URL of the privacy policy. Empty string
$link = apply_filters( 'the_privacy_policy_link', $link, $privacy_policy_url );
return $before . $link . $after;
* Returns an array of URL hosts which are considered to be internal hosts.
* By default the list of internal hosts is comprised of the host name of
* the site's home_url() (as parsed by wp_parse_url()).
* This list is used when determining if a specified URL is a link to a page on
* the site itself or a link offsite (to an external host). This is used, for
* example, when determining if the "nofollow" attribute should be applied to a
* @see wp_is_internal_link
* @return string[] An array of URL hosts.
function wp_internal_hosts() {
if ( empty( $internal_hosts ) ) {
* Filters the array of URL hosts which are considered internal.
* @param string[] $internal_hosts An array of internal URL hostnames.
$internal_hosts = apply_filters(
wp_parse_url( home_url(), PHP_URL_HOST ),
$internal_hosts = array_unique(
array_map( 'strtolower', (array) $internal_hosts )
* Determines whether or not the specified URL is of a host included in the internal hosts list.
* @see wp_internal_hosts()
* @param string $link The URL to test.
* @return bool Returns true for internal URLs and false for all other URLs.
function wp_is_internal_link( $link ) {
$link = strtolower( $link );
if ( in_array( wp_parse_url( $link, PHP_URL_SCHEME ), wp_allowed_protocols(), true ) ) {
return in_array( wp_parse_url( $link, PHP_URL_HOST ), wp_internal_hosts(), true );