Sorting WP Plugins by Date Added


Out of the box WordPress does not store timestamps of when a plugin was added or activated. You can not sort them by that category in Dashboard. However, sometimes it is necessary to check when your plugins were added and perheps sort them by date. This is easily done through the command line, provided you have ssh access to the server.

TL;DR

From your WordPress directory:

$ cd wp-content/plugins
$ for dir in */; do stat -c "%w %n" $dir; done | sort -n

Explanation

All the plugins are stored in their own sub-directories in wp-content/plugins. The stat command displays file/directory status. By default it shows size, access, permissions, uid, gid, access time, modification time, change time and birth time. The "birth" time is what we need. With the -c flag we can format the output. %w format sequence shows the "birth" time in a human-readable format, %n sequence shows the file name. All that's left is to loop through each directory in wp-conten/plugins and sort it numerically with sort -n. This way you get a list of all the plugin directories sorted from oldest to newest. To sort from newest to oldest, change the sort command to sort -nr.

After you got your list you can manipulate the plugins with wp-cli, so something like wp plugin delete <plugin>.