PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.8
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.8
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
← All changes | inc/form-restriction.php +27 -0 2.7.0 → 2.12.8 View file →
@@ -7,8 +7,9 @@
7 7 */
8 8
9 9 namespace SRFM\Inc;
10 10
11 +use SRFM\Inc\Compatibility\Multilingual\String_Translator;
11 12 use SRFM\Inc\Database\Tables\Entries;
12 13 use SRFM\Inc\Traits\Get_Instance;
13 14
14 15 if ( ! defined( 'ABSPATH' ) ) {
@@ -131,8 +132,30 @@
131 132 if ( ! is_int( $entries_count ) ) {
132 133 $entries_count = 0; // Ensure entries count is a non-negative integer.
133 134 }
134 135
136 + /**
137 + * Filter the count of entries used to evaluate the Maximum Number of Entries
138 + * cap. Allows extensions (e.g. SureForms Pro's Recurring Entry Limit) to
139 + * substitute a window-scoped count — entries since the start of today /
140 + * the current week / month / year — in place of the lifetime count.
141 + *
142 + * Returning a value greater than `$entries_count` will trip the cap sooner;
143 + * returning a smaller value will defer it. Non-integer return values are
144 + * coerced back to a non-negative integer.
145 + *
146 + * @param int $entries_count Lifetime entry count for the form.
147 + * @param int $form_id The ID of the form.
148 + * @param array<string, mixed> $form_restriction The form restriction settings.
149 + * @since 2.8.2
150 + */
151 + $entries_count = apply_filters( 'srfm_form_restriction_entries_count', $entries_count, $form_id, $form_restriction );
152 +
153 + // Always coerce to a non-negative integer — covers both non-int returns
154 + // from a misbehaving extension AND negative-int returns that would
155 + // otherwise silently disable the cap (e.g. -5 >= 100 is false).
156 + $entries_count = max( 0, (int) $entries_count );
157 +
135 158 return $entries_count >= $max_entries;
136 159 }
137 160
138 161 /**
@@ -232,8 +255,12 @@
232 255
233 256 // Get the scheduling state and appropriate message.
234 257 $scheduling_state = self::get_form_scheduling_state( $form_restriction );
235 258 $form_restriction_message = self::get_restriction_message_by_state( $scheduling_state, $form_restriction );
259 +
260 + // Translate the restriction message via the active multilingual provider
261 + // (no-op when no WPML/Polylang is installed).
262 + $form_restriction_message = String_Translator::get_instance()->translate_restriction_message( (int) $form_id, $form_restriction_message );
236 263
237 264 $form_restriction_message = apply_filters( 'srfm_form_restriction_message', $form_restriction_message, $form_id, $form_restriction );
238 265
239 266 ob_start();