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.
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 ), ) ); } |
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |