diff --git a/composer.json b/composer.json index 1e719d31..3a9b0a37 100644 --- a/composer.json +++ b/composer.json @@ -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, diff --git a/src/Sidebar_Command.php b/src/Sidebar_Command.php index a4624698..b126b117 100644 --- a/src/Sidebar_Command.php +++ b/src/Sidebar_Command.php @@ -84,5 +84,4 @@ public function list_( $args, $assoc_args ) { $formatter = new Formatter( $assoc_args, $this->fields ); $formatter->display_items( $sidebars ); } - } diff --git a/src/Widget_Command.php b/src/Widget_Command.php index 99c66e88..8cb6e7fe 100644 --- a/src/Widget_Command.php +++ b/src/Widget_Command.php @@ -98,7 +98,6 @@ public function list_( $args, $assoc_args ) { $formatter = new Formatter( $assoc_args, $this->fields ); $formatter->display_items( $output_widgets ); - } /** @@ -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.' ); - } /** @@ -206,7 +204,6 @@ public function update( $args, $assoc_args ) { $this->update_widget_options( $name, $widget_options ); WP_CLI::success( 'Widget updated.' ); - } /** @@ -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.' ); - } /** @@ -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; } @@ -311,7 +307,7 @@ public function deactivate( $args, $assoc_args ) { count( $this->get_sidebar_widgets( 'wp_inactive_widgets' ) ) ); - $count++; + ++$count; } @@ -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; } @@ -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 ); @@ -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; } @@ -445,7 +441,7 @@ public function reset( $args, $assoc_args ) { ); } WP_CLI::log( sprintf( "Sidebar '%s' reset.", $sidebar_id ) ); - $count++; + ++$count; } } @@ -627,7 +623,6 @@ private function move_sidebar_widget( $widget_id, $current_sidebar_id, $new_side } update_option( 'sidebars_widgets', $all_widgets ); - } /** @@ -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 ); - } - } diff --git a/widget-command.php b/widget-command.php index d5bba003..f03d2f54 100644 --- a/widget-command.php +++ b/widget-command.php @@ -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; }