Advertisement
mbis

Clone the permalink with the translation (WPML)

Apr 2nd, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. function pm_clone_translation_uri($master_post_id, $lang, $post_array, $id) {
  2.     global $permalink_manager_uris;
  3.  
  4.     // Trigger the function only if duplicate is created in the metabox
  5.     if(empty($_POST['action']) || $_POST['action'] !== 'make_duplicates') { return; }
  6.  
  7.     $permalink_manager_uris[$id] = (!empty($permalink_manager_uris[$master_post_id])) ? $permalink_manager_uris[$master_post_id] : Permalink_Manager_URI_Functions_Post::get_default_post_uri($id);
  8.  
  9.     update_option('permalink-manager-uris', $permalink_manager_uris);
  10. }
  11. add_action('icl_make_duplicate', 'pm_clone_translation_uri', 9999, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement