Opened 16 years ago
Closed 15 years ago
#10643 closed enhancement (duplicate)
Refactor <title> tag content generation
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8 |
Component: | Template | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
At this moment default theme uses following code to generate <title> tag:
<title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
Other templates uses something similar. Unfortunately this approach does not allow to completely control the title from plugins, so plugins (mainly SEO ones) uses output buffering and some kind of string search/replace to overcome this. This works, but is not good from performance perspective. Also this may produce unexpected results due to interaction between two such plugins, when one of them does not handle this correctly.
The easiest approach is to move <title> generation to backend completely, or pass whole title through new filter in template.
Because SEO plugins calls ob_start() before header.php file is loaded, we need to develop some kind of mechanism (or extend existing one if exists) so template can inform others that it supports the new approach. Plugins could then check this and either register handler for new title hook or call ob_start(). I think of new function, which should take an associative array or URI-param-like string. This function will be called from template's functions.php file.
I can write patch for this. Please let me know what do you think about my idea, and give me advice which approach should I take to implement the "template features" mechanism.
Attachments (2)
Change History (5)
#2
@
15 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 3.0
As I wrote earlier, plugins which wants to completely change title have to use ob_start() in order to do this.
Fortunately now it is easy to implement - WP 2.9 introduces add_theme_support()
and current_theme_supports()
, which we can use - see attached patches (two, for default and classic themes).
Not sure we need to do this.
I don't see why a plugin needs to change this - the theme has good enough control over things as it is.