I want to add a new button next to the Visit Site and Dashboard link which is visible under multisites dashboard page /wp-admin/my-sites.php
I have managed as far as adding the button here, and renaming the Visit site.
But the problem is that the link will always be the current page and not the multisite network page as the Visit site is.
Say I have 2 sites in my network, one called site-1
and the other site-2
. The link I have created will always go to https://example.com/site-1/mycustomfolder
instead of site-2
like it should.
This is the code I have so far:
add_filter( 'myblogs_blog_actions', 'my_sites_visit_site_target_blank', 10, 2 );
function my_sites_visit_site_target_blank( $actions, $user_blog ) {
$sites = get_blogs_of_user( get_current_user_id() );
foreach ( $sites as $site )
{
$to_replace = ">" . __( 'Visit' ) . '</a>';
$to_replace_with = " target='_blank' >" . __( 'Preview 1' ) . '</a> | <a href="'.$site->siteurl.'/customfolder/" target="_blank">Preview 2</a>';
return str_replace( $to_replace, $to_replace_with, $actions );
}
}