#28180 closed enhancement (fixed)
No get equivalent for language_attributes()
Reported by: | PeterRKnight | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 2.1 |
Component: | Themes | Keywords: | has-patch |
Focuses: | template | Cc: |
Description
In core most functions that can output a string call a function that returns a string instead of returning it. The language_attributes() function is an exception to this and always echoes a string. I was expecting there to be an equivalent get_language_attributes() function that returns a string instead.
I ran into this need while coding conditional IE fallback code for the opening HTML tag. Rather than call language_attributes() multiple times, I wanted to store the attributes in a string. The current workaround is either using output buffering or simply calling language_attributes() multiple times, both of which are undesirable because it adds unnecessary operations. It also imposes a limitation in how a developer may choose to output html.
I propose adding get_language_attributes() for consistency and flexibility purposes.
Attachments (3)
Change History (9)
#1
@
10 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 3.9 to 2.1
Not sure if I18n would be a more accurate component for this.
#3
@
9 years ago
Patch inspired from @PeterRKnight PHP file
- created get_language_attributes function with original language_attributes function code without echo
- language_attributes function call now get_language_attributes and echo result
#4
@
9 years ago
- Keywords needs-testing 2nd-opinion removed
- Milestone changed from Future Release to 4.3
This makes sense. Let's do it.
28180.diff corrects the language_attributes.28180.diff patch, improves the docs, and also adds $doctype
as a parameter to the language_attributes
filter.
patch adding get_language_attributes() and modifying language_attributes()