Hi, shure, that’s the code:
`//CREATE BUTTON IN THE BACKEND FOR AUTOFILL SHORT DESCRIPTION AND TAGS
add_action( ‘post_submitbox_misc_actions’, function() { #add a button near the publish/update button
global $post;
$attribute_names_for_tags = array( ‘pa_marca’, ‘pa_modello’, ‘pa_tipologia’, ‘pa_tipo-prodotto’, ‘pa_codice-oem’, ‘pa_codice-concorrenza’, ‘pa_stato’ ); #get the taxonomies for autofill tags
foreach ( $attribute_names_for_tags as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );
if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = $term->name;
array_push( $terms_array, $full_line );
}
$tags .= implode( $terms_array, ‘, ‘ ).’,’;
}
}
}
$attribute_names_for_desc = array( ‘pa_marca’, ‘pa_modello’, ‘pa_codice-oem’, ‘pa_codice-concorrenza’ ); #get the taxonomies for autofill short-description
foreach ( $attribute_names_for_desc as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );
if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = $term->name;
array_push( $terms_array, $full_line );
}
$short_desc .= ucwords(ltrim(str_replace(‘-‘, ‘ ‘, $taxonomy->name), ‘pa_’)) . ‘: ‘ . implode( $terms_array, ‘, ‘ ).'<br>’;
}
}
}
?>
<div class=”options_group”>
<p class=”form_field” style=”text-align:center;”>
<input type=”button” class=”button button-primary” value=”AUTOFILL DESCRIZIONE BREVE & TAGS” onclick=”document.getElementById(‘new-tag-product_tag’).value='<?php echo substr($tags, 0, strlen($tags)-1); ?>’;document.querySelector(‘.tagadd’).click();document.getElementById(‘excerpt_ifr’).contentWindow.document.getElementById(‘tinymce’).innerHTML='<?php echo $short_desc; ?>’;”>
</p>
</div>
<?php
} );