WordPress Move – Weekly Update 6
This week, I worked on writing tools for archiving files using PclZip. So far it consists of 6 functions:
- createArchive( $directory ) : Creates an archive of the given directory.
- createArchiveAdvanced( $array ) : Creates an archive of the given files.
- extractArchive( $filename, $destination ) : Extracts the given archive to the given destination.
- calculateTotalUsage( $directory ) : Calculates the total disk space the given directory uses.
- listAllFiles( $directory ) : Creates a list of all the files under the given directory.
- divideIntoChunks( $directory, $chunk_size ) : Creates lists of files (a 2 dimensional array) by dividing files inside a directory into chunks.
I think functions are pretty clear and they do not need any further explanation but of course, I would love to answer your questions, if you have any.
This task is almost complete but I need to make sure I did not forget anything before closing the ticket related to the task. I will commit the file to the repo and close the ticket tomorrow.
Next week, I will be working on writing tools for uploading files to the new server.
See you next week!
Andrew Nacin 11:44 pm on June 10, 2011 Permalink |
Hey Mert,
You should check out the WordPress coding standards – http://codex.wordpress.org/WordPress_Coding_Standards. Note how we name functions and methods.
Also, we already have the ability to extract files in core (it uses ZipArchive then falls back to PclZip), so you won’t need your own extractArchive method.
I didn’t check if these were methods or functions, but if they’re functions, please prefix them.
Mert Yazıcıoğlu 12:31 pm on June 11, 2011 Permalink |
In fact, the actual code has function names with underscores. I was about to sleep while writing this post, so my fingers just typed them in the way they got used to I think (:
You are right, I just wrote it to keep everything related to archiving together but since there’s a more advanced built-in one, I should stick with what is in the core.
They are functions, so I guess I should prefix them with “wpmove_”. Is that okay?
Thank you very much for your comment, much appreciated!