In the past month and a half we’ve been working on a completely new versions of Cuisine, our WordPress framework. We’ve also been radically updating some of our closed-source plugins we use every day with clients. The old version of Cuisine made our jobs easier. Stuff like registering posttypes and rewrites was very easy to do. But it also carried a lot of bagage. It was still relying on vanilla css, while we were working in Sass, it’s asset pipeline wasn’t really being used in favor of tools like bower and grunt and there really wasn’t a clear designpattern in place, which meant the ecosystem of our plugins all looked different.
So in April, we decided it was time to completely redo our tools and plugins. We started with a blank sheet of paper. The most important thing to us was uniformity in code and that meant moving away from the WordPress coding standards a little more, since there seems to be an abundance of function- and object-oriented code all running along side each other. The new Cuisine looks a lot more like Laravel than WordPress code, due to the Facade design pattern we picked.
Here are some examples to give you an idea of what the new Cuisine now looks like:
//register a custom post type: //@params: post_type name, plural, singular PostType::make( 'project', 'Projects', 'Project' )->set(); //adding a new url and routing it to the 'project' post_type: //@params: post_type, overview-url, singular-url Route::url( 'project', 'our-work', 'project' );
The new release uses several of the more modern php standards, like anonymous functions and namespacing. It also has full composer support with wp cli support still in the works.
In our old plugins we tried to be as forgiving to older versions of php whenever it was possible. We decided to break with that point of view and work with modern php standards in this. Cuisine requires a minimum of PHP 5.4 but runs great on PHP7 (not counting WP errors in this). Although we’ll keep working on it and won’t commit to a definite version for now; we encourage you to keep your php version updated.
To us, frontend is the most important part of the codebase. A plugin needs to be easy to use for an administrator, but it shouldn’t get in the way of your site’s visitor. We streamlined the entire frontend stack. Our default theme Carte Blanche (which also has a completely new version out), uses Sass along with Bourbon and Neat to get your preprocessin’ going.
//get the url of this plugin: $url = Url::plugin( 'crouton/Assets/' ); //registering a script //@params: ID, URL, autoload Script::register( 'crouton-script', $url.'Frontend.js', false ); //register a sass file: //@params: ID, URL, overwrite Sass::register( 'template', $url.'_template.scss', false );
Cuisine and Cuisine-powered plugins get to tap into this as it’s possible to enqueue Sass and Scripts files, which will be automatically loaded and compiled, if necessary. All default styles are using Flexbox powered grids and layouts. We’re working on a plugin which uses Cuisine to inject extra sass-files to add old IE support, but aren’t going to include it in the core plugin, because we believe regular grid-systems will be dead and gone in about two years.
We used the Advanced Custom Fields plugin a lot. It’s a great plugin. But importing and exporting the fields in every project where we needed the same layouts wasn’t really a good option. We wanted to be able to save our field-layouts in version-control and create plugins around ’em. So Cuisine now has a full-fledged field generator. Including inline validation and ‘advanced’ fields like repeater, flex and media-library fields. It’s markup is really inspired by the Themosis Framework, which I recommend you check out.
Here’s an example of a metabox being build with some fields:
$fields = array( //creating a simple text-field: Field::text( 'field_name', 'Field Label' ), //adding more variables: Field::text( 'field_name_2', 'Field Label 2', array( 'defaultValue' => 'This is a Textfield', 'validate' => array( 'required', 'textual' ), 'placeholder' => 'Put yer text here' ) ), //Media gallery Field::media( 'media', 'Image', array( 'label' => 'top' ) ) ); //create metaboxes on the fly: //@params: Label, post_type ( string or an array of strings ). Metabox::make( 'A Metabox', 'post' )->set( $fields );
And this is what that code gives you:
You’ll notice the drag & drop media-library (with just calling ) and the inline-validation in the second field. The metabox takes care of saving the data and does this with regard to all WordPress best practices, so we auto-check for user-rights and nonces and escape values when returning em. The fields are very easy to setup, it’s super user-friendly and it’s all in code, so you can use version control.
We’ve already fallen in love with our field generator. It turns out to be a great tool to create front- and backend interfaces with and we have several plugins successfully running on it and we can’t wait for you to get your hands on it.
The new Cuisine will be released in the first week of July and it’ll be completely open source, like our previous versions. For the first time, we’ll actually have documentation (and we’re working on adding great examples). Carte Blanche (our empty theme, hooked into Cuisine) and Crouton (our empty plugin) will also be released alongside of Cuisine.
If you have any ideas or improvements, you can create a pull-request.
Finally A little teaser on what’s to come
Come September, we’re hoping to release our first two paid plugins running on the open source Cuisine platform. We’re specifically targeting WordPress developers with these plugins as we try to make their lives easier.
We’ll announce them soon, but we can already tell you that one plugin is an advanced layout-generator working with sections and columns and the other is a form generator. Both work very easily and both can be expanded to suit your needs. Also; both plugins hook into the super-clean frontend and work with exactly the same designpattern. Right now we’re in the process of translating both of ’em.