WordPress anti-spam script
Coding Style and Conventions

A nice coding style can dramatically improve readability, and thanks to IDEs, it's incredibly easy to achieve. 


You should use correct indentation! This would make it a lot easier to see what blocks of code belong together (this goes for the PHP and the HTML code). 
You should handle the same thing the same way: Sometimes your closing curly brackets are on the same line, sometimes the next; sometimes you use echo($var), and sometimes echo $var (the second version is how it's usually done).
be consistent with your casing. SQL keywords should always be all-uppercase, not only sometimes.
you have some unnecessary parentheses (eg $query  = (...)).


Functions

Extracting functionality to functions increases readability as it's easier to see what a block of code does. It also decreases duplication and increases reusability of your code.

You could introduce functions such as:


countComments($onlyApproved): this can remove the SELECT COUNT(comment_approved) FROM $tablename duplication.
downloadPlugin($pluginName)
extractZip($fileName)
deleteComments($types): $types can be all, unapproved or spam.


Naming

Generally, your variable names are quite clear, but some of them could be more descriptive. Eg un could be unapproved, tablename could be tableNameComments, tablename2 could be tableNameCommentsMeta, query could be deleteComments and query2 could be deleteCommentsMeta.

Misc


If you have an error (eg the database connection failed), don't just continue. Return/Redirect/Die instead.
You should not use mysql_*, as it's deprecated (since 2013). Use mysqli_* or PDO instead (or use the wrapper that WordPress supplies)).
It seems that currently your code always installs the plugin, and additionally deletes comments if the user wants to, which doesn't seem to make that much sense. If I already installed the plugin, and only want to use the comment deletion option of your code, I would need to still download the plugin, which seems like a waste of resources.


WordPress

You should check out how to write plugins for WordPress, it would be a lot nicer than a plain PHP file. 

For example, this would make it easier for a reader to understand how your includes work (eg wp-config.php isn't really needed, it's loaded by wp-load.php; on the other hand, you use functions from files which you don't explicitely include).

It would also add some security. Currently, it seems that anyone can access this script, not just admin users, which would be pretty bad. An attacker could delete all comments, and can cause your website to slow down significantly (because the script downloads and unzips a big file each time it is called).