_links_add_base

The timeline below displays how wordpress function _links_add_base has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Callback to add a base URL to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @global string $_links_add_base
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    // 1 = attribute name  2 = quotation mark  3 = URL.
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols(), true)) ? $m[3] : WP_Http::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 5.5

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @global string $_links_add_base
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    // 1 = attribute name  2 = quotation mark  3 = URL.
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols(), true)) ? $m[3] : WP_Http::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 5.4

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @global string $_links_add_base
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    // 1 = attribute name  2 = quotation mark  3 = URL.
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols())) ? $m[3] : WP_Http::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 4.4

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @global string $_links_add_base
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    //1 = attribute name  2 = quotation mark  3 = URL
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols())) ? $m[3] : WP_Http::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 4.3

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @global string $_links_add_base
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    //1 = attribute name  2 = quotation mark  3 = URL
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols())) ? $m[3] : WP_HTTP::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 4.1

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    //1 = attribute name  2 = quotation mark  3 = URL
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols())) ? $m[3] : WP_HTTP::make_absolute_url($m[3], $_links_add_base)) . $m[2];
}

WordPress Version: 3.7

/**
 * Callback to add a base url to relative links in passed content.
 *
 * @since 2.7.0
 * @access private
 *
 * @param string $m The matched link.
 * @return string The processed link.
 */
function _links_add_base($m)
{
    global $_links_add_base;
    //1 = attribute name  2 = quotation mark  3 = URL
    return $m[1] . '=' . $m[2] . ((preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols())) ? $m[3] : path_join($_links_add_base, $m[3])) . $m[2];
}