wearerequired / WP-Widget-Disable

🖼 A WordPress plugin that allows you to disable Sidebar and Dashboard Widgets.
https://wordpress.org/plugins/wp-widget-disable/
GNU General Public License v2.0
16 stars 6 forks source link

Add settings for browser and PHP nag widgets #45

Closed ocean90 closed 4 years ago

ocean90 commented 4 years ago

Core has a wp_dashboard_browser_nag() and wp_dashboard_php_nag() widget. Both are registered depending on an API call, wp_check_browser_version() and wp_check_php_version(). Thus both are not collected by the current collector.

I'm proposing to add both widgets as hardcoded settings like we did with the Gutenberg callout. To disable the widgets, when set, we can use the site transient filter to prevent the API call which finally prevents registering the dashboard widgets.

// Browser nag
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
add_filter( 'pre_site_transient_browser_' . $key, '__return_null' );

// PHP nag
$key = md5( phpversion() );
add_filter( 'pre_site_transient_php_check_' . $key, '__return_null' );