PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.6.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.6.1
1.6.1 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 +61 -1 1.0.0 → 1.6.1 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 ),
@@ -369,8 +369,30 @@
369 369 );
370 370 }
371 371
372 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' );
392 + }
393 +
394 + /**
373 395 * Get aria-describedby attribute value.
374 396 *
375 397 * @since 0.0.1
376 398 * @return string
@@ -436,6 +458,44 @@
436 458 $g = min( 255, $g + ( ( 255 - $g ) * $percent / 100 ) );
437 459 $b = min( 255, $b + ( ( 255 - $b ) * $percent / 100 ) );
438 460
439 461 return sprintf( '#%02x%02x%02x', $r, $g, $b );
462 + }
463 +
464 + /**
465 + * Get the checked/unchecked SVG icon for a radio or checkbox option.
466 + *
467 + * Shared by every field that renders the option-pill markup (the donation
468 + * amount choices and the payment-type chooser), so the two cannot drift apart.
469 + *
470 + * @param string $type Icon type (circle-checked, circle-unchecked, square-checked, square-unchecked).
471 + * @param string $classes CSS class.
472 + * @return string SVG markup.
473 + * @since 1.5.1
474 + */
475 + protected function get_svg_icon( $type, $classes = '' ) {
476 + $class_attr = $classes ? ' class="' . esc_attr( $classes ) . '"' : '';
477 +
478 + switch ( $type ) {
479 + case 'circle-checked':
480 + return '<svg' . $class_attr . ' width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
481 + <path d="M15.1663 7.38674V8.00007C15.1655 9.43769 14.7 10.8365 13.8392 11.988C12.9785 13.1394 11.7685 13.9817 10.3899 14.3893C9.0113 14.797 7.53785 14.748 6.18932 14.2498C4.8408 13.7516 3.68944 12.8308 2.90698 11.6248C2.12452 10.4188 1.75287 8.99211 1.84746 7.55761C1.94205 6.12312 2.49781 4.75762 3.43186 3.66479C4.36591 2.57195 5.6282 1.81033 7.03047 1.4935C8.43274 1.17668 9.89985 1.32163 11.213 1.90674" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
482 + <path d="M15.1667 2.6665L8.5 9.33984L6.5 7.33984" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
483 + </svg>';
484 + case 'circle-unchecked':
485 + return '<svg' . $class_attr . ' width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
486 + <path d="M7.99967 14.6668C11.6816 14.6668 14.6663 11.6821 14.6663 8.00016C14.6663 4.31826 11.6816 1.3335 7.99967 1.3335C4.31778 1.3335 1.33301 4.31826 1.33301 8.00016C1.33301 11.6821 4.31778 14.6668 7.99967 14.6668Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
487 + </svg>';
488 + case 'square-checked':
489 + return '<svg' . $class_attr . ' width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
490 + <path d="M6.5 7.33366L8.5 9.33366L15.1667 2.66699" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
491 + <path d="M14.5 8V12.6667C14.5 13.0203 14.3595 13.3594 14.1095 13.6095C13.8594 13.8595 13.5203 14 13.1667 14H3.83333C3.47971 14 3.14057 13.8595 2.89052 13.6095C2.64048 13.3594 2.5 13.0203 2.5 12.6667V3.33333C2.5 2.97971 2.64048 2.64057 2.89052 2.39052C3.14057 2.14048 3.47971 2 3.83333 2H11.1667" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
492 + </svg>';
493 + case 'square-unchecked':
494 + return '<svg' . $class_attr . ' width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
495 + <path d="M12.6667 2H3.33333C2.59695 2 2 2.59695 2 3.33333V12.6667C2 13.403 2.59695 14 3.33333 14H12.6667C13.403 14 14 13.403 14 12.6667V3.33333C14 2.59695 13.403 2 12.6667 2Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
496 + </svg>';
497 + default:
498 + return '';
499 + }
440 500 }
441 501 }