lesterchan / wp-sweep

WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It also optimizes your database tables.
https://wordpress.org/plugins/wp-sweep/
152 stars 23 forks source link

added WP CLI command for wp-sweep #33

Closed Nikschavan closed 8 years ago

Nikschavan commented 8 years ago

First pass at #17, suggestions welcome :)

lesterchan commented 8 years ago

Thank you so much for this!

Nikschavan commented 8 years ago

@lesterchan any plans when this will be released on WordPress repo?

lesterchan commented 8 years ago

I normally update my plugins with the next release of WP, in this case will be 4.6 =)

collinbarrett commented 8 years ago

If I now run wp sweep --all on a cron, is there no need to run wp db optimize anymore? Is the database optimize that wp-sweep performs the same as the one built into wp-cli?

Thanks.

lesterchan commented 8 years ago

@collinbarrett yes, wp sweep -- includes optimize.

collinbarrett commented 8 years ago

@lesterchan perfect. can't wait for the wp-cli support to be rolled out through the .org plugin repo!

collinbarrett commented 8 years ago

I just manually installed the latest code (couldn't wait for the release). wp-cli integration seems to work like a charm. Thanks so much!

jscmal commented 6 years ago

Hi, @Nikschavan, I would require a Feature.

wp sweep --all doesn't consider the DB of a multisite.

Kindly may you add the feature to use it also for a multisite that has several websites with just 1 DataBase, then with some core tables in common and other tables that are repeated for each site?

I have 1 multisite with 2 sites the DB has different table prefixes for the 2 sites.

Please, may you do this?

Here my Feature Request that I wrote on the Support Page of the Plugin: https://wordpress.org/support/topic/wp-cli-on-a-multisite-with-1-data-base-and-2-different-table-prefixex/#post-10393725

Kind regards

G. Aloe

Nikschavan commented 6 years ago

Hi @jscmal, There's a trick to run all the WP-CLI commands on MS - wp site list --field=url | xargs -n1 -I % wp --url=% sweep --all

@danielbachhuber has a blog post which explains this nicely - https://danielbachhuber.com/tip/run-wp-cli-command-wordpress-multisite/

jscmal commented 6 years ago

Thank you @Nikschavan. :) It works concretely well. I have to say that I had never used xargs before.

Now I have my script in cron that clean everything after the midnight backup.