The way of your approach is arguably wrong. One shouldn’t use add_menu_page
for external links as that function isn’t created for that purpose. Add menu page adds a page in the admin area with menu_slug
as the fourth argument.
If we take a look at add_menu_page
/dev ref
source, we can notice that whatever the URL we pass in the function is passed through plugin_basename
/ dev ref
which normalizes and replaces the path giving us the path relative to plugin directory.
Instead you can hook it to admin bar which in my opinio correct place to put external link(if this is only purpose)
function wpse243214_user_manual($wp_admin_bar) {
$wp_admin_bar->add_menu( array(
//'parent' => 'wpse-parent-id', // parent if any
'id' => 'wpse243214_usermanual',
'title' => __('User Manual'),
'href' => 'http://docs.'.basename(esc_url(home_url())),
) );
}
//change priority(15) accordingly
add_action( 'admin_bar_menu', 'wpse243214_user_manual', 15 );
With this we get
Also note that I used basename
for home_url
otherwise we get a link with http or https scheme (http://www.example.com
).