Category: Wordpress


Quick Debugging Trick in WordPress

August 5th, 2011 — 1:13am

I always found it a pain when writing new plugins/themes in wordpress to have to turn on or off the WP_DEBUG flag to get errors to show. Plus often times I will be working on a site that others are also viewing or working on, so turning on the flag would disrupt their work. A really simple solution to this problems was to wrap a define statement for the WP_DEBUG flag in an if statement. For example:


if ($_GET['debug'] == 1) {
define("WP_DEBUG", 1);
}
else {
define("WP_DEBUG", 0);
}

The beauty of the code is that you can trigger debugging easily by adding ?debug=1 onto your uri. This saves you from having to change the wp-config.php file, as well as solves the issue of multiple users/developers.

Note this should only be done on a development site. Having this on a live WordPress install could open up your site to be more easily exploiting as you are giving your attackers access to the notifications, warnings and errors.

Comment » | Short Notes, Wordpress

WordPress Vim Syntax Highlighting

May 22nd, 2011 — 9:18pm

Lately I have been doing a lot more work in WordPress. I primarily code in Vim, and it always bugged me there was no syntax highlighting for WordPress in Vim (or at least that I could find), so I decided to write one. I started off pulling all the functions from this page: http://codex.wordpress.org/Function_Reference. However I found this page to be pretty incomplete, so I continued to add functions to the file as I went along.

I decided to release the file to the public in case anyone is looking for WordPress syntax highlighting. Note, by no means is this file complete, but is a good base. Feel free to contact me to fill in any functions I am missing.

Download: wordpress.vim (right click, save as)

To install, download and place in your .vim/syntax/ directory. Then load by running in vim:

:set syn=wordpress

Or place something like the following in your .vimrc file:

autocmd BufEnter *.php :set syn=wordpress

1 comment » | Vim, Wordpress

Back to top