get_shortcut_link

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

WordPress Version: 6.3

/**
 * Retrieves the Press This bookmarklet link.
 *
 * @since 2.6.0
 * @deprecated 4.9.0
 * @return string
 */
function get_shortcut_link()
{
    _deprecated_function(__FUNCTION__, '4.9.0');
    $link = '';
    /**
     * Filters the Press This bookmarklet link.
     *
     * @since 2.6.0
     * @deprecated 4.9.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.9

/**
 * Retrieves the Press This bookmarklet link.
 *
 * @since 2.6.0
 * @deprecated 4.9.0
 *
 */
function get_shortcut_link()
{
    _deprecated_function(__FUNCTION__, '4.9.0');
    $link = '';
    /**
     * Filters the Press This bookmarklet link.
     *
     * @since 2.6.0
     * @deprecated 4.9.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.7

/**
 * Retrieves the Press This bookmarklet link.
 *
 * @since 2.6.0
 *
 * @global bool          $is_IE      Whether the browser matches an Internet Explorer user agent.
 */
function get_shortcut_link()
{
    global $is_IE;
    include_once ABSPATH . 'wp-admin/includes/class-wp-press-this.php';
    $link = '';
    if ($is_IE) {
        /*
         * Return the old/shorter bookmarklet code for MSIE 8 and lower,
         * since they only support a max length of ~2000 characters for
         * bookmark[let] URLs, which is way to small for our smarter one.
         * Do update the version number so users do not get the "upgrade your
         * bookmarklet" notice when using PT in those browsers.
         */
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (!empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) {
            $url = wp_json_encode(admin_url('press-this.php'));
            $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . WP_Press_This::VERSION . '";' . 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
        }
    }
    if (empty($link)) {
        $src = @file_get_contents(ABSPATH . 'wp-admin/js/bookmarklet.min.js');
        if ($src) {
            $url = wp_json_encode(admin_url('press-this.php') . '?v=' . WP_Press_This::VERSION);
            $link = 'javascript:' . str_replace('window.pt_url', $url, $src);
        }
    }
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filters the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.6

/**
 * Retrieves the Press This bookmarklet link.
 *
 * @since 2.6.0
 *
 * @global bool   $is_IE      Whether the browser matches an Internet Explorer user agent.
 * @global string $wp_version WP version.
 *
 * @global bool          $is_IE
 * @global string        $wp_version
 * @global WP_Press_This $wp_press_this
 *
 * @return string The Press This bookmarklet link URL.
 */
function get_shortcut_link()
{
    global $is_IE, $wp_version;
    include_once ABSPATH . 'wp-admin/includes/class-wp-press-this.php';
    $bookmarklet_version = $GLOBALS['wp_press_this']->version;
    $link = '';
    if ($is_IE) {
        /*
         * Return the old/shorter bookmarklet code for MSIE 8 and lower,
         * since they only support a max length of ~2000 characters for
         * bookmark[let] URLs, which is way to small for our smarter one.
         * Do update the version number so users do not get the "upgrade your
         * bookmarklet" notice when using PT in those browsers.
         */
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (!empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) {
            $url = wp_json_encode(admin_url('press-this.php'));
            $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' . 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
        }
    }
    if (empty($link)) {
        $src = @file_get_contents(ABSPATH . 'wp-admin/js/bookmarklet.min.js');
        if ($src) {
            $url = wp_json_encode(admin_url('press-this.php') . '?v=' . $bookmarklet_version);
            $link = 'javascript:' . str_replace('window.pt_url', $url, $src);
        }
    }
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filters the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.3

/**
 * Retrieve the Press This bookmarklet link.
 *
 * Use this in 'a' element 'href' attribute.
 *
 * @since 2.6.0
 *
 * @global bool          $is_IE
 * @global string        $wp_version
 * @global WP_Press_This $wp_press_this
 *
 * @return string The Press This bookmarklet link URL.
 */
function get_shortcut_link()
{
    global $is_IE, $wp_version;
    include_once ABSPATH . 'wp-admin/includes/class-wp-press-this.php';
    $bookmarklet_version = $GLOBALS['wp_press_this']->version;
    $link = '';
    if ($is_IE) {
        /**
         * Return the old/shorter bookmarklet code for MSIE 8 and lower,
         * since they only support a max length of ~2000 characters for
         * bookmark[let] URLs, which is way to small for our smarter one.
         * Do update the version number so users do not get the "upgrade your
         * bookmarklet" notice when using PT in those browsers.
         */
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (!empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) {
            $url = wp_json_encode(admin_url('press-this.php'));
            $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' . 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
        }
    }
    if (empty($link)) {
        $src = @file_get_contents(ABSPATH . 'wp-admin/js/bookmarklet.min.js');
        if ($src) {
            $url = wp_json_encode(admin_url('press-this.php') . '?v=' . $bookmarklet_version);
            $link = 'javascript:' . str_replace('window.pt_url', $url, $src);
        }
    }
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filter the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.2

/**
 * Retrieve the Press This bookmarklet link.
 *
 * Use this in 'a' element 'href' attribute.
 *
 * @since 2.6.0
 *
 * @return string The Press This bookmarklet link URL.
 */
function get_shortcut_link()
{
    global $is_IE, $wp_version;
    include_once ABSPATH . 'wp-admin/includes/class-wp-press-this.php';
    $bookmarklet_version = $GLOBALS['wp_press_this']->version;
    $link = '';
    if ($is_IE) {
        /**
         * Return the old/shorter bookmarklet code for MSIE 8 and lower,
         * since they only support a max length of ~2000 characters for
         * bookmark[let] URLs, which is way to small for our smarter one.
         * Do update the version number so users do not get the "upgrade your
         * bookmarklet" notice when using PT in those browsers.
         */
        $ua = $_SERVER['HTTP_USER_AGENT'];
        if (!empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) {
            $url = wp_json_encode(admin_url('press-this.php'));
            $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' . 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
        }
    }
    if (empty($link)) {
        $src = @file_get_contents(ABSPATH . 'wp-admin/js/bookmarklet.min.js');
        if ($src) {
            $url = wp_json_encode(admin_url('press-this.php') . '?v=' . $bookmarklet_version);
            $link = 'javascript:' . str_replace('window.pt_url', $url, $src);
        }
    }
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filter the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 4.1

/**
 * Retrieve the Press This bookmarklet link.
 *
 * Use this in 'a' element 'href' attribute.
 *
 * @since 2.6.0
 *
 * @return string The Press This bookmarklet link URL.
 */
function get_shortcut_link()
{
    // In case of breaking changes, version this. #WP20071
    $link = "javascript:\n\t\t\tvar d=document,\n\t\t\tw=window,\n\t\t\te=w.getSelection,\n\t\t\tk=d.getSelection,\n\t\t\tx=d.selection,\n\t\t\ts=(e?e():(k)?k():(x?x.createRange().text:0)),\n\t\t\tf='" . admin_url('press-this.php') . "',\n\t\t\tl=d.location,\n\t\t\te=encodeURIComponent,\n\t\t\tu=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';\n\t\t\ta=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};\n\t\t\tif (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();\n\t\t\tvoid(0)";
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filter the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 3.9

/**
 * Retrieve the Press This bookmarklet link.
 *
 * Use this in 'a' element 'href' attribute.
 *
 * @since 2.6.0
 *
 * @return string
 */
function get_shortcut_link()
{
    // In case of breaking changes, version this. #WP20071
    $link = "javascript:\n\t\t\tvar d=document,\n\t\t\tw=window,\n\t\t\te=w.getSelection,\n\t\t\tk=d.getSelection,\n\t\t\tx=d.selection,\n\t\t\ts=(e?e():(k)?k():(x?x.createRange().text:0)),\n\t\t\tf='" . admin_url('press-this.php') . "',\n\t\t\tl=d.location,\n\t\t\te=encodeURIComponent,\n\t\t\tu=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';\n\t\t\ta=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};\n\t\t\tif (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();\n\t\t\tvoid(0)";
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    /**
     * Filter the Press This bookmarklet link.
     *
     * @since 2.6.0
     *
     * @param string $link The Press This bookmarklet link.
     */
    return apply_filters('shortcut_link', $link);
}

WordPress Version: 3.7

/**
 * Retrieve the Press This bookmarklet link.
 *
 * Use this in 'a' element 'href' attribute.
 *
 * @since 2.6.0
 *
 * @return string
 */
function get_shortcut_link()
{
    // In case of breaking changes, version this. #WP20071
    $link = "javascript:\n\t\t\tvar d=document,\n\t\t\tw=window,\n\t\t\te=w.getSelection,\n\t\t\tk=d.getSelection,\n\t\t\tx=d.selection,\n\t\t\ts=(e?e():(k)?k():(x?x.createRange().text:0)),\n\t\t\tf='" . admin_url('press-this.php') . "',\n\t\t\tl=d.location,\n\t\t\te=encodeURIComponent,\n\t\t\tu=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';\n\t\t\ta=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};\n\t\t\tif (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();\n\t\t\tvoid(0)";
    $link = str_replace(array("\r", "\n", "\t"), '', $link);
    return apply_filters('shortcut_link', $link);
}