These two lines might need explaining: 

L82 is removing '.tar.gz' (7 chars long) to create the directory name. 

So the tmp folder might contain something like...
 * /tmp/wp_xxxxxxxxxxxxx.tar.gz
 * /tmp/wp_xxxxxxxxxxxxx/
 * /tmp/wp_xxxxxxxxxxxxx/wordpress

L83 is creating an offset for '/wordpress' (10 chars long).

These functions are more efficient than ```str_replace()```. There's also the added benefit of not having to take ```\``` or ```/``` into consideration.