PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.0
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
← All changes | inc/fields/base.php +23 -1 1.0.01.1.0 View file →
@@ -359,9 +359,9 @@
359 359 * @since 0.0.1
360 360 * @return string
361 361 */
362 362 protected function generate_error_markup() {
363 - $error_text = $this->error_msg ? $this->error_msg : __( 'This field is required.', 'suredonation' );
363 + $error_text = $this->error_msg ? $this->error_msg : $this->default_required_message();
364 364
365 365 return sprintf(
366 366 '<p id="sd-error-%s" class="sd-error" role="alert" style="display: none;">%s</p>',
367 367 esc_attr( $this->block_id ),
@@ -366,8 +366,30 @@
366 366 '<p id="sd-error-%s" class="sd-error" role="alert" style="display: none;">%s</p>',
367 367 esc_attr( $this->block_id ),
368 368 esc_html( $error_text )
369 369 );
370 + }
371 +
372 + /**
373 + * Resolve the default required-field message for this field type.
374 + *
375 + * Mirrors the server-side resolution so the pre-rendered message matches
376 + * what the server would return: the admin-configured global default (Global
377 + * Settings → Form Validation) for the field type, falling back to a generic
378 + * message for field types without a configurable default.
379 + *
380 + * @since 1.1.0
381 + * @return string
382 + */
383 + protected function default_required_message() {
384 + // Derive the key via the same helper the server uses, so the key is
385 + // normalized identically (e.g. hyphenated field types) and the editor /
386 + // markup / server never resolve different keys for the same field.
387 + $message = \SureDonation\Inc\Field_Validation::get_validation_message(
388 + \SureDonation\Inc\Field_Validation::required_message_key( 'suredonation/' . $this->slug )
389 + );
390 +
391 + return '' !== $message ? $message : __( 'This field is required.', 'suredonation' );
370 392 }
371 393
372 394 /**
373 395 * Get aria-describedby attribute value.