Advertisement
Guest User

WPML - duplicate_master_post - 0.001

a guest
Feb 18th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. function duplicate_master_post($post_id, $post, $update){
  2.     global $sitepress, $iclTranslationManagement;
  3.    
  4.     if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
  5.         return;
  6.     }
  7.     // don't save for revisions
  8.     if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
  9.         return;
  10.     }
  11.     // only duplicate when publishing
  12.     if ($post->post_status != 'publish') {
  13.         return;
  14.     }
  15.     // avoid recursion
  16.     remove_action('wp_insert_post', 'duplicate_master_post', 10);
  17.  
  18.     if ( !isset( $iclTranslationManagement ) ) {
  19.         $iclTranslationManagement = new TranslationManagement;
  20.     }
  21.        
  22.     $post_type = get_post_type( $post_id );
  23.     if ( $sitepress->is_translated_post_type( $post_type ) ) {
  24.         $iclTranslationManagement->make_duplicates_all( $post_id );
  25.     }
  26. }
  27. add_action('wp_insert_post', 'duplicate_master_post', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement