Make WordPress Core

Changeset 54137


Ignore:
Timestamp:
09/12/2022 10:29:02 PM (19 months ago)
Author:
audrasjb
Message:

Comments: Make wp_required_field_indicator() and wp_required_field_message() output filterable.

This changeset introduces two new hooks:

  • wp_required_field_indicator allows developers to filter the HTML output of the wp_required_field_indicator() function.
  • wp_required_field_message does the same for the wp_required_field_message() function.

The changeset also adds new phpunit tests for these filters.

Follow-up to [53888], [54136].

Props kebbet, audrasjb, sabernhardt, costdev, mukesh27.
Fixes #56389.
See #54394.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r54136 r54137  
    50275027    $indicator = '<span class="required">' . esc_html( $glyph ) . '</span>';
    50285028
    5029     return $indicator;
     5029    /**
     5030     * Filters the markup for a visual indicator of required form fields.
     5031     *
     5032     * @since 6.1.0
     5033     *
     5034     * @param string $indicator Markup for the indicator element.
     5035     */
     5036    return apply_filters( 'wp_required_field_indicator', $indicator );
    50305037}
    50315038
     
    50445051    );
    50455052
    5046     return $message;
     5053    /**
     5054     * Filters the message to explain required form fields.
     5055     *
     5056     * @since 6.1.0
     5057     *
     5058     * @param string $message Message text and glyph wrapped in a `span` tag.
     5059     */
     5060    return apply_filters( 'wp_required_field_message', $message );
    50475061}
    50485062
Note: See TracChangeset for help on using the changeset viewer.