diff --git a/modules/calypsoify/class.jetpack-calypsoify.php b/modules/calypsoify/class.jetpack-calypsoify.php index 8d12b7612708..eb0874da1cdd 100644 --- a/modules/calypsoify/class.jetpack-calypsoify.php +++ b/modules/calypsoify/class.jetpack-calypsoify.php @@ -68,6 +68,8 @@ public function setup_admin() { add_action( 'manage_plugins_custom_column', array( $this, 'manage_plugins_custom_column' ), 10, 2 ); add_filter( 'bulk_actions-plugins', array( $this, 'bulk_actions_plugins' ) ); + add_action( 'current_screen', array( $this, 'attach_views_filter' ) ); + if ( 'plugins.php' === basename( $_SERVER['PHP_SELF'] ) ) { add_action( 'admin_notices', array( $this, 'plugins_admin_notices' ) ); } @@ -479,6 +481,27 @@ public function is_page_gutenberg() { return false; } + + /** + * Attach a WP_List_Table views filter to all screens. + */ + public function attach_views_filter( $current_screen ) { + add_filter( "views_{$current_screen->id}", array( $this, 'filter_views' ) ); + } + + /** + * Remove the parentheses from list table view counts when Calypsofied. + * + * @param array $views Array of views. See: WP_List_Table::get_views(). + * @return array Filtered views. + */ + public function filter_views( $views ) { + foreach ( $views as $id => $view ) { + $views[ $id ] = preg_replace( '/\((\d+)\)<\/span>/', '$1', $view ); + } + + return $views; + } } $Jetpack_Calypsoify = Jetpack_Calypsoify::getInstance();