Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions modules/calypsoify/class.jetpack-calypsoify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand Down Expand Up @@ -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( '/<span class="count">\((\d+)\)<\/span>/', '<span class="count">$1</span>', $view );
}

return $views;
}
}

$Jetpack_Calypsoify = Jetpack_Calypsoify::getInstance();