wp_admin_bar_shortlink_menu

Provide a shortlink.

Description

wp_admin_bar_shortlink_menu( (WP_Admin_Bar) $wp_admin_bar ); 

Parameters (1)

0. $wp_admin_bar (WP_Admin_Bar)
The wp admin bar.

Usage

  1. if ( !function_exists( 'wp_admin_bar_shortlink_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // The wp admin bar. 
  5. $wp_admin_bar = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_admin_bar_shortlink_menu($wp_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { 
  2. $short = wp_get_shortlink( 0, 'query' ); 
  3. $id = 'get-shortlink'; 
  4.  
  5. if ( empty( $short ) ) 
  6. return; 
  7.  
  8. $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />'; 
  9.  
  10. $wp_admin_bar->add_menu( array( 
  11. 'id' => $id,  
  12. 'title' => __( 'Shortlink' ),  
  13. 'href' => $short,  
  14. 'meta' => array( 'html' => $html ),  
  15. ) );