diff --git a/includes/class-users.php b/includes/class-users.php
index 16fa3507..f5391d99 100644
--- a/includes/class-users.php
+++ b/includes/class-users.php
@@ -19,7 +19,7 @@ class Users {
*/
public static function init() {
add_filter( 'manage_users_columns', [ __CLASS__, 'manage_users_columns' ] );
- add_filter( 'manage_users_custom_column', [ __CLASS__, 'manage_users_custom_column' ], 10, 3 );
+ add_filter( 'manage_users_custom_column', [ __CLASS__, 'manage_users_custom_column' ], 99, 3 ); // priority must be higher than Jetpack's jetpack_show_connection_status (10).
add_filter( 'users_list_table_query_args', [ __CLASS__, 'users_list_table_query_args' ] );
}
@@ -30,9 +30,7 @@ public static function init() {
* @return array
*/
public static function manage_users_columns( $columns ) {
- if ( Site_Role::is_hub() ) {
- $columns['newspack_network_activity'] = __( 'Newspack Network Activity', 'newspack-network' );
- }
+ $columns['newspack_network_activity'] = __( 'Newspack Network Activity', 'newspack-network' );
if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
$columns['newspack_network_user'] = __( 'Network Original User', 'newspack-network' );
}
@@ -60,36 +58,45 @@ public static function manage_users_custom_column( $value, $column_name, $user_i
);
}
}
- if ( 'newspack_network_activity' === $column_name && Site_Role::is_hub() ) {
+ if ( 'newspack_network_activity' === $column_name ) {
$user = get_user_by( 'id', $user_id );
if ( ! $user ) {
return $value;
}
+ if ( Site_Role::is_hub() ) {
+ $last_activity = \Newspack_Network\Hub\Stores\Event_Log::get( [ 'email' => $user->user_email ], 1 );
+ if ( empty( $last_activity ) ) {
+ return '-';
+ }
- $last_activity = \Newspack_Network\Hub\Stores\Event_Log::get( [ 'email' => $user->user_email ], 1 );
-
- if ( empty( $last_activity ) ) {
- return '-';
+ $event_log_url = add_query_arg(
+ [
+ 'page' => EVENT_LOG_PAGE_SLUG,
+ 'email' => urlencode( $user->user_email ),
+ ],
+ admin_url( 'admin.php' )
+ );
+ return sprintf(
+ '%s: %s
%s',
+ __( 'Last Activity', 'newspack-network' ),
+ $last_activity[0]->get_summary(),
+ $event_log_url,
+ __( 'View all', 'newspack-network' )
+ );
+ } else {
+ $event_log_url = add_query_arg(
+ [
+ 'page' => EVENT_LOG_PAGE_SLUG,
+ 'email' => urlencode( $user->user_email ),
+ ],
+ untrailingslashit( Node\Settings::get_hub_url() ) . '/wp-admin/admin.php'
+ );
+ return sprintf(
+ '%s',
+ $event_log_url,
+ __( 'View activity', 'newspack-network' )
+ );
}
-
- $last_activity = $last_activity[0];
-
- $summary = $last_activity->get_summary();
- $event_log_url = add_query_arg(
- [
- 'page' => EVENT_LOG_PAGE_SLUG,
- 'email' => $user->user_email,
- ],
- admin_url( 'admin.php' )
- );
- return sprintf(
- '%s: %s
%s',
- __( 'Last Activity', 'newspack-network' ),
- $summary,
- $event_log_url,
- __( 'View all', 'newspack-network' )
- );
-
}
return $value;
}
@@ -106,6 +113,10 @@ public static function users_list_table_query_args( $args ) {
$args['role__in'] = explode( ',', sanitize_text_field( $_REQUEST['role__in'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $args['role'] );
}
+ if ( isset( $_REQUEST['role__not_in'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $args['role__not_in'] = explode( ',', sanitize_text_field( $_REQUEST['role__not_in'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ unset( $args['role'] );
+ }
return $args;
}
}
diff --git a/includes/hub/admin/class-nodes-list.php b/includes/hub/admin/class-nodes-list.php
index d02d43f5..1332753b 100644
--- a/includes/hub/admin/class-nodes-list.php
+++ b/includes/hub/admin/class-nodes-list.php
@@ -27,6 +27,20 @@ public static function init() {
add_action( 'admin_bar_menu', [ __CLASS__, 'admin_bar_menu' ], 100 );
}
+ /**
+ * Cache for site info responses.
+ *
+ * @var array
+ */
+ private static $node_site_info_cache = [];
+
+ /**
+ * Cache for Hub site info.
+ *
+ * @var array
+ */
+ private static $hub_site_info = false;
+
/**
* Modify columns on post type table
*
@@ -37,16 +51,32 @@ public static function posts_columns( $columns ) {
unset( $columns['date'] );
unset( $columns['stats'] );
if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
+ $sync_users_count = \Newspack_Network\Utils\Users::get_synchronized_users_count();
$sync_users_info = sprintf(
' ',
sprintf(
/* translators: list of user roles which will entail synchronization */
esc_attr__( 'Users with the following roles: %1$s (%2$d on the Hub)', 'newspack-network' ),
implode( ', ', \Newspack_Network\Utils\Users::get_synced_user_roles() ),
- \Newspack_Network\Utils\Users::get_synchronized_users_count()
+ $sync_users_count
+ )
+ );
+ /* translators: %d is the synchronizable users count. */
+ $columns['sync_users'] = sprintf( __( 'Synchronizable Users (%d)', 'newspack-network' ), $sync_users_count ) . $sync_users_info;
+ if ( isset( $_GET['_newspack_user_discrepancies'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $columns['user_discrepancies'] = __( 'Discrepancies in Sync. Users', 'newspack-network' );
+ }
+
+ $not_sync_users_info = sprintf(
+ ' ',
+ sprintf(
+ /* translators: list of user roles which will entail synchronization */
+ esc_attr__( 'Users with roles different than the following roles: %1$s (%2$d on the Hub)', 'newspack-network' ),
+ implode( ', ', \Newspack_Network\Utils\Users::get_synced_user_roles() ),
+ \Newspack_Network\Utils\Users::get_not_synchronized_users_count()
)
);
- $columns['sync_users'] = __( 'Synchronizable Users', 'newspack-network' ) . $sync_users_info;
+ $columns['not_sync_users'] = __( 'Non-synchronizable Users', 'newspack-network' ) . $not_sync_users_info;
}
$columns['links'] = __( 'Links', 'newspack-network' );
return $columns;
@@ -80,6 +110,38 @@ function ( $bookmark ) {