/**
  * Duplicate template styles.
  * 
  * @param int $new_id 
  * @param object $post
  */
 function duplicate_template_style($new_id, $post)
 {
     $current_style = get_post_meta($new_id, 'tf_template_style_modules', true);
     if ($current_style) {
         $old_sc_ids = tf_get_shortcode_ids($this->old_post_content);
         $new_sc_ids = tf_get_shortcode_ids($this->new_post_content);
         $new_style = array();
         if (count($old_sc_ids) > 0) {
             foreach ($old_sc_ids as $key => $id) {
                 if (isset($current_style[$old_sc_ids[$key]])) {
                     $new_style[$new_sc_ids[$key]] = $current_style[$old_sc_ids[$key]];
                 }
             }
         }
         update_post_meta($new_id, 'tf_template_style_modules', $new_style);
     }
 }
/**
 * Replace builder content sc_id with new unique shortcode id.
 * 
 * @since 1.0.0
 * @param string $content 
 * @return string
 */
function tf_generate_new_shortcode_ids($content)
{
    $unique_ids = tf_get_shortcode_ids($content);
    if (count($unique_ids) > 0) {
        foreach ($unique_ids as $id) {
            $new_id = TF_Model::generate_block_id();
            $content = str_replace($id, $new_id, $content);
            usleep(300);
            //because php will not have time to generate new id and will return the same id
        }
    }
    return $content;
}