Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#10643 closed enhancement (duplicate)

Refactor <title> tag content generation

Reported by: sirzooro's profile sirzooro Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Template Keywords: has-patch 2nd-opinion
Focuses: Cc:


At this moment default theme uses following code to generate <title> tag:

<title><?php wp_title('&laquo;', 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)

default_theme.diff (947 bytes) - added by sirzooro 15 years ago.
Patch for Default Theme
classic_theme.diff (817 bytes) - added by sirzooro 15 years ago.
Patch for Classic Theme

Download all attachments as: .zip

Change History (5)

#1 @westi
15 years ago

  • Milestone changed from 2.9 to Future Release

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.

#2 @sirzooro
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).

15 years ago

Patch for Default Theme

15 years ago

Patch for Classic Theme

#3 @nacin
14 years ago

  • Milestone 3.0 deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.