Open "View" and "Preview" Row Links in a New Tab
Makes the View and Preview links under each post and page in admin lists open in a new browser tab.
Opens WPIDE on
Code
$wpide_row_links_new_tab = function ( $actions ) {
foreach ( array( 'view', 'preview' ) as $key ) {
if ( isset( $actions[ $key ] ) && false === strpos( $actions[ $key ], 'target=' ) ) {
$actions[ $key ] = preg_replace( '/<a /', '<a target="_blank" rel="noopener" ', $actions[ $key ], 1 );
}
}
return $actions;
};
add_filter( 'post_row_actions', $wpide_row_links_new_tab );
add_filter( 'page_row_actions', $wpide_row_links_new_tab );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.