Skip to content
Open
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
22 changes: 22 additions & 0 deletions features/plugin-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,25 @@ Feature: Update WordPress plugins
"""
Success: Updated 1 of 1 plugins (1 skipped).
"""

@require-wp-5.2
Scenario: Updating all plugins should show the name of each plugin as it is updated
Given a WP install
And I run `wp plugin delete akismet`

When I run `wp plugin install health-check --version=1.5.0`
Then STDOUT should not be empty

When I run `wp plugin install wordpress-importer --version=0.5`
Then STDOUT should not be empty

When I try `wp plugin update --all`
Then STDOUT should contain:
"""
Updating Health Check & Troubleshooting...
"""

And STDOUT should contain:
"""
Success: Updated 2 of 2 plugins.
"""
22 changes: 22 additions & 0 deletions features/theme-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,25 @@ Feature: Update WordPress themes
"""
1.1.1
"""

@require-wp-4.5
Scenario: Updating all themes should show the name of each theme as it is updated
Given a WP install
And I run `wp theme delete --all --force`

When I run `wp theme install moina --version=1.0.2`
Then STDOUT should not be empty

When I run `wp theme install twentytwelve --version=1.0`
Then STDOUT should not be empty

When I try `wp theme update --all`
Then STDOUT should contain:
"""
Updating Moina...
"""

And STDOUT should contain:
"""
Success: Updated 2 of 2 themes.
"""
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<exclude-pattern>*/src/WP_CLI/CommandWithUpgrade\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/(CommandWith|DestructivePlugin|DestructiveTheme)Upgrader\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/Parse(Plugin|Theme)NameInput\.php$</exclude-pattern>
<exclude-pattern>*/src/WP_CLI/ExtensionUpgraderSkin\.php$</exclude-pattern>
</rule>

<!-- Exclude classes from UselessOverridingMethod sniff as the method is used for generating docs. -->
Expand Down
9 changes: 8 additions & 1 deletion src/WP_CLI/CommandWithUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,14 @@ protected function get_upgrader( $assoc_args ) {
$force = Utils\get_flag_value( $assoc_args, 'force', false );
$insecure = Utils\get_flag_value( $assoc_args, 'insecure', false );
$upgrader_class = $this->get_upgrader_class( $force );
return Utils\get_upgrader( $upgrader_class, $insecure );

if ( ! class_exists( '\WP_Upgrader_Skin' ) ) {
if ( file_exists( ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php' ) ) {
include ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php';
}
}

return Utils\get_upgrader( $upgrader_class, $insecure, new ExtensionUpgraderSkin() );
}

protected function update_many( $args, $assoc_args ) {
Expand Down
24 changes: 24 additions & 0 deletions src/WP_CLI/ExtensionUpgraderSkin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace WP_CLI;

use WP_CLI;

/**
* An Upgrader Skin for extensions (plugins/themes) that displays which item is being updated
*
* @package wp-cli
*/
class ExtensionUpgraderSkin extends UpgraderSkin {

/**
* Called before an update is performed.
*/
public function before() {
if ( isset( $this->plugin_info ) && is_array( $this->plugin_info ) && isset( $this->plugin_info['Name'] ) ) {
WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->plugin_info['Name'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ) );
} elseif ( isset( $this->theme_info ) && is_object( $this->theme_info ) && method_exists( $this->theme_info, 'get' ) ) {
WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->theme_info->get( 'Name' ), ENT_QUOTES, get_bloginfo( 'charset' ) ) ) );
}
}
}