Opened 9 years ago
Closed 8 years ago
#35487 closed enhancement (wontfix)
Update has_excerpt()
Reported by: | sebastian.pisula | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
I think that has_excerpt function should be return bool value from get_the_excerpt(). This is update after fix: [36319] where we can filter excerpt
Attachments (2)
Change History (12)
#3
in reply to:
↑ 1
@
9 years ago
- Keywords close removed
Replying to swissspidy:
Hmm this could lead to false positives where the excerpt has been filtered or when it is a private post.
For example,
get_the_excerpt()
returns'There is no excerpt because this is a protected post.'
for private posts, buthas_excerpt()
returnsfalse
. With this patch, it would returntrue
.
Sounds like a wontfix because of BC issues.
I think that this work good. Because for private post the excerpt is 'There is no excerpt because this is a protected post.'
. Maybe add new param - $private_excerpt = true
and in has_exceprt function get_the_excerpt($post_id, false)
? Example in patch.
#4
follow-up:
↓ 10
@
9 years ago
That still changes the semantics of the function. get_the_excerpt()
is almost never empty because wp_trim_excerpt()
is hooked to the get_the_excerpt
filter.
has_excerpt()
checks if there's a custom excerpt, not if there's some generated excerpt.
#5
follow-up:
↓ 6
@
9 years ago
current fuction work bad too because in $post->post_excerpt
I will be have excerpt and in get_the_excerpt I use filter to remove excerpt so has_excerpt()
return true
and get_the_excerpt
return empty string -> except not exists
#6
in reply to:
↑ 5
@
9 years ago
- Keywords close added
Replying to sebastian.pisula:
current fuction work bad too because in
$post->post_excerpt
I will be have excerpt and in get_the_excerpt I use filter to remove excerpt sohas_excerpt()
returntrue
andget_the_excerpt
return empty string -> except not exists
This sounds like an edge case. If you do that and you want to make sure get_the_excerpt()
is not empty, just use if ( get_the_excerpt() { … }
instead of has_excerpt()
.
The ticket really is a wontfix in my eyes because it breaks backwards-compatibility. Devs expect it to check $post->post_excerpt
and not get_the_excerpt()
.
#10
in reply to:
↑ 4
@
8 years ago
- Keywords close 2nd-opinion removed
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Replying to swissspidy:
has_excerpt()
checks if there's a custom excerpt, not if there's some generated excerpt.
[40042] clarifies that in the function description.
I agree with comment:6, changing it now would break backwards compatibility.
Hmm this could lead to false positives where the excerpt has been filtered or when it is a private post.
For example,
get_the_excerpt()
returns'There is no excerpt because this is a protected post.'
for private posts, buthas_excerpt()
returnsfalse
. With this patch, it would returntrue
.Sounds like a wontfix because of BC issues.