WP Developer Assistant is a WordPress plugin developed by a WordPress developer for WordPress developers.
- Have you ever needed to run a query when you didn’t have access to phpMyAdmin or SSH?
- Don’t you hate it when you need to upload a plugin, theme, or other file and don’t have FTP access?
- Have you ever wondered where that action or filter hook gets called?
- Want to enable errors while hiding them from everyone else?
- Wouldn’t it be great if you could output a full listing of PHP global variable values on each page so debugging would be easier?
- Ever wanted to modify one of those serialized options?
- Would you like to quickly see a full list of defined constants?
It’s thoughts like these that caused me to make this plugin. WP Developer Assistant is the first WordPress plugin of its kind. It essentially is a toolkit that makes life as a WordPress developer easier.
This page sets the persistent states of the WP Developer Assistant plugin. From this page, you can select to display specific error output from PHP and to display values for PHP global variables. This data will be output on any page you visit in your site, whether it is the front page, archives, or an admin page.
The really cool feature of this is that only your user sees the effects of these setttings. Anyone who is not logged in or is logged in as a different user won’t see the error messages or variable output.
I’ve often found the options screen that is built into WordPress to be very limiting. There are times where some of the serialized data becomes corrupted for one reason or another, and there aren’t any good ways to fix the problem. Now you can edit even the serialized data fields.
I also don’t like how you can’t add or remove any options, so I want my options page to offer that ability. This is still in the testing phases and should be added soon.
Actions and filters add amazing flexibility to WordPress. I think that they are one of the reasons that WordPress is so successful. As a developer, the amazing amount of available hooks are staggering. Add on top of that the fact that the Codex never seems to be up-to-date about what hooks are available and which versions support what hooks. There’s always the question of what is already set on this hook, where does that get set, and what options has it been set up with. Then you have the problem of remembering what arguments are passed to the hook when it’s called.
After a lot of thought about the best way to keep track of what is the current state of available and used hooks, I realized that I should just let the code tell me. Essentially, the plugin searches the WordPress root install, WPINC (wp-includes), wp-content, PLUGINDIR (wp-content/plugins), and wp-admin directories for hook functions. All the directories except the root install directory are searched recursively.
It might seem funny to search the plugin directory since it is inside wp-content. I do this to handle cases where the plugin directory has been moved elsewhere.
For add_action and add_filter calls, the hook name, function name, priority, number of accepted arguments, source file name, and file line number are shown. For do_action and apply_filters calls, the hook name, passed attributes, source file name, and file line number are shown.
Over time, I aim to use this tool to help tighten up the relevent parts of the Codex in order to keep it up to date.
The Run Query tool is extremely simple but immensely helpful. If you know how to write a query, you can access, add, and modify table data. You could even add, modify, and remove tables if you were so inclined.
It was my idea for this tool that caused me to create this plugin. I thought to myself, “why should I have to write a plugin just to be able to execute this one query?” The answer was quick and absurdly obvious: create a plugin that could execute any query.
With just this little text area, you can do anything you want with the database as long as the user has sufficient permissions. I have an idea to also offer an embedded phpMyAdmin. If enough people like the idea of having the phpMyAdmin interface as well, I’ll look at adding it.
This page is also simple. It just calls phpinfo() which dumps all of its data to the screen. I need to clean this up so that it doesn’t embed a full HTML document inside the page. Even though it’s so dirty, it still works very well.
Just like the Hooks page, the Defines page searches through the WordPress folder structure for matches.
By default, only constants that are declared in WordPress source files are shown. If you click “Show All Defines”, a full list of available constants will be generated with constants defined outside the WordPress source being marked as such. The name, the current value, the value declared by the specific line of code, the source file name, and the file line number are shown for each constant.
I imagine that this page will be the main reason most people will use this tool. The Upload Files page allows you to add file(s) to the WordPress installation completely from inside WordPress. No longer do you need FTP access just to add that new plugin, try out a new theme, or to easily add a file to your downloads area.
You can supply the file by specifying a URL location for the server to grab the file from or by selecting a file on your computer.
You have four destination options: Uploads will use the standard storage mechanism of WordPress to store the file in the Uploads directory; by default, it will store in subdirectories representing the year and month of the upload. Plugin will cause the upload to store in the plugins directory. Theme will store the file in the themes directory. Finally, you can use Manual Path to provide a path of your own chosing (the path must be relative to the root installation directory of WordPress).
There are a number of options to control how the upload handles overwriting and renaming files. This should be fairly self-explanatory.
The really interesting bit at the bottom is where it will automatically extract archive files at the destination. This is useful for loading plugins or themes without having to resort to saving it to your computer, extracting the files, and then loading each file up. Archives with the following extensions (and matching encoding schemes) are supported: zip, tar, gz, tar.gz, tgz, tar.bz2.
One thing to be careful about when extracting archives is that some archives don’t properly have a containing folder like they should. It’s for this reason that I provided the “Force files to be extracted inside a folder” option. If this option is selected, the archive will be extracted to a folder with the same name as the archive minus the extension. Note that it will do this irregardless of whether or not the archive contained files already inside a folder. It is advisable to look at the plugin on your computer first before trying to upload it to the server to verify whether or not forcing a containing folder is necessary.
Thanks to File_Archive developed by Pablo Fischer, I was able to provide the extraction ability irregardless of server operating system. I have not tested his code extensively since I only have access to Linux-based servers. If you have any problems with the extraction ability, please contact me.
Well, those are all the functions I could manage to cram into the first version without taking too long to release it. If you look at the code, you’ll see that I have a lot of ideas for the future of this tool. A few of my main ideas follow, please let me know if any of them would be useful to you so that I know which features to prioritize.
- *in development* Enable adding and removing of items from the options table through the Options page.
- *in development* A search page to search through files in the WordPress install. Think of it as a grep utility built into WordPress. This will be good for tracking down those pieces of code or text that you just can’t seem to find.
- Verification tool to quickly assess whether or not the core WordPress files and database tables have been modified. This will be useful for planning version upgrades.
- Tool to allow viewing the site with different themes without actually changing the theme.
- HTML validation… I’m not too sure that this one is readily possible, but it’s an interesting back-burner / rainy day idea.
- Provide a phpMyAdmin interface
- Robust database backup and restore tools. These would most likely be linked to some of the plugin’s functions to automatically backup the database before any modifications are made.
- Enhanced file management. The main thing I’d like to offer is editing of any text file within the WordPress root installation directory. Just think of all those files that the plugin and theme editors don’t give access to.
- Sidebar repair tool. Have you ever killed a sidebar with a messed up widget? This tool would allow for selectively removing specific widgets from specific sidebars.
This plugin should be considered to be in alpha stage. Thus, you should always back up your database before using any functions that modify tables. I cannot be held accountable for any loss of data, loss of time, or security problems created by this plugin.
If you are unsure about using this plugin, please wait until it has been sufficiently tested by others first. Even then, you should always take precautions by regularly backing up your data.
Keep in mind that this data will most likely be going through insecure HTTP communications. Some of the data that is exposed may make the site vulnerable if it is sniffed by the wrong people. I have tried to ensure that the most dangerous data (database access information, secret keys, etc) are filtered, but I don’t guarantee that I covered everything or that what I covered is sufficient to meet your desired level of security.
- WordPress 2.2+ – This is as far back as I’ve tested the plugin. I’ve gone through each iterative version backwards, and I have yet to find a version back to 2.2 that this plugin doesn’t work with. If you have different results, please let me know.
- PHP 5+ – I have seen some problems with running some of my code on servers with old versions of PHP. From my experience, if you have PHP 5 or above, the code should run without errors since I’ve purposefully avoided PHP 6 functions and constructs.
- 1.0.1 – released on June 26, 2008
- Arne Brachhold for providing some code that I found useful and incorporated into WP Developer Assistant.
- Henning Schaefer for PlugInstaller which was an inspiration for the File Upload page.
- Pablo Fischer for File_Archive which powers the extraction process for uploading archives.
Please visit the WP Developer Assistant page on WordPress.org to download. Further information and installation instructions can be found there.
I’ve already put in countless hours and many extremely late nights into the development of this plugin. If you would like to donate to this project so that I can devote more time to development on this plugin and others like it, please click the button below. Thank you.