The basic functions of the CMB2 Pipes plugin are covered: time to get back to proper TDD flow.
I’ve updated the lonely functional test that is covering the meager functions the CMB2 Pipes plugin is now offering: read and/or write sync with post fields from Custom Meta Boxes 2 generated meta boxes.
I’m using WP Browser and its WP Loader module for the tests in the Codeception environment and am quite fond of the result.
While WordPress will take care of much filtering and sanitisation to avoid junk from getting into the database I’d like to implement some more post related functions like function based filtering before a value is written to the post field or after it has been read from it in a fashion like the one below
$args = [ 'object_id' => $id, 'object_type' => 'post', 'field_args' => [ 'name' => __( 'The post series', 'cmb2' ), // field_id, direction, target_field, after_read_filter, before_write_filter 'id' => cmb2_pipe( $field_id, '', 'post_title', 'get_series_name', 'prepend_series_name' ), 'type' => 'text', ] ];
and piping to Posts 2 Posts relations; the syntax might be something like
$args = [ 'object_id' => $id, 'object_type' => 'post', 'field_args' => [ 'name' => __( 'Select cited people', 'cmb2' ), 'id' => cmb2_p2p_pipe( $field_id, '', 'post_citation'), 'type' => 'text', ] ];
and I can think of many scenarios I could use this.