Ready to get started?Download WordPress


Short link maker
possible addition to theme or plugin - admin bar button (1 post)

  1. asafche
    Posted 2 years ago #

    place this code inside your theme functions.php, of (for this plugin developer) inside plugin code, for adding a shortlink to the admin bar.
    for those who would like to have this button also without dependence in "short link maker" plugin, if the plugin isn't working or is absent, it will show the numeric default worpress link.

    function wp_shortlink_adminbar() {
        global $wp_admin_bar, $wpdb, $post;
        if ( !is_user_logged_in() || !is_admin_bar_showing() )
    	if ( function_exists('get_shortlink') ) {
        $shortlink = get_shortlink($post->post_ID);
    	} else $shortlink = get_site_url().'/?p='.$post->ID;
        /* Add the main siteadmin menu item */
        $wp_admin_bar->add_menu( array( 'id' => 'shortlink', 'title' => __( 'Shortlink', 'textdomain' ), 'href' => FALSE ) );
        $wp_admin_bar->add_menu( array( 'parent' => 'shortlink', 'title' => $shortlink, 'href' => FALSE ) );
        add_action( 'admin_bar_menu', 'wp_shortlink_adminbar', 1000 );


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic