@@ -549,13 +549,64 @@ function blc_dashboard_links_page() {
549549 }
550550
551551 // Préparation des données et des statistiques pour les liens
552- global $ wpdb ;
553- $ table_name = $ wpdb ->prefix . 'blc_broken_links ' ;
554- $ broken_links_count = (int ) $ wpdb ->get_var (
555- $ wpdb ->prepare (
556- "SELECT COUNT(*) FROM $ table_name WHERE type = %s AND ignored_at IS NULL " ,
557- 'link '
558- )
552+ $ list_table = new BLC_Links_List_Table ();
553+ $ status_counts = $ list_table ->get_status_counts ();
554+
555+ $ broken_links_count = isset ($ status_counts ['active_count ' ]) ? (int ) $ status_counts ['active_count ' ] : 0 ;
556+ $ not_found_count = isset ($ status_counts ['not_found_count ' ]) ? (int ) $ status_counts ['not_found_count ' ] : 0 ;
557+ $ server_error_count = isset ($ status_counts ['server_error_count ' ]) ? (int ) $ status_counts ['server_error_count ' ] : 0 ;
558+ $ redirect_count = isset ($ status_counts ['redirect_count ' ]) ? (int ) $ status_counts ['redirect_count ' ] : 0 ;
559+ $ needs_recheck_count = isset ($ status_counts ['needs_recheck_count ' ]) ? (int ) $ status_counts ['needs_recheck_count ' ] : 0 ;
560+
561+ $ dashboard_base_url = function_exists ('admin_url ' )
562+ ? admin_url ('admin.php?page=blc-dashboard ' )
563+ : 'admin.php?page=blc-dashboard ' ;
564+
565+ $ build_dashboard_url = static function ($ link_type ) use ($ dashboard_base_url ) {
566+ if ($ link_type === 'all ' ) {
567+ return $ dashboard_base_url ;
568+ }
569+
570+ if (function_exists ('add_query_arg ' )) {
571+ return add_query_arg ('link_type ' , $ link_type , $ dashboard_base_url );
572+ }
573+
574+ $ separator = (false === strpos ($ dashboard_base_url , '? ' )) ? '? ' : '& ' ;
575+
576+ return $ dashboard_base_url . $ separator . 'link_type= ' . rawurlencode ($ link_type );
577+ };
578+
579+ $ stats_cards = array (
580+ array (
581+ 'slug ' => 'all ' ,
582+ 'link_type ' => 'all ' ,
583+ 'value ' => number_format_i18n ($ broken_links_count ),
584+ 'label ' => __ ('Liens morts trouvés ' , 'liens-morts-detector-jlg ' ),
585+ ),
586+ array (
587+ 'slug ' => '404 ' ,
588+ 'link_type ' => 'status_404_410 ' ,
589+ 'value ' => number_format_i18n ($ not_found_count ),
590+ 'label ' => __ ('Erreurs 404 / 410 ' , 'liens-morts-detector-jlg ' ),
591+ ),
592+ array (
593+ 'slug ' => '5xx ' ,
594+ 'link_type ' => 'status_5xx ' ,
595+ 'value ' => number_format_i18n ($ server_error_count ),
596+ 'label ' => __ ('Erreurs 5xx ' , 'liens-morts-detector-jlg ' ),
597+ ),
598+ array (
599+ 'slug ' => 'redirects ' ,
600+ 'link_type ' => 'status_redirects ' ,
601+ 'value ' => number_format_i18n ($ redirect_count ),
602+ 'label ' => __ ('Redirections détectées ' , 'liens-morts-detector-jlg ' ),
603+ ),
604+ array (
605+ 'slug ' => 'recheck ' ,
606+ 'link_type ' => 'needs_recheck ' ,
607+ 'value ' => number_format_i18n ($ needs_recheck_count ),
608+ 'label ' => __ ('Liens à revérifier ' , 'liens-morts-detector-jlg ' ),
609+ ),
559610 );
560611 $ option_size_bytes = blc_get_dataset_storage_footprint_bytes ('link ' );
561612 $ last_check_time = get_option ('blc_last_check_time ' , 0 );
@@ -567,30 +618,47 @@ function blc_dashboard_links_page() {
567618 ? wp_date ('j M Y ' , $ last_check_time )
568619 : __ ('Jamais ' , 'liens-morts-detector-jlg ' );
569620
570- $ list_table = new BLC_Links_List_Table ();
571621 $ list_table ->prepare_items ();
572622 blc_render_action_modal ();
573623
574624 ?>
575- <div class="wrap">
625+ <div class="wrap blc-dashboard-links-page ">
576626 <?php blc_render_dashboard_tabs ('links ' ); ?>
577627 <h1><?php esc_html_e ('Rapport des Liens Cassés ' , 'liens-morts-detector-jlg ' ); ?> </h1>
578628 <div class="blc-stats-box">
579- <div class="blc-stat">
580- <span class="blc-stat-value"><?php echo esc_html ($ broken_links_count ); ?> </span>
581- <span class="blc-stat-label"><?php esc_html_e ('Liens morts trouvés ' , 'liens-morts-detector-jlg ' ); ?> </span>
582- </div>
583- <div class="blc-stat">
584- <span class="blc-stat-value"><?php echo esc_html ($ size_display ); ?> </span>
585- <span class="blc-stat-label"><?php esc_html_e ('Poids des données ' , 'liens-morts-detector-jlg ' ); ?> </span>
629+ <?php foreach ($ stats_cards as $ card ) :
630+ $ link_type = $ card ['link_type ' ];
631+ $ card_url = $ build_dashboard_url ($ link_type );
632+ $ aria_label = sprintf (
633+ /* translators: 1: Stat label, 2: number of items. */
634+ __ ('Afficher %1$s (%2$s) ' , 'liens-morts-detector-jlg ' ),
635+ $ card ['label ' ],
636+ $ card ['value ' ]
637+ );
638+ ?>
639+ <a
640+ class="blc-stat blc-stat--<?php echo esc_attr ($ card ['slug ' ]); ?> "
641+ href="<?php echo esc_url ($ card_url ); ?> "
642+ data-link-type="<?php echo esc_attr ($ link_type ); ?> "
643+ aria-label="<?php echo esc_attr ($ aria_label ); ?> "
644+ >
645+ <span class="blc-stat-value"><?php echo esc_html ($ card ['value ' ]); ?> </span>
646+ <span class="blc-stat-label"><?php echo esc_html ($ card ['label ' ]); ?> </span>
647+ </a>
648+ <?php endforeach ; ?>
649+ </div>
650+ <div class="blc-meta-box">
651+ <div class="blc-meta">
652+ <span class="blc-meta-value"><?php echo esc_html ($ size_display ); ?> </span>
653+ <span class="blc-meta-label"><?php esc_html_e ('Poids des données ' , 'liens-morts-detector-jlg ' ); ?> </span>
586654 </div>
587- <div class="blc-stat ">
588- <span class="blc-stat -value"><?php echo esc_html ($ last_check_display ); ?> </span>
589- <span class="blc-stat -label"><?php esc_html_e ('Dernière analyse ' , 'liens-morts-detector-jlg ' ); ?> </span>
655+ <div class="blc-meta ">
656+ <span class="blc-meta -value"><?php echo esc_html ($ last_check_display ); ?> </span>
657+ <span class="blc-meta -label"><?php esc_html_e ('Dernière analyse ' , 'liens-morts-detector-jlg ' ); ?> </span>
590658 </div>
591- <div class="blc-stat ">
592- <span class="blc-stat -value"><?php echo esc_html ($ next_scheduled_display ); ?> </span>
593- <span class="blc-stat -label"><?php esc_html_e ('Prochaine analyse automatique ' , 'liens-morts-detector-jlg ' ); ?> </span>
659+ <div class="blc-meta ">
660+ <span class="blc-meta -value"><?php echo esc_html ($ next_scheduled_display ); ?> </span>
661+ <span class="blc-meta -label"><?php esc_html_e ('Prochaine analyse automatique ' , 'liens-morts-detector-jlg ' ); ?> </span>
594662 <?php if ('' !== $ schedule_note ) : ?>
595663 <span class="blc-stat-note"><?php echo esc_html ($ schedule_note ); ?> </span>
596664 <?php endif ; ?>
0 commit comments