Created
March 5, 2015 16:04
-
-
Save suth/301708ddd7e8e4d36bc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Video Importer Temporary Drafts | |
Plugin URI: https://refactored.co | |
Description: Temporarily saves imported posts as a draft so any publishing logic doesn't run until custom fields are saved | |
Version: 1.0 | |
Author: Refactored Co. | |
Author URI: https://refactored.co | |
*/ | |
function temporarily_save_imported_video_as_draft( $post ) { | |
$post['post_status'] = 'draft'; | |
return $post; | |
} | |
add_filter( 'refactored_video_importer/post_array', 'temporarily_save_imported_video_as_draft', 10, 1 ); | |
function update_imported_video_status_after_saving_custom_fields( $post_id, $provider, $video_array, $source_id, $import_options ) { | |
if ( $import_options['post_status'] != 'draft' ) { | |
$post = array( | |
'ID' => $post_id, | |
'post_status' => $import_options['post_status'] | |
); | |
wp_update_post( $post ); | |
} | |
} | |
add_action( 'refactored_video_importer/single_video_imported', 'update_imported_post_status_after_saving_custom_fields', 15, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment