Skip to content

Commit

Permalink
MDL-81825 core: Replace sr_text() with visually_hidden_text()
Browse files Browse the repository at this point in the history
In core renderer, replace 'sr_text' method with 'visually_hidden_text' to be
consistent with Bootstrap 5 upgrade.
  • Loading branch information
roland04 committed Nov 8, 2024
1 parent b44f9ec commit 2e7d8a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .upgradenotes/MDL-81825-2024110812525353.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
issueNumber: MDL-81825
notes:
core:
- message: >-
The 'core_renderer::sr_text()' function has been deprecated, use
'core_renderer::visually_hidden_text()' instead.
type: deprecated
16 changes: 15 additions & 1 deletion lib/classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2952,12 +2952,26 @@ public function paragraph(string $contents, ?string $classes = null, ?string $id
*
* @param string $contents The contents of the paragraph
* @return string the HTML to output.
* @deprecated since 5.0. Use visually_hidden_text() instead.
* @todo Final deprecation in Moodle 6.0. See MDL-83671.
*/
#[\core\attribute\deprecated('core_renderer::visually_hidden_text()', since: '5.0', mdl: 'MDL-81825')]
public function sr_text(string $contents): string {
\core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]);
return $this->visually_hidden_text($contents);
}

/**
* Outputs a visually hidden inline text (but accessible to assistive technologies).
*
* @param string $contents The contents of the paragraph
* @return string the HTML to output.
*/
public function visually_hidden_text(string $contents): string {
return html_writer::tag(
'span',
$contents,
['class' => 'sr-only']
['class' => 'visually-hidden']
) . ' ';
}

Expand Down

0 comments on commit 2e7d8a5

Please sign in to comment.