feat: estilo editorial de la IA configurable (editorial-style.php)
La IA del plugin 'AI' redacta segun el estilo del pack: editorial-style.php (tono, normas, prohibidos, max chars de titulares) se copia a wp-content y un mu-plugin lo inyecta en las instrucciones de sistema via wpai_system_instruction (scp: wpai_title_generation_system_instruction para el cap de caracteres). Editas el fichero, re-ejecutas deploy y la IA cambia de estilo.
This commit is contained in:
1 parent
b3c2098d10
commit
f86717b542
4 files changed
+85
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: d0a1 — Instrucciones editoriales IA (mu-plugin)
|
||||
* Description: Inyecta el estilo editorial (editorial-style.php del pack) en las instrucciones de sistema del plugin "AI".
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
function d0a1_editorial_style() {
|
||||
$file = WP_CONTENT_DIR . '/editorial-style.php';
|
||||
if ( ! file_exists( $file ) ) { return null; }
|
||||
$s = include $file;
|
||||
return is_array( $s ) ? $s : null;
|
||||
}
|
||||
|
||||
function d0a1_editorial_block() {
|
||||
$s = d0a1_editorial_style();
|
||||
if ( ! $s ) { return ''; }
|
||||
$out = "\n\nESTILO EDITORIAL DEL SITIO (prioridad sobre instrucciones anteriores):\n";
|
||||
if ( ! empty( $s['estilo'] ) ) { $out .= 'Tono: ' . $s['estilo'] . "\n"; }
|
||||
if ( ! empty( $s['reglas'] ) ) {
|
||||
$out .= "Normas:\n";
|
||||
foreach ( $s['reglas'] as $r ) { $out .= '- ' . $r . "\n"; }
|
||||
}
|
||||
if ( ! empty( $s['prohibido'] ) ) {
|
||||
$out .= "Prohibido:\n";
|
||||
foreach ( $s['prohibido'] as $p ) { $out .= '- ' . $p . "\n"; }
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// Global: todas las funciones IA del plugin (titulos, extractos, alt text, moderacion...).
|
||||
add_filter( 'wpai_system_instruction', function ( $instruction ) {
|
||||
return $instruction . d0a1_editorial_block();
|
||||
}, 10, 1 );
|
||||
|
||||
// Afinar titulares: max chars configurable en editorial-style.php.
|
||||
add_filter( 'wpai_title_generation_system_instruction', function ( $instruction ) {
|
||||
$s = d0a1_editorial_style();
|
||||
if ( $s && ! empty( $s['titulares_max_chars'] ) && $s['titulares_max_chars'] !== 80 ) {
|
||||
$instruction = preg_replace( '/Be no more than \d+ characters/', 'Be no more than ' . (int) $s['titulares_max_chars'] . ' characters', $instruction );
|
||||
}
|
||||
return $instruction;
|
||||
}, 10, 1 );
|
||||
Reference in new issue
Block a user