array( array( 'handle' => 'aiforya-sm-tab-migration', 'src' => AIFORYA_SM_URL . 'assets/css/tab-migration.css', 'ver' => AIFORYA_SM_VERSION, ), ), ); } public function render( array $args = array() ): void { $service = Aiforya_Schema_Markup_Migration::get_instance(); $detected = $service->detect_competitors(); $history = $service->get_history( 20 ); $nonce = wp_create_nonce( 'aiforya_sm_admin_nonce' ); // Helper D2 : pastille d'aide « ? » charte (AiforyaTooltip). $text déjà traduit. $tip = static function ( $text ) { printf( '', esc_attr( $text ) ); }; /* * V786-B — le comportement part par wp_add_inline_script(), plus par une balise de script * écrite dans le HTML (grief n°2 de wordpress.org, compté ERREUR par le Plugin Check). * * ⚠ NOWDOC (<<<'JS'), surtout pas heredoc : le corps contient $btn, $host, $t, $ — un * heredoc les remplacerait par du vide, sans qu aucun contrôle ne crie. * ⚠ ET ON N ÉCRIT PAS LA BALISE EN CLAIR DANS CE COMMENTAIRE. Première rédaction : elle * y était, et l inventaire l a RECOMPTÉE — le correctif se dénonçait lui-même comme le * défaut. 4ᵉ occurrence en trois jours de la même famille (V785-B en cite trois). */ $handle = 'aiforya-sm-tab-migration-js'; wp_register_script( $handle, false, array( 'jquery' ), AIFORYA_SM_VERSION, true ); wp_enqueue_script( $handle ); wp_localize_script( $handle, 'aiforyaSmMigrationL10n', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => $nonce, 'confirmImport' => __( 'Import schemas from this plugin? Existing AIFORYA schemas will be overwritten for the same posts.', 'aiforya-schema-markup' ), 'failed' => __( 'Failed.', 'aiforya-schema-markup' ), 'network' => __( 'Network error.', 'aiforya-schema-markup' ), ) ); $js = <<<'JS' jQuery(function($){ var L = window.aiforyaSmMigrationL10n || {}; var ajaxUrl = window.ajaxurl || L.ajaxUrl; var nonce = L.nonce; $('#aiforya-sm-migration-toast-host').appendTo('body'); function smToast(message, type, ttl) { type = type || 'info'; ttl = ttl || 4500; var $host = $('.aiforya-sm-toast-host').last(); var $t = $('
', { 'class': 'aiforya-sm-toast aiforya-sm-toast--' + type, role: 'status' }).text(message); $host.append($t); setTimeout(function(){ $t.addClass('is-visible'); }, 10); setTimeout(function(){ $t.removeClass('is-visible'); setTimeout(function(){ $t.remove(); }, 300); }, ttl); } $(document).on('click', '.aiforya-sm-mig-import', function(){ var $btn = $(this); var src = $btn.data('source'); var orig = $btn.html(); window.AiforyaConfirm.ask(L.confirmImport, function(){ $btn.prop('disabled', true).html(''); $.post(ajaxUrl, { action: 'aiforya_sm_migration_import', nonce: nonce, source: src }).done(function(r){ if (r && r.success) { var d = r.data || {}; smToast(d.message || 'OK', 'success'); $('.aiforya-sm-mig-result[data-source-result="' + src + '"]').html('' + (d.message || '') + ''); setTimeout(function(){ location.reload(); }, 1200); } else { smToast((r && r.data && r.data.message) || L.failed, 'error'); } }).fail(function(){ smToast(L.network, 'error'); }).always(function(){ $btn.prop('disabled', false).html(orig); }); }); }); }); JS; wp_add_inline_script( $handle, $js ); ?>

$d ) : ?>

source_plugin ); ?> status ); ?> posts_imported ); ?> posts_failed ); ?> started_at ); ?>