Skip to content
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

Add option to list recently active plugins #383

Closed

Conversation

thrijith
Copy link
Member

Fixes #232

Add examples for activate and listing plugins with new flag
Add tests for new flag
@thrijith thrijith requested a review from a team as a code owner November 13, 2023 07:47
@swissspidy
Copy link
Member

@wp-cli/committers Instead of wp plugin list --recently-active, should we just make this wp plugin list --status=recently-active?

@danielbachhuber
Copy link
Member

Instead of wp plugin list --recently-active, should we just make this wp plugin list --status=recently-active?

@swissspidy I prefer --recently-active because recently_active is a separate column, not a value in the status column.

@@ -0,0 +1,103 @@
Feature: List Recently Active WordPress plugins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this file to plugin-list-recently-active.feature?

Also, given we have a code path for multisite, we should have a multisite scenario too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 805760d

@@ -699,6 +705,12 @@ protected function get_item_list() {
$auto_updates = [];
}

$recently_active = is_multisite() ? get_site_option( 'recently_activated' ) : get_option( 'recently_activated' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this get_site_option( 'recently_activated' ) option applied to single site plugin pages on multisite too? Or only the network plugins screen?

Copy link
Member Author

@thrijith thrijith Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,

if ( ! is_network_admin() ) {
update_option(
'recently_activated',
array( $plugin->file => time() ) + (array) get_option( 'recently_activated' )
);
} else {
update_site_option(
'recently_activated',
array( $plugin->file => time() ) + (array) get_site_option( 'recently_activated' )
);
}
I've updated condition to match what I found in deactivate.

@@ -1169,6 +1182,9 @@ public function delete( $args, $assoc_args = array() ) {
* [--skip-update-check]
* : If set, the plugin update check will be skipped.
*
* [--recently-active]
* : If set, only recently active plugins will be shown and the status filter will be ignored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document how the behavior changes for multisite too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielbachhuber sorry, didn't get what needs to be done here.

@@ -501,6 +501,16 @@ protected function _list( $_, $assoc_args ) {

$all_items = $this->get_all_items();

// Only show plugins that are recently active.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't necessary and can be removed. It simply duplicates the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 805760d, but I didn't get what you meant here.

@thrijith
Copy link
Member Author

thrijith commented Dec 3, 2023

Not sure what the error is in https://github.com/wp-cli/extension-command/actions/runs/7077555679/job/19262025024?pr=383#step:12:260, unable to replicate on local site, getting this error only in tests, please check https://cleanshot.thrijith.com/jMsCpCyk

@danielbachhuber
Copy link
Member

@thrijith You can merge main to fix the unrelated broken tests. I fixed them up with #389.

I'd recommend setting up the Behat test suite locally so it's easier for you to debug the failure specific to your tests.

@thrijith
Copy link
Member Author

thrijith commented Mar 1, 2024

Closing the PR as I was not able to figure out the reason for one of the failure in tests, anyone who wants to takes this, please feel free to do so, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to activate all recently active plugins
3 participants