Tag Archives: WordPress

Visual PHP Unit + WordPress Unit Tests

House of Payne

I saw VisualPHPUnit and was immediately interested.  This provided a very nice visual wrapper to PHPUnit without full blown continuous integration, and kept a history of your test passes / fails.


VisualPHPUnit is a wrapper for PHPUnit.  It expects that your tests are compatible with PHPUnit’s command line test runner already.

Could this work with WordPress’ Unit Tests?  After some investigation, I’m sad to report that, no, it can’t.  VisualPHPUnit makes several assumptions that are incompatible with WordPress’ test suite.  These are not bad assumptions, just incompatible ones.

  • Include the bootstrap before the PHPUnit library.  This causes problems because the bootstrap cannot reference PHPUnit (e.g. extending PHPUnit_Framework_TestCase).
  • Always include the PHPUnit library.  This causes problems because the bootstrap may have already included PHPUnit (to solve the above problem).  Code like this would solve the issue:
    if( !function_exists( 'phpunit_autoload' ) ) {
    require_once( 'PHPUnit/Autoload.php' );
  • Each test case…

View original post 222 more words


WordPress local dev tips: DB & plugins

Mark on WordPress

Running a WordPress site on your local machine is a great way to do development. I’ve taken advantage of this to do development while on flights (and yes, I realize that in about 5 years it’s going to seem positively quaint that there used to be flights without Internet access).

Today, I’d like to tackle two common issues when running a WordPress site locally:

  1. Handling differing database connection details
  2. Handling plugins that can’t or shouldn’t run on a localhost

My assumptions:

  • You have your site in a Git repository
  • You have a working LAMP/MAMP/WAMP/whatever setup.
  • You already know how to do a mysqldump and import that dump to your local machine

Database connection details

Your database user and password are (or should) be different on your localhost than they are on your production environment. One way to handle this is to have wp-config.php not be in version control and have…

View original post 287 more words


WordPress Filter: manage edit-post type columns

This filter applied to the list of columns to print on the manage posts screen for a custom post type. Filter function argument/return value is an associative array where the element key is the name of the column, and the value is the header text for that column.

Add Columns

Suppose you have a ‘books’ custom post type and you want to add the publisher and book author in the edit page but remove the post author.

function set_edit_book_columns($columns) {


return array_merge($columns,

array('publisher' => __('Publisher'),

'book_author' =>__( 'Book Author')));


add_filter('manage_edit-books_columns' , 'set_edit_book_columns');

Replace Columns

Here’s another example that completely replaces the columns, rather than adding and removing specific ones.

function set_edit_book_columns($columns) {

return array(

'cb' => '',

'title' => __('Title'),

'date' => __('Date'),

'publisher' => __('Publisher'),

'book_author' =>__( 'Book Author')



add_filter('manage_edit-books_columns' , 'set_edit_book_columns');

Note the header for the ‘cb’ column is a checkbox, so that the checked posts can be toggled between all and none.

via Plugin API/Filter Reference/manage edit-post type columns « WordPress Codex.

Tagged ,

Wildcard domains DNS and local WAMP for website development

I have found this very useful while configuring wildcard DNS entry in your local development environment based on Windows for WordPress multi-site:

Configuring DNS wildcards with Acrilic DNS Proxy

I was looking for a tool like this for a long time. Normally I had to configure Dnsmasq on a Linux machine, but with Acrylic it is a lot more easier and all local on a Windows machine.

Download Acrilic DNS Proxy from Sourceforge: sourceforge.net/projects/acrylic/

After installation go to menu:
Start->Programs->Acrilic DNS Proxy->Config->Edit Custom Hosts File

Add the folowing lines on the end of the file:	*.localhost	*.local	*.lc

Now you need to restart the Acrilic DNS Proxy service. Go to menu:
Start->Programs->Acrilic DNS Proxy->Config->Restart Acrilic Service