Framework 2.4

February 2, 2020

Framework 2.4 brings with it two additional conditional callbacks, the isPostType and isPostTypeArchive callbacks.

IsPostType

The isPostType callback can be used like this:

$app->isPostType('icecream', function() use ($app) {

  // your code goes here.

});

Where the icecream is the post type name in slug form.

IsPostTypeArchive

The isPostTypeArchive callback can be used like this:

$app->isPostTypeArchive('icecream', function() use ($app) {

  // your code goes here.

});

Where the icecream, again, is the post type name in slug form.

BaboonWP 2.0

January 10, 2020

Announcing the immediate availability of version 2.0 of our WordPress theme helper class & JavaScript library, except that from now on we'll call it a theme development framework because that's what it essentially is starting the pretty damn big 2.0 update.

Changelog

  • BaboonWP is now a WordPress plugin, so to install it simply upload the .zip file from releases to the admin panel.
  • No longer using static methods, so you must first initialize the class with new and set it to a variable.
  • Added conditional callbacks
  • Added templating
  • Added querying content

Conditional callbacks

Conditionals in WordPress you already know about, the is_home, is_page, etc. Since with BaboonWP we are moving away from classic theme files (PHP & HTML mix), we tend to do everything within functions.php. Conditional callbacks help us achieve a number of things. For example, to execute a bunch of code only on a certain page:

$app->is_page('about', function() use($app) {

  // execute stuff here

});

Or to maybe just execute stuff on the front page:

$app->is_front_page(function() use($app) {

  // execute stuff here

});

Templating

The biggest change to 2.0 is the templating, with what we intend to entirely abandon the old PHP/HTML spaghetti practices that have plagued WordPress for so long. To use BaboonWP templating, simply call the template method, like so:

$app->is_front_page(function() use($app) {

  $app->template('home', [
    'name' => 'John'
  ]);

});

That will then load the Handlebars template file located at templates/home.hbs. And then in your handlebars file you can do stuff like this:

Hi, {{name}}.

Querying content

Since WP_Query itself isn't templating language friendly (with its nested objects and stuff), we now have a wrapper on top of it, which you can access with the query method. It doesn't support just about everything yet, but we'll get there.

You can query for stuff, for templates, like this:

$app->is_front_page(function() use($app) {

  $app->template('blog', [
    'posts' => $app->query(['post_type' => 'post'])
  ]);

]);

As you can see, you can pass the exact same parameters to the query that you can pass to WP_Query.

To conclude

BaboonWP 2.0 is a big update and a shift in a new bold direction, it is by no means ready for use with big and complex WordPress sites just yet, but we'll be adding to it as we use it and need the stuff to be there. All tough the flexibility of it should allow for quite complex stuff already.

There's a lot more that I didn't cover in this post, but you can read in the documentation.