Make WordPress Core

Opened 20 years ago

Closed 20 years ago

Last modified 20 years ago

#2930 closed defect (bug) (invalid)

Filter called for wp_title does not receive all arguments

Reported by: sargant's profile sargant Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Template Keywords:
Focuses: Cc:

Description

(Using WordPress Version 2.0.3)

The function called by the filter wp_title should receive both the title and the separator as arguments, according to template-functions-general.php line 201.

However, the only argument received by the callback function is the title, and no indication of the separator.

You can test this by installing the following code as a plugin:

<?php
/*
Plugin Name: Title Filter Test
Author: Sargant
Description: Demonstrates problem with wp_title filter
Version: 1
*/

add_filter('wp_title', 'title_filter_argument_test');

function title_filter_argument_test() {
  var_dump(func_get_args());
}

?>

Expected output:

The function wp_title() should var_dump an array with two elements - the title and the separator.

Actual output:

The var_dump shows just one function argument - the title alone.

Attachments (1)

title-filter-test.php (317 bytes) - added by sargant 20 years ago.
Demonstration Plugin

Download all attachments as: .zip

Change History (5)

@sargant
20 years ago

Demonstration Plugin

#1 @tenpura
20 years ago

  • Resolution set to invalid
  • Status changed from new to closed

In this case, apply_filters() should return single value, not an array.

#2 @markjaquith
20 years ago

In order to get additional values, you must specify so in your add_filter() call.

Like so:

add_filter('wp_title', 'title_filter_argument_test', 10, 2);

10 is the order of execution (10 is default) and 2 is the number of params you want passed (you want both, so you specify 2). Now your function will get both params.

#3 @tenpura
20 years ago

Ah, that's what he wants to do. thanks, Mark.

#4 @sargant
20 years ago

Oops. Bit too eager with the bug report - sorry for wasting your time, and thanks!

Note: See TracTickets for help on using tickets.