diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 5d177fed286..b1cbf57c290 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -3277,6 +3277,20 @@ EOD; ); } + /** + * Outputs a screen reader only inline text. + * + * @param string $contents The contents of the paragraph + * @return string the HTML to output. + */ + public function sr_text(string $contents): string { + return html_writer::tag( + 'span', + $contents, + ['class' => 'sr-only'] + ) . ' '; + } + /** * Outputs a container. * diff --git a/lib/upgrade.txt b/lib/upgrade.txt index b07dcec3ab3..7df51950287 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -53,6 +53,7 @@ information provided here is intended especially for developers. the page displays a heading for the activity (usually a h2 heading containing the activity name). * New method moodleform::filter_shown_headers() is created to show some expanded headers only and hide the rest. * count_words() and count_letters() have a new optional parameter called $format to format the text before doing the counting. +* New core_renderer::sr_text method to generate screen reader only inline texts without using html_writter. === 4.2 ===