From 43b406a5ee84e89683599826421886adb753db01 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Mon, 12 Sep 2022 22:31:10 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@54137 git-svn-id: http://core.svn.wordpress.org/trunk@53696 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 18 ++++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index acc3b5bda2..1a23cb4316 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -5026,7 +5026,14 @@ function wp_required_field_indicator() { $glyph = __( '*' ); $indicator = '' . esc_html( $glyph ) . ''; - return $indicator; + /** + * Filters the markup for a visual indicator of required form fields. + * + * @since 6.1.0 + * + * @param string $indicator Markup for the indicator element. + */ + return apply_filters( 'wp_required_field_indicator', $indicator ); } /** @@ -5043,7 +5050,14 @@ function wp_required_field_message() { sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator() ) ); - return $message; + /** + * Filters the message to explain required form fields. + * + * @since 6.1.0 + * + * @param string $message Message text and glyph wrapped in a `span` tag. + */ + return apply_filters( 'wp_required_field_message', $message ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 2650849f8a..7868e41281 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54136'; +$wp_version = '6.1-alpha-54137'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.