#4596 closed defect (bug) (worksforme)
use_desc_for_title doesnt work in wp_list_categories()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.2.1 |
Component: | General | Keywords: | wp_list_categories categories lists reporter-feedback |
Focuses: | Cc: |
Description (last modified by )
When you make a call to wp_list_categories(), the use_desc_for_title is set to TRUE by default, but even if the category has a description, the default text (View all posts filed under..) is shown. Even if you force the use_desc_for_title to TRUE in the wp_list_categories() call, it still doesnt work.
I managed to "fix" this bug changing the line 586 in the classes.php file from:
if ( $use_desc_for_title == 0 || empty($category->category_description) )
to
if ( empty($category->category_description) )
but, this break the use_desc_for_title variable usage.
Attachments (1)
Change History (8)
#4
follow-up:
↓ 5
@
17 years ago
I'm going to take ownership of this for the weekend or tonight. If I provide a patch and find a solution, is it possible it can get in? Or is it too early to tell?
#5
in reply to:
↑ 4
@
17 years ago
Replying to darkdragon:
I'm going to take ownership of this for the weekend or tonight. If I provide a patch and find a solution, is it possible it can get in? Or is it too early to tell?
Go for it. Patches that fix issues are always appreciated!
#6
@
17 years ago
Wait! use_desc_for_title
is set to '1'
by default. However, it is a string, it will still be type casted to 1
, which doesn't equal 0, so the first evaluates to false and unless the description contains something, it will display the first block with "View all posts..."
I'm unsure if the goal is to allow for setting the value to true
. In which case, I would have to agree that it should allow you to set the argument to true.
#7
@
17 years ago
- Milestone 2.4 deleted
- Resolution set to worksforme
- Status changed from new to closed
Unit Tests show that this is not a problem. $category->category_description
no longer exists and is now $category->description
, it is most likely that the problem you were having was fixed on the switch over to Taxonomy API.
Question: Was the operator between those two an
||
or an&&
when you were having trouble?This is an interesting bug. However, it appears that Trac removed some formatting from the description. I'm going to try to track down and see what the rest of the string is.
It appears that the line is using the correct logic, however, because of PHP implicit type jungling it is unclear whether your
TRUE
value is being type casted toINT 1
.It might be better to explicitly type cast
$use_desc_for_title
to boolean and then test forfalse
value. However, type casting anything to boolean means that an empty variable and 0 will havefalse
value and everything else will havetrue
value.With:
if( (bool) $use_desc_for_title === false || empty( $category->description ) )
These should have false values:
$use_desc_for_title = ''
$use_desc_for_title = 0
$use_desc_for_title = false
These should have true values:
$use_desc_for_title = true
$use_desc_for_title = 'a'
$use_desc_for_title = 1
It is unlikely that a drastic logic modification like removing the variable check would help anything. The logic itself should be fixed.