Skip to content

Update to WPCS v3 #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"require-dev": {
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^3.1"
"wp-cli/wp-cli-tests": "^4"
},
"config": {
"process-timeout": 7200,
Expand Down
1 change: 0 additions & 1 deletion src/Sidebar_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,4 @@ public function list_( $args, $assoc_args ) {
$formatter = new Formatter( $assoc_args, $this->fields );
$formatter->display_items( $sidebars );
}

}
19 changes: 6 additions & 13 deletions src/Widget_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public function list_( $args, $assoc_args ) {

$formatter = new Formatter( $assoc_args, $this->fields );
$formatter->display_items( $output_widgets );

}

/**
Expand Down Expand Up @@ -165,7 +164,6 @@ public function add( $args, $assoc_args ) {
$this->move_sidebar_widget( $widget_id, null, $sidebar_id, null, $position );

WP_CLI::success( 'Added widget to sidebar.' );

}

/**
Expand Down Expand Up @@ -206,7 +204,6 @@ public function update( $args, $assoc_args ) {
$this->update_widget_options( $name, $widget_options );

WP_CLI::success( 'Widget updated.' );

}

/**
Expand Down Expand Up @@ -264,7 +261,6 @@ public function move( $args, $assoc_args ) {
$this->move_sidebar_widget( $widget_id, $current_sidebar_id, $new_sidebar_id, $current_sidebar_index, $new_sidebar_index );

WP_CLI::success( 'Widget moved.' );

}

/**
Expand Down Expand Up @@ -293,7 +289,7 @@ public function deactivate( $args, $assoc_args ) {
foreach ( $args as $widget_id ) {
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::warning( "Widget '{$widget_id}' doesn't exist." );
$errors++;
++$errors;
continue;
}

Expand All @@ -311,7 +307,7 @@ public function deactivate( $args, $assoc_args ) {
count( $this->get_sidebar_widgets( 'wp_inactive_widgets' ) )
);

$count++;
++$count;

}

Expand Down Expand Up @@ -342,7 +338,7 @@ public function delete( $args, $assoc_args ) {
foreach ( $args as $widget_id ) {
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::warning( "Widget '{$widget_id}' doesn't exist." );
$errors++;
++$errors;
continue;
}

Expand All @@ -358,7 +354,7 @@ public function delete( $args, $assoc_args ) {
$all_widgets[ $sidebar_id ] = array_values( $all_widgets[ $sidebar_id ] );
update_option( 'sidebars_widgets', $all_widgets );

$count++;
++$count;
}

Utils\report_batch_operation_results( 'widget', 'delete', count( $args ), $count, $errors );
Expand Down Expand Up @@ -425,7 +421,7 @@ public function reset( $args, $assoc_args ) {
foreach ( $args as $sidebar_id ) {
if ( ! array_key_exists( $sidebar_id, $wp_registered_sidebars ) ) {
WP_CLI::warning( sprintf( 'Invalid sidebar: %s', $sidebar_id ) );
$errors++;
++$errors;
continue;
}

Expand All @@ -445,7 +441,7 @@ public function reset( $args, $assoc_args ) {
);
}
WP_CLI::log( sprintf( "Sidebar '%s' reset.", $sidebar_id ) );
$count++;
++$count;
}
}

Expand Down Expand Up @@ -627,7 +623,6 @@ private function move_sidebar_widget( $widget_id, $current_sidebar_id, $new_side
}

update_option( 'sidebars_widgets', $all_widgets );

}

/**
Expand Down Expand Up @@ -666,7 +661,5 @@ private function sanitize_widget_options( $id_base, $dirty_options, $old_options
// because Widget API dependent on the form fields
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Whitelisting due to above reason.
return @$widget->update( $dirty_options, $old_options );

}

}
2 changes: 1 addition & 1 deletion widget-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
return;
}

$wpcli_widget_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_widget_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_widget_autoloader ) ) {
require_once $wpcli_widget_autoloader;
}
Expand Down