Tribe__Events__Aggregator__Record__Abstract::save( int $post_id, array $args = array(), array $meta = array() )
Edits an import record
Contents
Parameters
- $post_id
-
(int) (Required) Post ID to edit.
- $args
-
(array) (Optional) Post type args.
Default value: array()
- $meta
-
(array) (Optional) Post meta.
Default value: array()
Return
(WP_Post|WP_Error)
Source
File: src/Tribe/Aggregator/Record/Abstract.php
public function save( $post_id, $args = array(), $meta = array() ) {
if ( ! isset( $meta['type'] ) || 'schedule' !== $meta['type'] ) {
return tribe_error( 'core:aggregator:invalid-edit-record-type', $meta );
}
$defaults = array(
'parent' => 0,
);
$args = (object) wp_parse_args( $args, $defaults );
$defaults = array(
'frequency' => null,
);
$meta = wp_parse_args( $meta, $defaults );
$post = $this->prep_post_args( $meta['type'], $args, $meta );
$post['ID'] = absint( $post_id );
$post['post_status'] = Tribe__Events__Aggregator__Records::$status->schedule;
add_filter( 'wp_insert_post_data', array( $this, 'dont_change_post_modified' ), 10, 2 );
$result = wp_update_post( $post );
remove_filter( 'wp_insert_post_data', array( $this, 'dont_change_post_modified' ) );
if ( ! is_wp_error( $result ) ) {
$this->maybe_add_meta_via_pre_wp_44_method( $result, $post['meta_input'] );
}
// After Creating the Post Load and return
return $this->load( $result );
}