WC_Admin_Duplicate_Product::duplicate_post_taxonomies PHP Méthode

duplicate_post_taxonomies() private méthode

Copy the taxonomies of a post to another post.
private duplicate_post_taxonomies ( mixed $id, mixed $new_id, mixed $post_type )
$id mixed
$new_id mixed
$post_type mixed
        private function duplicate_post_taxonomies($id, $new_id, $post_type)
        {
            $exclude = array_filter(apply_filters('woocommerce_duplicate_product_exclude_taxonomies', array()));
            $taxonomies = array_diff(get_object_taxonomies($post_type), $exclude);
            foreach ($taxonomies as $taxonomy) {
                $post_terms = wc_get_object_terms($id, $taxonomy);
                $post_terms_count = sizeof($post_terms);
                for ($i = 0; $i < $post_terms_count; $i++) {
                    wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true);
                }
            }
        }