CMB2 Pipes amazements and next steps

Amazement while trying to pipe things around.

Amazing things happen on both sides

The code below, taken straight from the current version of the CMB2 Pipes plugin, will take care of adding a date and time field to the post edit screen leveraging Custom Meta Boxes 2 power

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 date', 'cmb2' ),
        'id'   => cmb2_pipe('the_date','<>', 'post_date'),
        'type' => 'text_datetime_timestamp',
    ) );
}

The piping is happening on the 'id' => cmb2_pipe('the_date','<>', 'post_date') line and, in plain english, means

When a date is selected in the meta box field do not save it to a meta value but save it to the post_date attribute; when the time comes to populate the date field with a value do not look for a meta value: look for the current post post_date

What’s amazing is the amount of filtering and salinization WordPress will do for me to avoid junk from getting into the database and, on the other end, the amount of filtering and salinization Custom Meta Boxes 2 will do to avoid showing non sense values.

Amazement enough, time for tests

While I’d like to get back to my Etsy Little Helper project I now do not have the time to do it; I will devote some time snippets to testing the piping possibilities the CMB2 Pipes plugin offers and will do it using the updated WPBrowser suite version I’ve just pushed.

Probably related

I appreciate your input