Skip to content

Commit

Permalink
Apply fixes for new coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean90 committed Mar 11, 2019
1 parent 287a846 commit b7b0019
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 32 deletions.
6 changes: 3 additions & 3 deletions classes/class-wp-widget-disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function has_settings_errors() {
public function save_network_options() {
$data = [];

// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
// phpcs:disable WordPress.Security.NonceVerification
if ( isset( $_POST[ $this->dashboard_widgets_option ] ) ) {
$data = $this->sanitize_dashboard_widgets( $_POST[ $this->dashboard_widgets_option ] );
}
Expand Down Expand Up @@ -401,7 +401,7 @@ public function sanitize_sidebar_widgets( $input ) {
// Check to see if the current option has a value. If so, process it.
if ( isset( $input[ $key ] ) ) {
// Strip all HTML and PHP tags and properly handle quoted strings.
$output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) );
$output[ $key ] = wp_strip_all_tags( stripslashes( $input[ $key ] ) );
}
}

Expand Down Expand Up @@ -462,7 +462,7 @@ public function sanitize_dashboard_widgets( $input ) {
// Check to see if the current option has a value. If so, process it.
if ( isset( $input[ $key ] ) ) {
// Strip all HTML and PHP tags and properly handle quoted strings.
$output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) );
$output[ $key ] = wp_strip_all_tags( stripslashes( $input[ $key ] ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- Define both prefixes for functions and hooks. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="wp_widget_disable"/>
<property name="prefixes" type="array" value="widget_disable,WP_Widget_Disable"/>
</properties>
</rule>

Expand Down
29 changes: 11 additions & 18 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
<?php
/**
* Fired when the plugin is uninstalled.
*
* @package WP_Widget_Disable
* @author Silvan Hagen <[email protected]>
* @license GPL-2.0+
* @link http://wp.required.ch/plugins/wp-widget-disable
* @copyright 2015 required gmbh
* Included when the plugin is uninstalled.
*/

defined( 'WP_UNINSTALL_PLUGIN' ) || die;

$options = [
$widget_disable_options = [
'rplus_wp_widget_disable_sidebar_option',
'rplus_wp_widget_disable_dashboard_option',
];

if ( ! is_multisite() ) {
foreach ( $options as $option ) {
delete_option( $option );
foreach ( $widget_disable_options as $widget_disable_option ) {
delete_option( $widget_disable_option );
}
} else {
global $wpdb;

$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$original_blog_id = get_current_blog_id();
$widget_disable_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );

foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
foreach ( $widget_disable_ids as $widget_disable_id ) {
switch_to_blog( $widget_disable_id );

foreach ( $options as $option ) {
delete_option( $option );
foreach ( $widget_disable_options as $widget_disable_option ) {
delete_option( $widget_disable_option );
}
}

switch_to_blog( $original_blog_id );
restore_current_blog( $widget_disable_id );
}
}
11 changes: 3 additions & 8 deletions views/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
* Represents the view for the administration dashboard.
*
* This includes the header, options, and other information that should provide
* The User Interface to the end user.
*
* @package WP_Widget_Disable
* @author Silvan Hagen <[email protected]>
* @license GPL-2.0+
* @link http://wp.required.ch/plugins/wp-widget-disable
* @copyright 2015 required gmbh
* the User Interface to the end user.
*/

// phpcs:disable WordPress.NamingConventions, VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- Variables are not global.
$sidebar_tab_url = add_query_arg(
[
'page' => 'wp-widget-disable',
Expand All @@ -28,7 +23,7 @@

$active_tab = $this->sidebar_widgets_option;

// phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
// phpcs:ignore WordPress.Security.NonceVerification
if ( is_network_admin() || ( isset( $_GET['tab'] ) && 'dashboard' === $_GET['tab'] ) ) {
$active_tab = $this->dashboard_widgets_option;
}
Expand Down
4 changes: 2 additions & 2 deletions wp-widget-disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
// Pull in the plugin classes and initialize.
include __DIR__ . '/classes/class-wp-widget-disable.php';

$wp_widget_disable = new WP_Widget_Disable();
add_action( 'plugins_loaded', array( $wp_widget_disable, 'add_hooks' ) );
$widget_disable = new WP_Widget_Disable();
add_action( 'plugins_loaded', array( $widget_disable, 'add_hooks' ) );
}

unset( $requirements_check );

0 comments on commit b7b0019

Please sign in to comment.