42. Intégration WP-CLI | Field Forge - Champs personnalisés, conçus pour la vitesse
Télécharger Se connecter

42. Intégration WP-CLI

Gérez les données Field Forge depuis la ligne de commande en utilisant wp eval.

Exporter Tous les Groupes de Champs vers JSON

bash
wp eval 'echo FIELDFORGE_Local_JSON::instance()->save_all();'

Vérifier l’État de Synchronisation

bash
wp eval '$d = FIELDFORGE_Local_JSON::instance()->get_diff(); print_r($d);'

Forcer la Synchronisation de JSON vers DB

bash
wp eval 'FIELDFORGE_Local_JSON::instance()->sync("json_to_db");'

Lister Tous les Groupes de Champs

bash
wp eval '
$groups = FIELDFORGE_Field_Groups::instance()->get_all();
foreach ( $groups as $g ) {
    $fields = json_decode( $g->fields, true );
    printf( "#%d: %s (%d fields)\n", $g->id, $g->title, count( $fields ) );
}
'

Obtenir les Valeurs de Champ pour une Publication

bash
wp eval '
$fields = get_fields( 42 );
foreach ( $fields as $name => $value ) {
    printf( "%s = %s\n", $name, is_array( $value ) ? json_encode( $value ) : $value );
}
'

Mise à Jour en Masse des Valeurs de Champ

bash
wp eval '
$posts = get_posts( [ "post_type" => "product", "numberposts" => -1, "fields" => "ids" ] );
foreach ( $posts as $id ) {
    $price = (float) get_field( "price", $id );
    update_field( "price", $price * 1.1, $id );
}
echo count( $posts ) . " products updated.\n";
'

Exécuter la Migration ACF

bash
wp eval '
$imp = FIELDFORGE_ACF_Import::instance();
$det = $imp->detect();
printf( "Found: %d groups, %d fields, %d posts\n", $det["groups"], $det["fields"], $det["posts_with_values"] );
$res = $imp->import_groups();
printf( "Migrated: %d groups, %d errors\n", $res["migrated"], $res["errors"] );
'

Vider le Cache de Field Forge

bash
wp eval 'FIELDFORGE_Performance::instance()->flush_all(); echo "Cache flushed.\n";'

Assistant IA Forge En ligne

Bonjour ! Je suis l'assistant IA Field Forge. Posez-moi n'importe quelle question sur le plugin — configuration, fonctionnalités, dépannage ou développement.

À l'instant
Propulsé par Forge IA · Parcourir la documentation