WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#17039 new defect (bug)

the_excerpt() - <!--more--> handling

Reported by: wpweaver Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Formatting Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

If a post has a manually inserted <!--more--> before the default break at the excerpt length, then the_excerpt() fails to generate any [...] or call the "excerpt_more" filter. Thus, there is no indication that there is more content to the post.

Attachments (2)

17039.diff (1.5 KB) - added by kawauso 3 years ago.
17039.2.diff (1.5 KB) - added by kawauso 3 years ago.
wp_trim_excerpt() isn't fired if post_password_required() is true, so drop internal check

Download all attachments as: .zip

Change History (8)

comment:1 kawauso3 years ago

  • Keywords has-patch added

The issue can be traced back to using get_the_content() in wp_trim_excerpt() which cuts off at <!--more--> regardless of the caller function and doesn't have a more text provided for it.

Following patch splices in a minimal version of the_content() rather than trying to bend the existing code or use a hacky workaround such as $more = 1

Cut:

  • <!--noteaser--> checks which sets $stripteaser: isn't used unless $more is true
  • if ( count($content) > 1 ): only invokes force_balance_tags() since $more is false and $more_link_text is empty, which is unnecessary since we strip_tags()

Not cut:

  • post_password_required() check, though it's overridden by the_excerpt()
  • $preview check: is this needed?

kawauso3 years ago

kawauso3 years ago

wp_trim_excerpt() isn't fired if post_password_required() is true, so drop internal check

comment:2 kawauso3 years ago

Last patch does have the slight difference that if it's called by a function other than get_the_excerpt() that fails to replicate the password required check, it will return the actual excerpt rather than a mangled excerptified password form.

comment:3 nacin3 years ago

This was noticed during Twenty Ten development. See #13361 for relevant conversation.

comment:4 iandstewart2 years ago

  • Cc ian@… added

comment:5 mfields2 years ago

  • Cc michael@… added

comment:6 nacin3 months ago

  • Keywords 2nd-opinion added
  • Milestone changed from Awaiting Review to Future Release

See also #25349, somewhat related to the weirdness here.

Note: See TracTickets for help on using tickets.