Using WordPress ‘myblogs_blog_actions’ PHP filter

The myblogs_blog_actions WordPress PHP filter allows you to modify the row links displayed for each site on the My Sites screen.

Usage

add_filter('myblogs_blog_actions', 'my_custom_blog_actions', 10, 2);
function my_custom_blog_actions($actions, $user_blog) {
    // Your custom code here
    return $actions;
}

Parameters

  • $actions: string – The HTML site link markup.
  • $user_blog: object – An object containing the site data.

More information

See WordPress Developer Resources: myblogs_blog_actions

Examples

This code adds a “View Dashboard” link to each site’s row actions.

add_filter('myblogs_blog_actions', 'add_view_dashboard_link', 10, 2);
function add_view_dashboard_link($actions, $user_blog) {
    $dashboard_url = esc_url(get_admin_url($user_blog->userblog_id));
    $actions .= sprintf('<a href="%s">View Dashboard</a>', $dashboard_url);
    return $actions;
}

This code removes the “Visit” link from the site row actions.

add_filter('myblogs_blog_actions', 'remove_visit_link', 10, 2);
function remove_visit_link($actions, $user_blog) {
    $actions = preg_replace('/<a[^>]*>Visit<\/a>/', '', $actions);
    return $actions;
}

This code changes the “Visit” link text to “Open Site”.

add_filter('myblogs_blog_actions', 'change_visit_link_text', 10, 2);
function change_visit_link_text($actions, $user_blog) {
    $actions = preg_replace('/(>Visit<\/a>)/', '>Open Site</a>', $actions);
    return $actions;
}

This code adds a “Settings” link with a gear icon to the site row actions.

add_filter('myblogs_blog_actions', 'add_settings_link_with_icon', 10, 2);
function add_settings_link_with_icon($actions, $user_blog) {
    $settings_url = esc_url(get_admin_url($user_blog->userblog_id, 'options-general.php'));
    $actions .= sprintf('<a href="%s"><span class="dashicons dashicons-admin-generic"></span> Settings</a>', $settings_url);
    return $actions;
}

Wrap the site row actions in a div

This code wraps the site row actions in a div with a custom class.

add_filter('myblogs_blog_actions', 'wrap_actions_in_div', 10, 2);
function wrap_actions_in_div($actions, $user_blog) {
    $actions = sprintf('<div class="custom-actions-wrapper">%s</div>', $actions);
    return $actions;
}