Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function duplicate_master_post($post_id, $post, $update){
- global $sitepress, $iclTranslationManagement;
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- // don't save for revisions
- if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
- return;
- }
- // only duplicate when publishing
- if ($post->post_status != 'publish') {
- return;
- }
- // avoid recursion
- remove_action('wp_insert_post', 'duplicate_master_post', 10);
- if ( !isset( $iclTranslationManagement ) ) {
- $iclTranslationManagement = new TranslationManagement;
- }
- $post_type = get_post_type( $post_id );
- if ( $sitepress->is_translated_post_type( $post_type ) ) {
- $iclTranslationManagement->make_duplicates_all( $post_id );
- }
- }
- add_action('wp_insert_post', 'duplicate_master_post', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement