WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#14127 closed enhancement (worksforme)

Dashboard feed widgets should open entries in new tabs

Reported by: IndigoJo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: General Keywords:
Focuses: Cc:

Description

The widgets which track feeds like WP Planet, etc. and incoming links should open entries in new tabs rather than replacing the WP admin interface, or at least provide an option for this. Only internal links should open in the same tab, so that the tab remains reserved for administering the site, rather than for viewing extraneous content (not all of it relevant to the site itself).

Change History (7)

comment:1 scribu4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

What prevents you from doing Right-Click -> Open in new tab (or even scroll-press)?

If you want to enable this functionality for an unknowing client, you should install a plugin that opens _all_ external links from the admin in a new window. This can be achieved with a few lines of javascript.

comment:2 scribu4 years ago

And here is said javascript:

jQuery(document).click(function(ev) {
	var url = jQuery(ev.target).attr('href'), undefined;

	if ( undefined == url )
		return;

    if ( 0 != url.indexOf(location.protocol + '//' + location.host) ) {
		window.open(url);
		return false;
	}
});

comment:3 filosofo4 years ago

scribu's right: there's no reason to make a general penalty for users so long as you have the scroll click available.


	if ( undefined == url )
		return;

What does that get you that if ( ! url ) doesn't?

    if ( 0 != url.indexOf(location.protocol + '//' + location.host) ) {
		window.open(url);
		return false;
	}

The problem is that in the WP admin, the internal links are not absolute, so you'll be opening them in new windows too.

comment:4 follow-up: scribu4 years ago

What does that get you that if ( ! url ) doesn't?

You're right.

The problem is that in the WP admin, the internal links are not absolute, so you'll be opening them in new windows too.

Good observation, yet it works, because they're automatically translated into absolute URLs in JavaScript land.

comment:6 in reply to: ↑ 4 filosofo4 years ago

Replying to scribu:

Good observation, yet it works, because they're automatically translated into absolute URLs in JavaScript land.

Yes and no, depending on what you're getting and the client you're doing it in.

Yes in IE--you get the full path. But in Firefox it depends:

  • The href property of the target has the full path.
  • But the "href" attribute has its actual value, here not absolute.

In this case

jQuery(ev.target).attr('href')

is equivalent to

ev.target.getAttribute('href') // relative path

not

ev.target.href // absolute path

comment:7 scribu4 years ago

Thanks for pointing that out. :)

Updated the tutorial.

Note: See TracTickets for help on using tickets.