You appear to be a bot. Output may be restricted
Description
Creates a new post locally
The fields need to be slashed, using wp_slash, to avoid losing backslashes. That's what's done on update, so why was it missing on insert? … well in Multi Site clone it caused a problem with post_taxonomies
Usage
$$post_id = oik_clone_insert_post( $source_post );
Parameters
- $source_post
- ( mixed ) required –
Returns
$post_id the ID of the newly created post
TO DO
What should we do with the guid?
Source
File name: oik-clone/admin/oik-clone-actions.php
Lines:
1 to 20 of 20
function oik_clone_insert_post( $source_post ) { $post_taxonomies = $source_post->post_taxonomies; $post = (array) $source_post; unset( $post['post_taxonomies'] ); unset( $post['ID'] ); $post = wp_slash( $post ); $post['post_taxonomies'] = $post_taxonomies; p( "Inserting post: " . $post['post_title'] ); bw_trace2( $post ); $post_id = wp_insert_post( $post, true ); //$post_id = 123; if ( is_wp_error( $post_id ) ) { p( "oops" ); bw_trace2( $post_id, "wperror", false ); } else { p( "Post created: " . $post_id ); } return( $post_id ); }