Make WordPress Core

Changeset 61695


Ignore:
Timestamp:
02/19/2026 12:43:43 PM (5 months ago)
Author:
audrasjb
Message:

Plugins: Add a new plugins_list_status_text filter in get_views() to allow custom filtering.

This changeset does the following:

  • Custom statuses added via plugins_list now appear as tabs, to filter the related plugins
  • The tab label is customizable via the new plugins_list_status_text hook

Follow-up to [56068].

Props juliobox, audrasjb, hellofromTonya, khokansardar, sajjad67, davidbaumwald, sukhendu2002, SirLouen, mindctrl, shailu25, huzaifaalmesbah, westonruter.
See #60495.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r61481 r61695  
    4747                );
    4848
    49                 $allowed_statuses = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' );
    50 
    5149                $status = 'all';
    52                 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $allowed_statuses, true ) ) {
    53                         $status = $_REQUEST['plugin_status'];
     50                if ( isset( $_REQUEST['plugin_status'] ) ) {
     51                        $status = sanitize_key( $_REQUEST['plugin_status'] );
    5452                }
    5553
     
    583581                                                'Auto-updates Disabled <span class="count">(%s)</span>',
    584582                                                $count
     583                                        );
     584                                        break;
     585                                default:
     586                                        /**
     587                                         * Filters the status text of default switch case in the plugins list table.
     588                                         *
     589                                         * @since 7.0.0
     590                                         *
     591                                         * @param string $text  Plugins list status text. Default empty string.
     592                                         * @param int    $count Count of the number of plugins.
     593                                         * @param string $type  The status slug being filtered.
     594                                         */
     595                                        $text = apply_filters( 'plugins_list_status_text', '', $count, $type );
     596                                        if ( empty( $text ) || ! is_string( $text ) ) {
     597                                                $text = $type;
     598                                        }
     599                                        $text = esc_html( $text ) . ' ' . sprintf(
     600                                                '<span class="count">(%s)</span>',
     601                                                number_format_i18n( $count )
    585602                                        );
    586603                                        break;
Note: See TracChangeset for help on using the changeset viewer.