Tinkerwell was initially created for Laravel developers but it is framework agnostic since day one. This makes it a perfect companion for WordPress developers who often write pure PHP and rely a lot on helper functions of the WordPress platform.
When you run code in Tinkerwell, it detects your WordPress site and bootstraps everything that you need before the code in the editor runs – this makes accessing the database or working with plugins a breeze.
Imagine that you want to display the latest three published posts on your homepage. Instead of jumping into the template and trying to get the method right and display them with a foreach loop, why not fire up Tinkerwell and write the method to fetch them first. If you are happy with the results and can confirm that you want these posts, copy the code over to the template and work on the output.
wp_get_recent_posts([ 'numberposts' => 3, 'post_status' => 'publish'])
When the performance of a WordPress site is slow, it’s often worth checking the options table and checking if there are options in the autoloader that are from disabled plugins or if there are simply too many that aren’t needed.
With Tinkerwell, you can simply open your site in the editor and run wp_load_alloptions()
to see what’s loaded on
every request. You can also run get_option('blogname')
and read the content of an option – and if you want
to add a new option during development, simply run add_option('tinkerwell_is_awesome', true)
and you are
set.
There are several ways to create users for your WordPress site – but creating them with code can be very convenient, especially if you need test users or simply want to create a new admin user for yourself. By leveraging Magic Comments, you can display the generated password directly in the editor and use it to log in with your new account.
wp_create_user( 'Marcel', wp_generate_password(12, false), //?);
Let’s take that a step further and imagine that you need 10,000 users for testing the performance for your site. You can quickly create them with a simple script instead of fiddling around with the WordPress CLI or even think of letting your intern create them via the admin interface.
for ($i = 0; $i < 10000; $i++) { wp_create_user( uniqid(), wp_generate_password(12, false), uniqid().'@example.com' );}
When working on a new feature, it often helps to write code in isolation but with access to all your data. In this simple example, we’re querying the users list and extracting all fields that we need for our new user table. When we’re happy with the results, we can copy this to our site and work on the UI – knowing that we’ll get exact the data that we need and without hitting the browser countless times before.
get_users([ 'fields' => [ 'ID', 'user_nicename', 'user_email' ], 'number' => 25]);
Tinkerwell can also display the results of arrays within a table view, which makes working with data super convenient. The Table Mode features an integrated CSV export, so if you want to export some records that are available as an array, use Tinkerwell instead of writing a custom export for your site.
Tinkerwell is super versatile and as you can imagine from these basic examples, it helps you debugging your WordPress site and speeds up plugin development by giving you code access without hitting your browser or deploying the site to a server countless times.
The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.
Buy now Learn more