array( array( 'handle' => 'aiforya-sm-tab-health', 'src' => AIFORYA_SM_URL . 'assets/css/tab-health.css', 'ver' => AIFORYA_SM_VERSION, ), ), ); } public function render( array $args = array() ): void { $service = Aiforya_Schema_Markup_Health::get_instance(); $report = $service->compute_score(); $history = $service->get_history( 90 ); $nonce = wp_create_nonce( 'aiforya_sm_admin_nonce' ); $score = (int) $report['score']; $status = $score >= 90 ? 'excellent' : ( $score >= 70 ? 'good' : ( $score >= 50 ? 'partial' : 'weak' ) ); /* * V786-B — le comportement part par wp_add_inline_script() (grief n°2 de wordpress.org, * compté ERREUR par le Plugin Check). NOWDOC obligatoire : le corps contient $btn, $host, * $t, $status, $ — un heredoc les remplacerait par du vide, en silence. */ $handle = 'aiforya-sm-tab-health-js'; wp_register_script( $handle, false, array( 'jquery' ), AIFORYA_SM_VERSION, true ); wp_enqueue_script( $handle ); wp_localize_script( $handle, 'aiforyaSmHealthL10n', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => $nonce, 'recomputing' => __( 'Recalculating…', 'aiforya-schema-markup' ), 'recomputed' => __( 'Score recalculated.', 'aiforya-schema-markup' ), 'recomputedOk' => __( 'Health Score recalculated.', 'aiforya-schema-markup' ), 'failed' => __( 'Failed.', 'aiforya-schema-markup' ), 'network' => __( 'Network error.', 'aiforya-schema-markup' ), ) ); $js = <<<'JS' jQuery(function($){ var L = window.aiforyaSmHealthL10n || {}; var ajaxUrl = window.ajaxurl || L.ajaxUrl; var nonce = L.nonce; $('#aiforya-sm-health-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); } $('#aiforya-sm-health-recompute').on('click', function(){ var $btn = $(this); var $status = $('.aiforya-sm-health-status-text'); $btn.prop('disabled', true); $status.text(L.recomputing).css('color', '#94a3b8'); $.post(ajaxUrl, { action: 'aiforya_sm_health_compute', nonce: nonce }).done(function(r){ if (r && r.success) { $status.text(L.recomputed).css('color', '#4ade80'); smToast(L.recomputedOk, 'success'); setTimeout(function(){ location.reload(); }, 600); } else { $status.text((r && r.data && r.data.message) || L.failed).css('color', '#f87171'); } }).fail(function(){ $status.text(L.network).css('color', '#f87171'); }).always(function(){ $btn.prop('disabled', false); }); }); }); JS; wp_add_inline_script( $handle, $js ); // Helper D2 : pastille d'aide « ? » charte (AiforyaTooltip). $text déjà traduit. $tip = static function ( $text ) { printf( '', esc_attr( $text ) ); }; ?>

/100
array( __( 'Coverage', 'aiforya-schema-markup' ), $report['coverage'], /* translators: % o : valeur insérée dynamiquement. */ __( '% of published posts have a schema', 'aiforya-schema-markup' ), __( 'The share of your published content that already carries markup. The higher it is, the better Google understands your site.', 'aiforya-schema-markup' ) ), 'quality' => array( __( 'Quality', 'aiforya-schema-markup' ), $report['quality'], __( 'Average quality score across active schemas', 'aiforya-schema-markup' ), __( 'The average completeness of your schemas: the more required and recommended fields you fill in, the better the mark.', 'aiforya-schema-markup' ) ), 'diversity' => array( __( 'Diversity', 'aiforya-schema-markup' ), $report['diversity'], __( 'Coverage of the 10 target Schema.org types', 'aiforya-schema-markup' ), __( 'How varied the schema types on your site are. A rich site uses several types (Article, Product, FAQ and so on).', 'aiforya-schema-markup' ) ), 'validation' => array( __( 'Validation', 'aiforya-schema-markup' ), $report['validation'], /* translators: % s : valeur insérée dynamiquement. */ __( '% schemas validated without Google Rich Results errors', 'aiforya-schema-markup' ), __( 'The share of your schemas that pass the Google Rich Results check with no blocking error.', 'aiforya-schema-markup' ) ), ); // ⛔ 13/08/2026 — l'axe Search Console n'est affiché QUE si // l'intégration existe réellement. Avant, il était rendu dans // toutes les variantes et annonçait « 0 open error(s) — daily // repair active » à 100 % alors qu'aucune erreur n'était jamais // récupérée : une fonction absente notée au maximum. if ( ! empty( $report['gsc_actif'] ) ) { $axes['gsc_score'] = array( __( 'Search Console', 'aiforya-schema-markup' ), $report['gsc_score'], sprintf( /* translators: %d : valeur insérée dynamiquement. */ __( '%d open error(s) — daily repair active', 'aiforya-schema-markup' ), (int) $report['gsc_errors'] ), __( 'Search Console is Google\'s free tool, which reports the markup errors it finds on your site.', 'aiforya-schema-markup' ) ); } foreach ( $axes as $key => $a ) : $val = (int) $a[1]; $axis_status = $val >= 90 ? 'excellent' : ( $val >= 70 ? 'good' : ( $val >= 50 ? 'partial' : 'weak' ) ); ?>
%

= 90 ? 'excellent' : ( $h >= 70 ? 'good' : ( $h >= 50 ? 'partial' : 'weak' ) ); ?>