Opened 4 months ago
Last modified 4 months ago
#62780 assigned feature request
Add ability to developers to add their own plugin statuses via a filter #1
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Plugins | Keywords: | has-patch |
Focuses: | Cc: |
Description
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 // 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:
Change History (1)
This ticket was mentioned in PR #8087 on WordPress/wordpress-develop by @sukhendu2002.
4 months ago
#1
- Keywords has-patch added
Trac ticket: https://core.trac.wordpress.org/ticket/62780