@@ -21,6 +21,7 @@ function blc_register_settings() {
2121 $ timeout_constraints = blc_get_request_timeout_constraints ();
2222 $ head_timeout_limits = isset ($ timeout_constraints ['head ' ]) ? $ timeout_constraints ['head ' ] : array ('default ' => 5 );
2323 $ get_timeout_limits = isset ($ timeout_constraints ['get ' ]) ? $ timeout_constraints ['get ' ] : array ('default ' => 10 );
24+ $ recheck_constraints = blc_get_recheck_interval_days_constraints ();
2425
2526 register_setting (
2627 $ option_group ,
@@ -72,6 +73,16 @@ function blc_register_settings() {
7273 )
7374 );
7475
76+ register_setting (
77+ $ option_group ,
78+ 'blc_recheck_interval_days ' ,
79+ array (
80+ 'type ' => 'integer ' ,
81+ 'sanitize_callback ' => 'blc_sanitize_recheck_interval_days_option ' ,
82+ 'default ' => isset ($ recheck_constraints ['default ' ]) ? $ recheck_constraints ['default ' ] : 7 ,
83+ )
84+ );
85+
7586 register_setting (
7687 $ option_group ,
7788 'blc_link_delay ' ,
@@ -262,6 +273,17 @@ function blc_register_settings_sections() {
262273 )
263274 );
264275
276+ add_settings_field (
277+ 'blc_recheck_interval_days ' ,
278+ __ ('🔁 Délai avant re-contrôle ' , 'liens-morts-detector-jlg ' ),
279+ 'blc_render_recheck_interval_field ' ,
280+ $ page ,
281+ 'blc_planification_section ' ,
282+ array (
283+ 'label_for ' => 'blc_recheck_interval_days ' ,
284+ )
285+ );
286+
265287 add_settings_section (
266288 'blc_performance_section ' ,
267289 __ ('Performance ' , 'liens-morts-detector-jlg ' ),
@@ -462,6 +484,21 @@ function blc_get_timezone_label() {
462484 return $ timezone_label ;
463485}
464486
487+ /**
488+ * Retourne les contraintes associées au délai de re-contrôle des liens.
489+ *
490+ * @since 1.1.0
491+ *
492+ * @return array<string, int>
493+ */
494+ function blc_get_recheck_interval_days_constraints () {
495+ return array (
496+ 'min ' => 1 ,
497+ 'max ' => 30 ,
498+ 'default ' => 7 ,
499+ );
500+ }
501+
465502/**
466503 * Retourne la liste des fréquences prédéfinies disponibles dans l'interface.
467504 *
@@ -692,6 +729,64 @@ function blc_render_frequency_field() {
692729 <?php
693730}
694731
732+ /**
733+ * Affiche le champ de délai avant re-contrôle des liens.
734+ *
735+ * @return void
736+ */
737+ function blc_render_recheck_interval_field () {
738+ $ constraints = blc_get_recheck_interval_days_constraints ();
739+ $ min_days = isset ($ constraints ['min ' ]) ? (int ) $ constraints ['min ' ] : 1 ;
740+ $ max_days = isset ($ constraints ['max ' ]) ? (int ) $ constraints ['max ' ] : 30 ;
741+ $ default = isset ($ constraints ['default ' ]) ? (int ) $ constraints ['default ' ] : $ min_days ;
742+
743+ $ stored_value = get_option ('blc_recheck_interval_days ' , $ default );
744+ $ value = is_numeric ($ stored_value ) ? (int ) $ stored_value : $ default ;
745+
746+ if ($ value < $ min_days ) {
747+ $ value = $ min_days ;
748+ } elseif ($ value > $ max_days ) {
749+ $ value = $ max_days ;
750+ }
751+
752+ ?>
753+ <div class="blc-recheck-interval-field">
754+ <label class="screen-reader-text" for="blc_recheck_interval_days"><?php esc_html_e ('Nombre de jours avant re-vérification automatique ' , 'liens-morts-detector-jlg ' ); ?> </label>
755+ <input
756+ type="range"
757+ name="blc_recheck_interval_days"
758+ id="blc_recheck_interval_days"
759+ value="<?php echo esc_attr ($ value ); ?> "
760+ min="<?php echo esc_attr ($ min_days ); ?> "
761+ max="<?php echo esc_attr ($ max_days ); ?> "
762+ step="1"
763+ >
764+ <output id="blc_recheck_interval_days_output" for="blc_recheck_interval_days"><?php echo esc_html ($ value ); ?> </output>
765+ <?php esc_html_e ('jours ' , 'liens-morts-detector-jlg ' ); ?>
766+ <p class="description">
767+ <?php esc_html_e ('Détermine après combien de jours un lien non vérifié est de nouveau signalé comme à recontrôler dans la liste. ' , 'liens-morts-detector-jlg ' ); ?>
768+ </p>
769+ </div>
770+ <script>
771+ (function() {
772+ var slider = document.getElementById('blc_recheck_interval_days');
773+ var output = document.getElementById('blc_recheck_interval_days_output');
774+
775+ if (!slider || !output) {
776+ return;
777+ }
778+
779+ var update = function() {
780+ output.textContent = slider.value;
781+ };
782+
783+ slider.addEventListener('input', update);
784+ update();
785+ })();
786+ </script>
787+ <?php
788+ }
789+
695790/**
696791 * Affiche les champs de plage horaire de repos.
697792 *
@@ -1245,6 +1340,31 @@ function blc_sanitize_rest_end_hour_option($value) {
12451340 return blc_sanitize_rest_hour_option ($ value , 'blc_rest_end_hour ' , '20 ' );
12461341}
12471342
1343+ /**
1344+ * Sanitize le délai avant re-contrôle automatique.
1345+ *
1346+ * @param mixed $value Valeur brute.
1347+ *
1348+ * @return int
1349+ */
1350+ function blc_sanitize_recheck_interval_days_option ($ value ) {
1351+ $ constraints = blc_get_recheck_interval_days_constraints ();
1352+
1353+ $ min = isset ($ constraints ['min ' ]) ? (int ) $ constraints ['min ' ] : 1 ;
1354+ $ max = isset ($ constraints ['max ' ]) ? (int ) $ constraints ['max ' ] : 30 ;
1355+ $ default = isset ($ constraints ['default ' ]) ? (int ) $ constraints ['default ' ] : $ min ;
1356+
1357+ $ sanitized = is_scalar ($ value ) ? (int ) $ value : $ default ;
1358+
1359+ if ($ sanitized < $ min ) {
1360+ $ sanitized = $ min ;
1361+ } elseif ($ sanitized > $ max ) {
1362+ $ sanitized = $ max ;
1363+ }
1364+
1365+ return $ sanitized ;
1366+ }
1367+
12481368/**
12491369 * Sanitize le délai entre deux liens.
12501370 *
0 commit comments