WordPress / WordPress/WordPress-Coding-Standards
Flag use of `the_title()` within a HTML element attribute
Open
Nobody has claimed this yet.
Focus: Code analysis
Focus: WP interoperability
Type: Enhancement
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Using the_title() within a HTML attribute is incorrect. Instead, the_title_attribute() should be used.
Nonsensical example:
<img src="http://example.org/test.jpg" alt="<?php the_title_attribute();">
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named in the issue. Start by locating the PHP_CodeSniffer sniff that checks WordPress function usage, then inspect its existing tests and identify where HTML attribute contexts are parsed. Done means the incorrect use of the_title() in an HTML attribute is flagged and the_title_attribute() is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100