ActionScheduler_wpPostStore::save_post_array
Save post array.
Method of the class: ActionScheduler_wpPostStore{}
No Hooks.
Returns
Int. Returns the post ID.
Usage
// protected - for code of main (parent) or child class $result = $this->save_post_array( $post_array );
- $post_array(array) (required)
- Post array.
ActionScheduler_wpPostStore::save_post_array() ActionScheduler wpPostStore::save post array code WC 10.8.1
protected function save_post_array( $post_array ) {
add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );
$has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );
if ( $has_kses ) {
// Prevent KSES from corrupting JSON in post_content.
kses_remove_filters();
}
$post_id = wp_insert_post( $post_array );
if ( $has_kses ) {
kses_init_filters();
}
remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );
if ( is_wp_error( $post_id ) || empty( $post_id ) ) {
throw new RuntimeException( __( 'Unable to save action.', 'woocommerce' ) );
}
return $post_id;
}