Laying out the first step in CMB2 Piping plugin development.
Draft code
I’ve pushed a first code draft to GitHub and added a small code sample to try it out.
New example code
The new approach, in coding terms, differs little from what I had originally imagined but still offers a quick and easy enough interface to satisfy me.
add_action( 'cmb2_init', 'post_meta_boxes' );
function post_meta_boxes() {
$post_meta_box = new_cmb2_box( array(
'id' => 'post-metabox',
'title' => __( 'A Meta Box', 'cmb2' ),
'object_types' => array( 'post' )
) );
$post_meta_box->add_field( array(
'name' => __( 'The post title', 'cmb2' ),
// literally "read and write the content of this field from/to the post title"
'id' => cmb2_pipe('the_title','<>', 'post_title'),
'type' => 'text_small',
) );
}
This is a very small first step now working for posts alone but I can already see some interesting developments beside the comfort it offers not to deal with filter functions of sort.