wp_admin_bar_shortlink_menu() WordPress Function

The wp_admin_bar_shortlink_menu() function displays a shortlink for the current page in the WordPress admin bar. This is useful for quickly copying and sharing links to WordPress content.

wp_admin_bar_shortlink_menu( WP_Admin_Bar $wp_admin_bar ) #

Provides a shortlink.


Parameters

$wp_admin_bar

(WP_Admin_Bar)(Required)The WP_Admin_Bar instance.


Top ↑

Source

File: wp-includes/admin-bar.php

719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
    $short = wp_get_shortlink( 0, 'query' );
    $id    = 'get-shortlink';
 
    if ( empty( $short ) ) {
        return;
    }
 
    $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
 
    $wp_admin_bar->add_node(
        array(
            'id'    => $id,
            'title' => __( 'Shortlink' ),
            'href'  => $short,
            'meta'  => array( 'html' => $html ),
        )
    );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.