You appear to be a bot. Output may be restricted
Description
Import the contents into the target postAttempt to load the post that's been asked for. If the target post is what we hope it is. If it's not then we have to decide:
- Do we try to find the matching post
- or should we already know it
Usage
oik_clone_attempt_import( $source, $target, $post );
Parameters
- $source
- ( ID ) required – the ID of the source post
- $target
- ( ID ) required – the ID of the target post
- $post
- ( array ) required – the post to clone
Returns
voidSource
File name: oik-clone/admin/oik-clone-clone.phpLines:
1 to 58 of 58
function oik_clone_attempt_import( $source, $target, $post ) { oik_require( "admin/oik-clone-actions.php", "oik-clone" ); oik_require( "admin/oik-clone-relationships.php", "oik-clone" ); $media_file = null; kses_remove_filters(); oik_clone_cloning_in_progress( true ); $target_id = oik_clone_determine_target_id( $source, $target, $post ); if ( $target_id ) { $target_post = oik_clone_load_target( $target_id ); if ( $target_post ) { $post = oik_clone_apply_mapping( $post ); oik_clone_update_target( $post, $target_id ); } else { p( "That's odd" ); } } else { p( "Looks like we'll have to create it" ); $post = oik_clone_apply_mapping( $post ); $target_id = oik_clone_insert_post( $post ); } if ( $post->post_type == "attachment" ) { oik_require( "admin/oik-clone-media.php", "oik-clone" ); $saved_post_id = bw_array_get( $_REQUEST, 'post_id', null ); bw_trace2( $saved_post_id, "saved post_id", true ); $_REQUEST['post_id'] = $post->post_parent; $upload_date = oik_clone_get_upload_month( $post->post_meta->_wp_attached_file[0] ); $media_file = oik_clone_save_media_file( $upload_date, $post ); //$post->post_date ); $post->file = $media_file['file']; if ( $saved_post_id ) { $_REQUEST['post_id'] = $saved_post_id; } } oik_clone_update_post_meta( $post, $target_id ); if ( $target_id && $media_file ) { oik_clone_update_attachment_metadata( $target_id, $media_file['file'] ); } oik_clone_update_taxonomies( $post, $target_id ); // update the post meta with the master post ID of the source ... regardless of the current source // Can we trust [HTTP_USER_AGENT] => WordPress/4.1.1; http://qw/oikcom ? // If not we'll have to pass it. // Or get it from??? oik_require( "admin/oik-save-post.php", "oik-clone" ); $master = bw_array_get( $_REQUEST, "master", null ); oik_clone_update_slave_target( $target_id, $master, $source, $post->post_modified_gmt ); oik_clone_cloning_in_progress( false ); return( $target_id ); }View on GitHub