diff --git src/bp-core/admin/bp-core-admin-optouts.php src/bp-core/admin/bp-core-admin-optouts.php
index a80b188e4..5df6047d0 100644
--- src/bp-core/admin/bp-core-admin-optouts.php
+++ src/bp-core/admin/bp-core-admin-optouts.php
@@ -55,40 +55,49 @@ function bp_core_optouts_admin_load() {
 		// The per_page screen option.
 		add_screen_option( 'per_page', array( 'label' => _x( 'Nonmember opt-outs', 'Nonmember opt-outs per page (screen options)', 'buddypress' ) ) );
 
-		get_current_screen()->add_help_tab( array(
-			'id'      => 'bp-optouts-overview',
-			'title'   => __( 'Overview', 'buddypress' ),
-			'content' =>
-			'<p>' . __( 'This is the administration screen for nonmember opt-outs on your site.', 'buddypress' ) . '</p>' .
-			'<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' .
-			'<p>' . __( 'You can reorder the list of opt-outs by clicking on the Email Address, User Who Contacted, Email Type or Date Modified column headers.', 'buddypress' ) . '</p>' .
-			'<p>' . __( 'Using the search form, you can search for an opt-out to a specific email address.', 'buddypress' ) . '</p>'
-		) );
-
-		get_current_screen()->add_help_tab( array(
-			'id'      => 'bp-optouts-actions',
-			'title'   => __( 'Actions', 'buddypress' ),
-			'content' =>
-			'<p>' . __( 'Hovering over a row in the opt-outs list will display action links that allow you to manage the opt-out. You can perform the following actions:', 'buddypress' ) . '</p>' .
-			'<ul><li>' . __( '"Delete" allows you to delete the record of an opt-out. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>' .
-			'<p>' . __( 'Bulk actions allow you to perform these actions for the selected rows.', 'buddypress' ) . '</p>'
-		) );
+		// Current screen.
+		$current_screen = get_current_screen();
+
+		$current_screen->add_help_tab(
+			array(
+				'id'      => 'bp-optouts-overview',
+				'title'   => __( 'Overview', 'buddypress' ),
+				'content' =>
+					'<p>' . __( 'This is the administration screen for nonmember opt-outs on your site.', 'buddypress' ) . '</p>' .
+					'<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' .
+					'<p>' . __( 'You can reorder the list of opt-outs by clicking on the Email Address, User Who Contacted, Email Type or Date Modified column headers.', 'buddypress' ) . '</p>' .
+					'<p>' . __( 'Using the search form, you can search for an opt-out to a specific email address.', 'buddypress' ) . '</p>',
+			)
+		);
+
+		$current_screen->add_help_tab(
+			array(
+				'id'      => 'bp-optouts-actions',
+				'title'   => __( 'Actions', 'buddypress' ),
+				'content' =>
+					'<p>' . __( 'Hovering over a row in the opt-outs list will display action links that allow you to manage the opt-out. You can perform the following actions:', 'buddypress' ) . '</p>' .
+					'<ul><li>' . __( '"Delete" allows you to delete the record of an opt-out. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>' .
+					'<p>' . __( 'Bulk actions allow you to perform these actions for the selected rows.', 'buddypress' ) . '</p>',
+			)
+		);
 
 		// Help panel - sidebar links.
-		get_current_screen()->set_help_sidebar(
+		$current_screen->set_help_sidebar(
 			'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
 			'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
 		);
 
 		// Add accessible hidden headings and text for the Pending Users screen.
-		get_current_screen()->set_screen_reader_content( array(
-			/* translators: accessibility text */
-			'heading_views'      => __( 'Filter opt-outs list', 'buddypress' ),
-			/* translators: accessibility text */
-			'heading_pagination' => __( 'Opt-out list navigation', 'buddypress' ),
-			/* translators: accessibility text */
-			'heading_list'       => __( 'Opt-outs list', 'buddypress' ),
-		) );
+		$current_screen->set_screen_reader_content(
+			array(
+				/* translators: accessibility text */
+				'heading_views'      => __( 'Filter opt-outs list', 'buddypress' ),
+				/* translators: accessibility text */
+				'heading_pagination' => __( 'Opt-out list navigation', 'buddypress' ),
+				/* translators: accessibility text */
+				'heading_list'       => __( 'Opt-outs list', 'buddypress' ),
+			)
+		);
 
 	} else {
 		if ( empty( $_REQUEST['optout_ids' ] ) ) {
@@ -233,7 +242,7 @@ function bp_core_optouts_admin() {
 
 		<?php endif; ?>
 
-			<p><?php echo $notice['message']; ?></p>
+			<p><?php echo esc_html( $notice['message'] ); ?></p>
 		</div>
 
 	<?php endif;
@@ -299,7 +308,8 @@ function bp_core_optouts_admin_index() {
 			'action2',
 			'_wpnonce',
 			'optout_ids'
-		), $_SERVER['REQUEST_URI']
+		),
+		$_SERVER['REQUEST_URI']
 	);
 
 	?>
@@ -309,10 +319,11 @@ function bp_core_optouts_admin_index() {
 
 		<?php
 		if ( $usersearch ) {
-			printf( '<span class="subtitle">' . __( 'Opt-outs with an email address matching &#8220;%s&#8221;', 'buddypress' ) . '</span>', esc_html( $usersearch ) );
+			$num_results = (int) $bp_optouts_list_table->total_items;
+			printf( '<span class="subtitle">' . esc_html( _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' ) ) . '</span>', esc_html( $usersearch ) );
 		}
 		?>
-		<p class="description"><?php _e( 'This table shows opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to receive no further communications.', 'buddypress' ); ?></p>
+		<p class="description"><?php esc_html_e( 'This table shows opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to receive no further communications.', 'buddypress' ); ?></p>
 
 		<hr class="wp-header-end">
 
@@ -321,7 +332,7 @@ function bp_core_optouts_admin_index() {
 
 		<form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">
 			<input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
-			<?php $bp_optouts_list_table->search_box( __( 'Search for a specific email address', 'buddypress' ), 'bp-optouts' ); ?>
+			<?php $bp_optouts_list_table->search_box( esc_html__( 'Search for a specific email address', 'buddypress' ), 'bp-optouts' ); ?>
 		</form>
 
 		<form id="bp-optouts-form" action="<?php echo esc_url( $form_url );?>" method="post">
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index 88e4b651b..e56c7453f 100644
--- src/bp-core/bp-core-functions.php
+++ src/bp-core/bp-core-functions.php
@@ -4247,16 +4247,19 @@ function bp_get_widget_max_count_limit( $widget_class = '' ) {
  *                                 prompted the user to opt-out.
  *     @type string $date_modified Optional. Specify a time, else now will be used.
  * }
- * @return false | int False on failure, ID of new (or existing) opt-out if successful.
+ * @return false|int False on failure, ID of new (or existing) opt-out if successful.
  */
 function bp_add_optout( $args = array() ) {
 	$optout = new BP_Optout();
-	$r = bp_parse_args( $args, array(
-		'email_address'     => '',
-		'user_id'           => 0,
-		'email_type'        => '',
-		'date_modified'     => bp_core_current_time(),
-	), 'add_optout' );
+	$r      = bp_parse_args(
+		$args, array(
+			'email_address' => '',
+			'user_id'       => 0,
+			'email_type'    => '',
+			'date_modified' => bp_core_current_time(),
+		),
+		'add_optout'
+	);
 
 	// Opt-outs must have an email address.
 	if ( empty( $r['email_address'] ) ) {
@@ -4264,11 +4267,13 @@ function bp_add_optout( $args = array() ) {
 	}
 
 	// Avoid creating duplicate opt-outs.
-	$optout_id = $optout->optout_exists( array(
-		'email_address' => $r['email_address'],
-		'user_id'       => $r['user_id'],
-		'email_type'    => $r['email_type'],
-	) );
+	$optout_id = $optout->optout_exists(
+		array(
+			'email_address' => $r['email_address'],
+			'user_id'       => $r['user_id'],
+			'email_type'    => $r['email_type'],
+		)
+	);
 
 	if ( ! $optout_id ) {
 		// Set up the new opt-out.
@@ -4289,6 +4294,9 @@ function bp_add_optout( $args = array() ) {
  * @since 8.0.0
  *
  * @see BP_Optout::get() for a description of parameters and return values.
+ *
+ * @param array $args See {@link BP_Optout::get()}.
+ * @return array See {@link BP_Optout::get()}.
  */
 function bp_get_optouts( $args = array() ) {
 	$optout_class = new BP_Optout();
@@ -4301,6 +4309,7 @@ function bp_get_optouts( $args = array() ) {
  * @since 8.0.0
  *
  * @param int $id ID of the optout to delete.
+ * @return bool True on success, false on failure.
  */
 function bp_delete_optout_by_id( $id = 0 ) {
 	$optout_class = new BP_Optout();
diff --git src/bp-core/classes/class-bp-optout.php src/bp-core/classes/class-bp-optout.php
index 6d7725c34..b9a4822a6 100644
--- src/bp-core/classes/class-bp-optout.php
+++ src/bp-core/classes/class-bp-optout.php
@@ -282,7 +282,7 @@ class BP_Optout {
 
 		// id.
 		if ( false !== $args['id'] ) {
-			$id_in = implode( ',', wp_parse_id_list( $args['id'] ) );
+			$id_in                  = implode( ',', wp_parse_id_list( $args['id'] ) );
 			$where_conditions['id'] = "id IN ({$id_in})";
 		}
 
@@ -323,7 +323,7 @@ class BP_Optout {
 				$et_clean[] = $wpdb->prepare( '%s', sanitize_key( $et ) );
 			}
 
-			$et_in = implode( ',', $et_clean );
+			$et_in                          = implode( ',', $et_clean );
 			$where_conditions['email_type'] = "email_type IN ({$et_in})";
 		}
 
@@ -463,25 +463,25 @@ class BP_Optout {
 		// id.
 		if ( ! empty( $args['id'] ) ) {
 			$where_clauses['data']['id'] = absint( $args['id'] );
-			$where_clauses['format'][] = '%d';
+			$where_clauses['format'][]   = '%d';
 		}
 
 		// email_address.
 		if ( ! empty( $args['email_address'] ) ) {
 			$where_clauses['data']['email_address_hash'] = $args['email_address'];
-			$where_clauses['format'][] = '%s';
+			$where_clauses['format'][]                   = '%s';
 		}
 
 		// user_id.
 		if ( ! empty( $args['user_id'] ) ) {
 			$where_clauses['data']['user_id'] = absint( $args['user_id'] );
-			$where_clauses['format'][] = '%d';
+			$where_clauses['format'][]        = '%d';
 		}
 
 		// email_type.
 		if ( ! empty( $args['email_type'] ) ) {
 			$where_clauses['data']['email_type'] = $args['email_type'];
-			$where_clauses['format'][] = '%s';
+			$where_clauses['format'][]           = '%s';
 		}
 
 		return $where_clauses;
@@ -530,18 +530,22 @@ class BP_Optout {
 		$optouts_table_name = BP_Optout::get_table_name();
 
 		// Parse the arguments.
-		$r  = bp_parse_args( $args, array(
-			'id'                => false,
-			'email_address'     => false,
-			'user_id'           => false,
-			'email_type'        => false,
-			'search_terms'      => '',
-			'order_by'          => false,
-			'sort_order'        => false,
-			'page'              => false,
-			'per_page'          => false,
-			'fields'            => 'all',
-		), 'bp_optout_get' );
+		$r = bp_parse_args(
+			$args,
+			array(
+				'id'            => false,
+				'email_address' => false,
+				'user_id'       => false,
+				'email_type'    => false,
+				'search_terms'  => '',
+				'order_by'      => false,
+				'sort_order'    => false,
+				'page'          => false,
+				'per_page'      => false,
+				'fields'        => 'all',
+			),
+			'bp_optout_get'
+		);
 
 		$sql = array(
 			'select'     => "SELECT",
@@ -561,25 +565,31 @@ class BP_Optout {
 		}
 
 		// WHERE.
-		$sql['where'] = self::get_where_sql( array(
-			'id'            => $r['id'],
-			'email_address' => $r['email_address'],
-			'user_id'       => $r['user_id'],
-			'email_type'    => $r['email_type'],
-			'search_terms'  => $r['search_terms'],
-		) );
+		$sql['where'] = self::get_where_sql(
+			array(
+				'id'            => $r['id'],
+				'email_address' => $r['email_address'],
+				'user_id'       => $r['user_id'],
+				'email_type'    => $r['email_type'],
+				'search_terms'  => $r['search_terms'],
+			)
+		);
 
 		// ORDER BY.
-		$sql['orderby'] = self::get_order_by_sql( array(
-			'order_by'   => $r['order_by'],
-			'sort_order' => $r['sort_order']
-		) );
+		$sql['orderby'] = self::get_order_by_sql(
+			array(
+				'order_by'   => $r['order_by'],
+				'sort_order' => $r['sort_order']
+			)
+		);
 
 		// LIMIT %d, %d.
-		$sql['pagination'] = self::get_paged_sql( array(
-			'page'     => $r['page'],
-			'per_page' => $r['per_page'],
-		) );
+		$sql['pagination'] = self::get_paged_sql(
+			array(
+				'page'     => $r['page'],
+				'per_page' => $r['per_page'],
+			)
+		);
 
 		$paged_optouts_sql = "{$sql['select']} {$sql['fields']} {$sql['from']} {$sql['where']} {$sql['orderby']} {$sql['pagination']}";
 
@@ -643,18 +653,22 @@ class BP_Optout {
 		$optouts_table_name = BP_Optout::get_table_name();
 
 		// Parse the arguments.
-		$r  = bp_parse_args( $args, array(
-			'id'                => false,
-			'email_address'     => false,
-			'user_id'           => false,
-			'email_type'        => false,
-			'search_terms'      => '',
-			'order_by'          => false,
-			'sort_order'        => false,
-			'page'              => false,
-			'per_page'          => false,
-			'fields'            => 'all',
-		), 'bp_optout_get_total_count' );
+		$r  = bp_parse_args(
+			$args,
+			array(
+				'id'            => false,
+				'email_address' => false,
+				'user_id'       => false,
+				'email_type'    => false,
+				'search_terms'  => '',
+				'order_by'      => false,
+				'sort_order'    => false,
+				'page'          => false,
+				'per_page'      => false,
+				'fields'        => 'all',
+			),
+			'bp_optout_get_total_count'
+		);
 
 		// Build the query
 		$select_sql = "SELECT COUNT(*)";
@@ -700,9 +714,9 @@ class BP_Optout {
 		$retval = self::_update( $update['data'], $where['data'], $update['format'], $where['format'] );
 
 		// Clear matching items from the cache.
-		$cache_args = $where_args;
+		$cache_args           = $where_args;
 		$cache_args['fields'] = 'ids';
-		$maybe_cached_ids = self::get( $cache_args );
+		$maybe_cached_ids     = self::get( $cache_args );
 		foreach ( $maybe_cached_ids as $invite_id ) {
 			wp_cache_delete( $invite_id, 'bp_optouts' );
 		}
@@ -747,9 +761,9 @@ class BP_Optout {
 		do_action( 'bp_optout_before_delete', $args );
 
 		// Clear matching items from the cache.
-		$cache_args = $args;
+		$cache_args           = $args;
 		$cache_args['fields'] = 'ids';
-		$maybe_cached_ids = self::get( $cache_args );
+		$maybe_cached_ids     = self::get( $cache_args );
 		foreach ( $maybe_cached_ids as $invite_id ) {
 			wp_cache_delete( $invite_id, 'bp_optouts' );
 		}
@@ -783,10 +797,11 @@ class BP_Optout {
 		$exists = false;
 
 		$args['fields'] = 'ids';
-		$optouts = BP_Optout::get( $args );
+		$optouts        = BP_Optout::get( $args );
 		if ( $optouts ) {
 			$exists = current( $optouts );
 		}
+
 		return $exists;
 	}
 
@@ -806,5 +821,4 @@ class BP_Optout {
 			'id' => $id,
 		) );
 	}
-
 }
diff --git src/bp-core/classes/class-bp-optouts-list-table.php src/bp-core/classes/class-bp-optouts-list-table.php
index 7615583d8..5201c9172 100644
--- src/bp-core/classes/class-bp-optouts-list-table.php
+++ src/bp-core/classes/class-bp-optouts-list-table.php
@@ -33,12 +33,14 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 	 */
 	public function __construct() {
 		// Define singular and plural labels, as well as whether we support AJAX.
-		parent::__construct( array(
-			'ajax'     => false,
-			'plural'   => 'optouts',
-			'singular' => 'optout',
-			'screen'   => get_current_screen()->id,
-		) );
+		parent::__construct(
+			array(
+				'ajax'     => false,
+				'plural'   => 'optouts',
+				'singular' => 'optout',
+				'screen'   => get_current_screen()->id,
+			)
+		);
 	}
 
 	/**
@@ -57,11 +59,11 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 		$paged    = $this->get_pagenum();
 
 		$args = array(
-			'search_terms'      => $search,
-			'order_by'          => 'date_modified',
-			'sort_order'        => 'DESC',
-			'page'              => $paged,
-			'per_page'          => $per_page,
+			'search_terms' => $search,
+			'order_by'     => 'date_modified',
+			'sort_order'   => 'DESC',
+			'page'         => $paged,
+			'per_page'     => $per_page,
 		);
 
 		if ( isset( $_REQUEST['orderby'] ) ) {
@@ -76,10 +78,12 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 		$optouts_class     = new BP_Optout();
 		$this->total_items = $optouts_class->get_total_count( $args );
 
-		$this->set_pagination_args( array(
-			'total_items' => $this->total_items,
-			'per_page'    => $per_page,
-		) );
+		$this->set_pagination_args(
+			array(
+				'total_items' => $this->total_items,
+				'per_page'    => $per_page,
+			)
+		);
 	}
 
 	/**
@@ -102,10 +106,12 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 		);
 		?>
 
-		<h2 class="screen-reader-text"><?php
-			/* translators: accessibility text */
-			_e( 'Filter opt-outs list', 'buddypress' );
-		?></h2>
+		<h2 class="screen-reader-text">
+			<?php
+				/* translators: accessibility text */
+				esc_html_e( 'Filter opt-outs list', 'buddypress' );
+			?>
+		</h2>
 		<ul class="subsubsub">
 			<?php
 			/**
@@ -150,15 +156,18 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 		 *
 		 * @param array $value Array of columns to display.
 		 */
-		return apply_filters( 'bp_optouts_list_columns', array(
-			'cb'                       => '<input type="checkbox" />',
-			'email_address'            => __( 'Email Address Hash',    'buddypress' ),
-			'username'                 => __( 'Email Sender',        'buddypress' ),
-			'user_registered'          => __( 'Email Sender Registered',        'buddypress' ),
-			'email_type'               => __( 'Email Type', 'buddypress' ),
-			'email_type_description'   => __( 'Email Description', 'buddypress' ),
-			'optout_date_modified'     => __( 'Date Modified',   'buddypress' ),
-		) );
+		return apply_filters(
+			'bp_optouts_list_columns',
+			array(
+				'cb'                     => '<input type="checkbox" />',
+				'email_address'          => __( 'Email Address Hash', 'buddypress' ),
+				'username'               => __( 'Email Sender', 'buddypress' ),
+				'user_registered'        => __( 'Email Sender Registered', 'buddypress' ),
+				'email_type'             => __( 'Email Type', 'buddypress' ),
+				'email_type_description' => __( 'Email Description', 'buddypress' ),
+				'optout_date_modified'   => __( 'Date Modified', 'buddypress' ),
+			)
+		);
 	}
 
 	/**
@@ -192,10 +201,10 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 	 */
 	public function get_sortable_columns() {
 		return array(
-			'email_address'            => 'email_address_hash',
-			'username'                 => 'user_id',
-			'email_type'               => 'email_type',
-			'optout_date_modified'     => 'date_modified',
+			'email_address'        => 'email_address_hash',
+			'username'             => 'user_id',
+			'email_type'           => 'email_type',
+			'optout_date_modified' => 'date_modified',
 		);
 	}
 
@@ -226,7 +235,7 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 	 * @return void
 	 */
 	public function single_row( $optout = null, $style = '', $role = '', $numposts = 0 ) {
-		echo '<tr' . $style . ' id="optout-' . esc_attr( $optout->id ) . '">';
+		echo '<tr' . $style . ' id="optout-' . intval( $optout->id ) . '">';
 		echo $this->single_row_columns( $optout );
 		echo '</tr>';
 	}
@@ -240,10 +249,12 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 	 */
 	public function column_cb( $optout = null ) {
 	?>
-		<label class="screen-reader-text" for="optout_<?php echo intval( $optout->id ); ?>"><?php
-			/* translators: accessibility text */
-			printf( esc_html__( 'Select opt-out request: %s', 'buddypress' ), $optout->id );
-		?></label>
+		<label class="screen-reader-text" for="optout_<?php echo intval( $optout->id ); ?>">
+			<?php
+				/* translators: %d: accessibility text. */
+				printf( esc_html__( 'Select opt-out request: %d', 'buddypress' ), intval( $optout->id ) );
+			?>
+		</label>
 		<input type="checkbox" id="optout_<?php echo intval( $optout->id ) ?>" name="optout_ids[]" value="<?php echo esc_attr( $optout->id ) ?>" />
 		<?php
 	}
@@ -275,7 +286,7 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 			),
 			$form_url
 		);
-		$actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
+		$actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), esc_html__( 'Delete', 'buddypress' ) );
 
 		/**
 		 * Filters the row actions for each opt-out in list.
@@ -304,7 +315,7 @@ class BP_Optouts_List_Table extends WP_Users_List_Table {
 			return;
 		}
 		$user_link = bp_core_get_user_domain( $optout->user_id );
-		echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $user_link ), $inviter->user_login );
+		echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $user_link ), esc_html( $inviter->user_login ) );
 	}
 
 	/**
