[wp-trac] [WordPress Trac] #62780: Add ability to developers to add their own plugin statuses via a filter #1
WordPress Trac
noreply at wordpress.org
Sat Jan 4 18:39:42 UTC 2025
#62780: Add ability to developers to add their own plugin statuses via a filter #1
-----------------------------+-----------------------------
Reporter: pexlechris | Owner: (none)
Type: feature request | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
My suggestion is to add ability to developers to alter/filter the allowed
plugin statuses .
So If you add a WP filter, this could be done more efficient and natively.
My code suggestion is this:
in file:
wp-admin/includes/class-wp-plugins-list-table.php
in construct method to add a filter after defining the $allowed_statuses
variable like this:
{{{
/**
* Filters the plugin allowed statuses.
*
* @param array $allowed_statuses The array of plugin allowed statuses.
*/
$allowed_statuses = apply_filters('plugin_allowed_statuses',
$allowed_statuses);
}}}
For example, my case was to add plugin status fav_plugins, and I have
written this work around to init the plugin_status as I need:
{{{#!php
<?php
// Workaround
add_filter('plugins_auto_update_enabled', function($enabled){
if( !is_admin() ) return $enabled;
global $pagenow;
if( $pagenow != 'plugins.php' ) return $enabled;
$plugin_status = $_GET['plugin_status'] ?? '';
if( $plugin_status != 'fav_plugins' ) return $enabled;
$GLOBALS['status'] = 'fav_plugins';
return $enabled;
});
}}}
My purpose was to create a functionality to save all the active plugins to
a newplugin status called fav_plugins. You can view the plugin I created
here:
[https://github.com/pexlechris/pexlechris-save-active-plugins/blob/main
/pexlechris-save-active-plugins.php]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62780>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list