diff --git a/includes/list-table.php b/includes/list-table.php index 7b4cd5a0c..6d9c34cb6 100644 --- a/includes/list-table.php +++ b/includes/list-table.php @@ -402,7 +402,7 @@ function assemble_records( $column, $table = '' ) { require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php'; $all_records = array(); - // Short circuit and return empty array if we have more than 10 users, to use Ajax instead + // If the number of users exceeds the max authors constant value then return an empty array and use AJAX instead $user_count = count_users(); $total_users = $user_count['total_users']; if ( $total_users > WP_Stream_Admin::PRELOAD_AUTHORS_MAX ) { @@ -797,7 +797,7 @@ function get_column_excluded_setting_key( $column ) { $output = 'ip_addresses'; break; case 'author': - $output = 'authors_and_roles'; + $output = 'authors'; break; default: $output = false; diff --git a/includes/query.php b/includes/query.php index 0c87ea21f..4efe08756 100755 --- a/includes/query.php +++ b/includes/query.php @@ -362,7 +362,10 @@ public static function add_excluded_record_args( $args ) { $args['action__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'actions' ); // Remove record of excluded author - $args['author__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'authors_and_roles' ); + $args['author__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'authors' ); + + // Remove record of excluded author role + $args['author_role__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'roles' ); // Remove record of excluded ip $args['ip__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'ip_addresses' ); diff --git a/includes/settings.php b/includes/settings.php index 548b599ed..b53d11d68 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -846,12 +846,13 @@ public static function get_active_connectors() { } /** - * @param $column string name of the setting key (actions|ip_addresses|contexts|connectors) + * @param $column string name of the setting key (authors|roles|actions|ip_addresses|contexts|connectors) * * @return array */ public static function get_excluded_by_key( $column ) { - $option_name = 'exclude_' . $column; + $option_name = ( 'authors' === $column || 'roles' === $column ) ? 'exclude_authors_and_roles' : 'exclude_' . $column; + $excluded_values = ( isset( self::$options[ $option_name ] ) ) ? self::$options[ $option_name ] : array(); if ( is_callable( $excluded_values ) ) { @@ -860,6 +861,25 @@ public static function get_excluded_by_key( $column ) { $excluded_values = wp_list_filter( $excluded_values, array( '__placeholder__' ), 'NOT' ); + if ( 'authors' === $column || 'roles' === $column ) { + // Convert numeric strings to integers + array_walk( $excluded_values, function ( &$value ) { + if ( is_numeric( $value ) ) { + $value = absint( $value ); + } + }); + + if ( 'authors' === $column ) { + $filter = 'is_int'; // Author ID's are always integers + } + + if ( 'roles' === $column ) { + $filter = 'is_string'; // Author roles are always strings + } + + $excluded_values = array_values( array_filter( $excluded_values, $filter ) ); // Reset the array keys + } + return $excluded_values; }