Tribe__Repository::build_postarr( $id = null )
{@inheritdoc}
Source
File: src/Tribe/Repository.php
public function build_postarr( $id = null ) {
$postarr = array(
'tax_input' => array(),
'meta_input' => array(),
);
/*
* The check is lax here by design: we leave space for the client code
* to use this method to build post arrays; when this is used by the
* repository the integrity of `$id` is granted.
*/
$is_update = null !== $id && is_numeric( $id );
// But still let's provide values that make sense.
if ( $is_update ) {
$postarr['ID'] = (int) $id;
}
foreach ( $this->updates as $key => $value ) {
if ( is_callable( $value ) ) {
$value = $value( $id, $key, $this );
}
// Allow fields to be aliased
$key = Tribe__Utils__Array::get( $this->update_fields_aliases, $key, $key );
if ( ! $this->can_be_updated( $key ) ) {
throw Tribe__Repository__Usage_Error::because_this_field_cannot_be_updated( $key, $this );
}
if ( $this->is_a_post_field( $key ) ) {
if ( $this->requires_converted_date( $key ) ) {
$this->update_postarr_dates( $key, $value, $postarr );
} else {
$postarr[ $key ] = $value;
}
} elseif ( $this->is_a_taxonomy( $key ) ) {
$taxonomy = get_taxonomy( $key );
if ( $taxonomy instanceof WP_Taxonomy ) {
$postarr['tax_input'][ $key ] = Tribe__Utils__Array::list_to_array( $value );
}
} else {
// it's a custom field
$postarr['meta_input'][ $key ] = $value;
}
}
return $postarr;
}