Oh, domingo, dilación ...
enlace
- Permite agregar términos en masa
red
- Puede seleccionar qué sitios serán
afectados
- Funciona con taxonomías personalizadas
- No se elimina
- No se sincroniza
Esto es algo que he hecho en las últimas horas y no tengo tiempo para más pruebas ahora. De todos modos - funciona para mí! .)
Inténtalo. También se implementó una función de "ejecución de prueba" para que pueda verificar el resultado antes de hacer algo.
Actualizar - > Capturas de pantalla:
Antes de la acción:

Despuésdelapruebadeejecución:
El complemento vinculado anteriormente agrega una interfaz de usuario, pero casi todo lo importante sucede en esta función:
<?php function mau_add_network_terms($terms_to_add, $siteids, $testrun = false) {
// check if this is multisite install
if ( !is_multisite() )
return 'This is not a multisite WordPress installation.';
// very basic input check
if ( empty($terms_to_add) || empty($siteids) || !is_array($terms_to_add) || !is_array($siteids) )
return 'Nah, I eat only arrays!';
if ($testrun) $log = '<p><em>No need to get excited. This is just a test run.</em></p>';
else $log = '';
// loop thru blogs
foreach ($siteids as $blog_id) :
switch_to_blog( absint($blog_id) );
$log .= '<h4>'.get_blog_details( $blog_id )->blogname.':</h4>';
$log .= '<ul id="ntlog">';
// loop thru taxonomies
foreach ( $terms_to_add as $taxonomy => $terms ) {
// check if taxonomy exists
if ( taxonomy_exists($taxonomy) ) {
// get taxonomy name
$tax_name = get_taxonomy($taxonomy);
$tax_name = $tax_name->labels->name;
//loop thru terms
foreach ( $terms as $term ) {
// check if term exists
if ( term_exists($term, $taxonomy) ) {
$log .= "<li class='notice' ><em>$term already exists in the $tax_name taxonomy - not added!</em></li>";
} else {
// if it doesn't exist insert the $term to $taxonomy
$term = strip_tags($term);
$taxonomy = strip_tags($taxonomy);
if (!$testrun)
wp_insert_term( $term, $taxonomy );
$log .= "<li><b>$term</b> successfully added to the <b>$tax_name</b> taxonomy</li>";
}
}
} else {
// tell our log that taxonomy doesn't exists
$log .= "<li class='notice'><em>The $tax_name taxonomy doesn't exist! Skipping...</em></li>";
}
}
$log .= '</ul>';
// we're done here
restore_current_blog();
endforeach;
if ($testrun) $log .= '<p><em>No need to get excited. This was just the test run.</em></p>';
return $log;
} ?>
Volveré y editaré esto con más información más adelante (si es necesario).
Está lejos de ser perfecto (lea los problemas conocidos en el encabezado del complemento).
Cualquier comentario apreciado!