WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#14652 closed enhancement (wontfix)

add '_parent' or '_top' to the wordpress menus 'link target' advanced options

Reported by: erikshosting Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Menus Keywords:
Focuses: Cc:

Description

The advanced menu builder option 'link target' only contains attributes _self, and _blank. This needs to be expanded to _parent, or _top.

Change History (12)

comment:1 scribu4 years ago

  • Component changed from General to Menus

comment:2 Denis-de-Bernardy4 years ago

-1. We ought to give two options: one opens a new window, the other breaks out of any frame and loads in it's own frame. And they should be labeled "current window" and "new window". Frames are too 1995, and shouldn't be used at all. And most users have no clue what those vales are anyway.

comment:3 scribu4 years ago

I agree. An 'Open in a new window' checkbox should be enough, UI wise.

comment:4 erikshosting4 years ago

'new window' and 'current window' are already options, but 'current window' is targeted to '_self', rather than '_top' or '_parent'. so there is currently no option to break out of frames.

I know that frames are "too 1995", which is even more reason to add the '_top' or '_parent' attribute so we can break them when needed.

Most casual users don't know what these options are, which is why they are already hidden as an advanced screen option. Shouldn't this advanced option be complete?

If you point me to the appropriate file, I'll start looking into adding _parent, or changing the 'current window' option from '_self', to '_parent'.

comment:5 erikshosting4 years ago

I just added a custom walker to output these attributes, but I still think that the _top $arg should be added to target options...

comment:6 nacin3 years ago

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

I agree. An 'Open in a new window' checkbox should be enough, UI wise.

Agree completely.

comment:7 davelewis@…3 years ago

I have a site where I have no choice but to use a frameset on one particular page (long ugly story involving a legacy system hosted at another domain so I can't use an iFrame since there is no way to size the iFrame to the content without access to both domains). So I need a big 'ol ugly frameset circa 1995. No choice other than maybe an external link or new window. So I need all other links in the menu to have the ability to break out of the frameset.

comment:8 scribu3 years ago

@davelewis: That's an edge case that should be handled via a plugin.

comment:9 nacin3 years ago

Followup: #17521: Menu Link Target should be a checkbox

You should be able to filter the link target for all menu items, thus preventing the need to even store target=_top in the database.

comment:10 davelewis@…3 years ago

Fair enough. I'm working on it now. I was considering making my own walker... but the filter idea sounds better. Thanks. Oh how it pains me to even have to use a frameset. But anyway...

Last edited 3 years ago by davelewis@… (previous) (diff)

comment:11 nacin3 years ago

function nacin_filter_menu_target_sorry_world( $menu_item ) {
    if ( ! is_admin() && empty( $menu_item->target ) )
        $menu_item->target = '_top';
    return $menu_item;
}
add_filter( 'wp_setup_nav_menu_item', 'nacin_filter_menu_target_sorry_world' );

That should probably work.

comment:12 davelewis@…3 years ago

Beautiful. Thanks!!! I was attempting to use the pre_link_target or pre_link_url filter along with some PHP string replacement. What's having much luck :)

Version 0, edited 3 years ago by davelewis@… (next)
Note: See TracTickets for help on using tickets.