Giter VIP home page Giter VIP logo

wp-widget-disable's Introduction

Widget Disable for WordPress

PHPUnit Linting

This WordPress plugin allows you to disable any sidebar and dashboard widget for the current WordPress site you are on.

It provides a simple user interface available to users with edit_theme_options capabilities (usually Administrator role) available under Appearance -> Disable Widgets.

After saving the settings, the sidebar and dashboard widgets are removed and users canโ€™t use those widgets anymore.


a required open source product - let's get in touch

wp-widget-disable's People

Contributors

dependabot[bot] avatar grappler avatar neverything avatar ocean90 avatar swissspidy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-widget-disable's Issues

Support Antispam Bee

Somehow Antispam Bee isn't available in the list of dashboard widgets to disable. Investigate.

Support hiding the Try Gutenberg callout

Needs similar treatment as the welcome panel:

if ( 'dashboard_welcome_panel' === $widget_id ) {
remove_action( 'welcome_panel', 'wp_welcome_panel' );
continue;
}

<p>
<input type="checkbox" id="dashboard_welcome_panel" name="rplus_wp_widget_disable_dashboard_option[dashboard_welcome_panel]" value="normal"
<?php checked( 'dashboard_welcome_panel', ( array_key_exists( 'dashboard_welcome_panel', $options ) ? 'dashboard_welcome_panel' : false ) ); ?>>
<label for="dashboard_welcome_panel">
<?php
/* translators: %s: welcome_panel */
printf( __( 'Welcome panel (%s)', 'wp-widget-disable' ), '<code>welcome_panel</code>' );
?>
</label>
</p>

Possible undefined index notices

Reported here: https://wordpress.org/support/topic/debug-errors-please/

Screenshot:

download

$widget['title'] doesn't seem to exist in all cases. The line in question:

wp_kses( $widget['title'], array( 'span' => array( 'class' => true ) ) ),

Probably doesn't hurt to add some hardening there. We can do this while flattening the array:

foreach ( $widgets as $context => $priority ) {
foreach ( $priority as $data ) {
foreach ( $data as $id => $widget ) {
$widget['title_stripped'] = wp_strip_all_tags( $widget['title'] );
$widget['context'] = $context;
$flat_widgets[ $id ] = $widget;
}
}
}

Same goes for get_default_dashboard_widgets():

We should check whether the array key exists / is set in this section:

if ( ! is_array( $wp_meta_boxes['dashboard'] ) ) {

Add settings for browser and PHP nag widgets

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' );

PHP Notice: Trying to access array offset on value of type bool

With PHP 7.4 and WordPress 5.4.2 I'm seeing a few PHP notices on the dashboard when some widgets are disabled.

image

You should be able to reproduce the issue by installing the plugin and disabling any dashboard widget which is not welcome_panel, dashboard_browser_nag and dashboard_php_nag.

Make spacing between checkbox and label consistent

bildschirmfoto 2016-12-07 um 22 14 21


Current HTML looks like:

	<form method="post" action="options.php">
		<input type='hidden' name='option_page' value='rplus_wp_widget_disable_dashboard_option' /><input type="hidden" name="action" value="update" /><input type="hidden" id="_wpnonce" name="_wpnonce" value="5c5298378c" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/themes.php?page=wp-widget-disable&amp;tab=dashboard" /><h2>Disable Dashboard Widgets</h2>
<p>Choose the dashboard widgets you would like to disable.</p><table class="form-table"><tr><th scope="row">Dashboard Widgets</th><td>		<p>
			<input type="checkbox" id="wp_widget_disable_select_all"/>
			<label for="wp_widget_disable_select_all">Select all</label>
		</p>
		<p>
			<input type="checkbox" id="dashboard_welcome_panel"
			       name="rplus_wp_widget_disable_dashboard_option[dashboard_welcome_panel]"
			       value="normal"
				 checked='checked'>
			<label for="dashboard_welcome_panel">
			<label for="dashboard_welcome_panel">
				Welcome panel (<code>welcome_panel</code>)			</label>
		</p>
		<p><input type="checkbox" id="dashboard_right_now" name="rplus_wp_widget_disable_dashboard_option[dashboard_right_now]" value="normal"  checked='checked'><label for="dashboard_right_now">At a Glance (<code>dashboard_right_now</code>)</label></p><p><input type="checkbox" id="dashboard_activity" name="rplus_wp_widget_disable_dashboard_option[dashboard_activity]" value="normal"  checked='checked'><label for="dashboard_activity">Activity (<code>dashboard_activity</code>)</label></p><p><input type="checkbox" id="dashboard_quick_press" name="rplus_wp_widget_disable_dashboard_option[dashboard_quick_press]" value="side"  checked='checked'><label for="dashboard_quick_press"><span class="hide-if-no-js">Quick Draft</span> <span class="hide-if-js">Drafts</span> (<code>dashboard_quick_press</code>)</label></p><p><input type="checkbox" id="dashboard_primary" name="rplus_wp_widget_disable_dashboard_option[dashboard_primary]" value="side"  checked='checked'><label for="dashboard_primary">WordPress News (<code>dashboard_primary</code>)</label></p></td></tr></table><p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes"  /></p>	</form>

Multisite Compatibility

Right now it doesn't matter if you activate the plugin for the whole network or for each site individually.

However, if you network activate it, it's currently not possible to disable widgets in the network admin dashboard. Shouldn't be too hard to allow this.

WordPress 5.8 Widget/Sidebar area

In WordPress 5.8 the sidebar area has moved to a block area. The old core widgets cannot be added.

Do we hide the Widget settings if the classic area is not enabled?

Do we create a new setting to disable the blocks for the widget area?

Buchstabendreher (Typo) in description

rplus_wp_widget_disable_default_dashboard_filter gives you back the list (array) of all dashboard widgets before we sotre them, so you could basically remove dashboard widgets from being disabled.

store

Textdomain not working

Add the actual textdomain instead of $this->plugin_slug in the strings related to this, because it won't work otherwise.

Release Version 1.9.0

Once #31 is merged, we can prepare releasing version 1.9.0

  • Bump version in wp-widget-disable.php
  • Add changelog and upgrade notice in readme.txt
  • Add changelog CHANGELOG.md
  • Commit to trunk on plugins.svn.wordpress.org
  • Tag 1.9.0 on plugins.svn.wordpress.org

Add Grunt tasks

To create the gettext files and maybe generate the readme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.