WP_MS_Users_List_Table::handle_row_actions
Generates and displays row action links.
Метод класса: WP_MS_Users_List_Table{}
Хуки из метода
Возвращает
Строку. Row actions output for users in Multisite, or an empty string if the current column is not the primary column.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->handle_row_actions( $item, $column_name, $primary );
- $item(WP_User) (обязательный)
- User being acted upon.
- $column_name(строка) (обязательный)
- Current column name.
- $primary(строка) (обязательный)
- Primary column name.
Список изменений
| С версии 4.3.0 | Введена. |
| С версии 5.9.0 | Renamed $user to $item to match parent class for PHP 8 named parameter support. |
Код WP_MS_Users_List_Table::handle_row_actions() WP MS Users List Table::handle row actions WP 6.9
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.
$user = $item;
$super_admins = get_super_admins();
$actions = array();
if ( current_user_can( 'edit_user', $user->ID ) ) {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
}
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins, true ) ) {
$actions['delete'] = '<a href="' . esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
}
/**
* Filters the action links displayed under each user in the Network Admin Users list table.
*
* @since 3.2.0
*
* @param string[] $actions An array of action links to be displayed. Default 'Edit', 'Delete'.
* @param WP_User $user WP_User object.
*/
$actions = apply_filters( 'ms_user_row_actions', $actions, $user );
return $this->row_actions( $actions );
}