Generates and displays row action links.
Parameters
$item
arrayrequired- Site being acted upon.
$column_name
stringrequired- Current column name.
$primary
stringrequired- Primary column name.
Source
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$blog = $item;
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
// Preordered.
$actions = array(
'edit' => '',
'backend' => '',
'activate' => '',
'deactivate' => '',
'archive' => '',
'unarchive' => '',
'spam' => '',
'unspam' => '',
'delete' => '',
'visit' => '',
);
$actions['edit'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
__( 'Edit' )
);
$actions['backend'] = sprintf(
'<a href="%1$s" class="edit">%2$s</a>',
esc_url( get_admin_url( $blog['blog_id'] ) ),
__( 'Dashboard' )
);
if ( ! is_main_site( $blog['blog_id'] ) ) {
if ( '1' === $blog['deleted'] ) {
$actions['activate'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ),
'activateblog_' . $blog['blog_id']
)
),
_x( 'Activate', 'site' )
);
} else {
$actions['deactivate'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ),
'deactivateblog_' . $blog['blog_id']
)
),
__( 'Deactivate' )
);
}
if ( '1' === $blog['archived'] ) {
$actions['unarchive'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ),
'unarchiveblog_' . $blog['blog_id']
)
),
__( 'Unarchive' )
);
} else {
$actions['archive'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ),
'archiveblog_' . $blog['blog_id']
)
),
_x( 'Archive', 'verb; site' )
);
}
if ( '1' === $blog['spam'] ) {
$actions['unspam'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ),
'unspamblog_' . $blog['blog_id']
)
),
_x( 'Not Spam', 'site' )
);
} else {
$actions['spam'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ),
'spamblog_' . $blog['blog_id']
)
),
_x( 'Spam', 'site' )
);
}
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
$actions['delete'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url(
wp_nonce_url(
network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ),
'deleteblog_' . $blog['blog_id']
)
),
__( 'Delete' )
);
}
}
$actions['visit'] = sprintf(
'<a href="%1$s" rel="bookmark">%2$s</a>',
esc_url( get_home_url( $blog['blog_id'], '/' ) ),
__( 'Visit' )
);
/**
* Filters the action links displayed for each site in the Sites list table.
*
* The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
* default for each site. The site's status determines whether to show the
* 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
* 'Not Spam' or 'Spam' link for each site.
*
* @since 3.1.0
*
* @param string[] $actions An array of action links to be displayed.
* @param int $blog_id The site ID.
* @param string $blogname Site path, formatted depending on whether it is a sub-domain
* or subdirectory multisite installation.
*/
$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
return $this->row_actions( $actions );
}
Hooks
- apply_filters( ‘manage_sites_action_links’,
string[] $actions ,int $blog_id ,string $blogname ) Filters the action links displayed for each site in the Sites list table.
User Contributed Notes
You must log in before being able to contribute a note or feedback.