Skip to main content

wp shell

If you’re a WordPress backend developer and don’t use wp shell, you must continue reading.

I have this imaginary plugin that is used to fetch some data from a third-party service and store every item as a post of a custom post type. Now I need to figure out how something deep down in this very complex integration works, but there’s a problem: To be able to test it locally I’d have to start an import that will fetch GB’s of data that I don’t need. Only to simulate what happens when a specific function is being executed as part of that import. wp shell to the rescue!

Let’s say that there’s an \ImaginaryPlugin\format_description( string $description ) function that is the function we’d like to test or debug. There’s also an ImaginaryPlugin\get_item( int $item_id ) function that can be used to get an item. Testing it on an existing item is as simple as this:

$ wp shell

wp> $item = \ImaginaryPlugin\get_item( 123 );
  array(3) {
  'id' =>
  int(123)
  'name' =>
  string(7) "Test"
  'description' =>
  string(14) "This_is_a_test"
}

wp> \ImaginaryPlugin\format_description( $item['description'] );
string(14) "This is a test"

Awesome! Being able to do this can make debugging or testing a breeze compared to actually testing things by refreshing the web page or running new imports over and over again.

There are of course other ways to test this specific and rather bad example, but the point of this post still stands: wp shell is very useful!

In general, the whole WP CLI project is an addition to WordPress that I find extremely useful. If you’re not familiar with it, check it out: https://wp-cli.org/

Next steps

Here are a few things you can do:

2026

September

  • Note

    As quite evident by looking at my brand new reading page, I haven't read very much this year. Going forward I will do my very best to finish the books I'm currently reading and find some new exciting books to read. Currently only finished three, the goal is 10!

  • Note

    I just ordered a Fairphone 6+, Fairbuds and Fairbuds XL.

    I have an iPhone 17 as my daily driver, but I couldn't help but order this phone and headsets once I became aware it was a thing.

    My plan is to switch to all of these things, replacing my iPhone 17, AirPods Pro 3 and Bose QuietComfort Ultra. These will either be sold or given to someone who needs them.

    The initiative is great and their values even better. We need companies trying to counter the enormous pressure laid upon all of us to keep buying stuff all the time.

    I will post a thorough review of these items once I've used them for a while.

  • Tømmerneset rock carvings

2025

April

  • Note

    I will be posting changes to my website simply as notes tagged with changelog. This is the very first changelog of this site, and it summarizes the most important changes I've done since I started wiping the dust of this site in April this year.

    • I've added a Buttondown newsletter integration. Whenever I publish a new post on my blog, an email will be sent to my subscribers.
    • I've added a «Reply by email» button to all content. Do not hestitate to contact me if you have comments or feedback. Getting feedback is a big part of why I blog in the first place — I enjoy hearing from readers and being part of a thoughtful exchange now and then.
    • I've added a Search feature using Pagefind. It's not yet fully configured or customized, but it's working.
    • Added links to previous and next post, note and link.
    • Added a 404 page.
    • Reduced the size of uncompressed resources being loaded on the front page to 66 kB. Submitted a PR to be added to the 512kb.club website.
  • Our dog: Kento
  • Note

    This is the very first note on my new website. It's a GREAT note.

    It doesn't say much, but still – it marks the beginning of a new note-hosting era for this website.

  • Back to basics – again..