Make WordPress Core

Opened 8 years ago

Last modified 2 years ago

#41179 new enhancement

Adding get_the_content-filter

Reported by: ninos-ego's profile Ninos Ego Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8
Component: Themes Keywords: needs-codex dev-feedback
Focuses: docs, template Cc:

Description

Hey there,
atm I cannot replace the content by a custom on, because of missing filter for get_the_content().

Attached a patch for this.

Attachments (1)

get_the_content_filter.patch (1.6 KB) - added by Ninos Ego 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @Ninos Ego
8 years ago

  • Keywords has-patch needs-codex dev-feedback added

#2 @Ninos Ego
8 years ago

BTW the function get_the_content() and the_content() seems too much inconsistent compared with e.g. get_the_excerpt() and the_excerpt(). Also it looks too much complex (job could surely be done in an easier way). May it needs a complete refactoring.

Pro:

  • Cleaner code (more consistent)
    • Easier to maintain
    • For devs: easier to understand and implement

Contra:

  • Theme and plugin authors may need to refactor their code

PS: I hope for WP 5.0 you're planning some refactoring, e.g. media lib and code cleanup / consistency.

This ticket was mentioned in Slack in #themereview by nikolam. View the logs.


7 years ago

#4 @joyously
7 years ago

  • Keywords has-patch removed

This patch does not match the ticket description. The patch adds parameters to the the_content filter, which would break all kinds of themes, plugins, and core.

Why do you think get_the_content() needs a filter? I thought the whole point of it was that it was returning the actual content, unfiltered. It is a reliable source of actual content.

#5 @Ninos Ego
7 years ago

Why it would break all kinds of themes, plugins or core? It does not replace params. Also atm plugins, themes and core just uses add_filter( 'the_content', 'yourfunction', PRIORITY )
, no admin is using here the param $accepted_args, because not needed. If used, they have to use 1. So it's not breaking anything. The other params are optional.

get_the_content()-filter is needed for plugins to change content in themes. The params $more_link_text
& $strip_teaser can then be used by plugins e.g. to readd the $more_link_text after changing content.

#6 @joyously
7 years ago

Ooops, my mistake of thinking the parameters backwardly. Sorry.

I still think get_the_content() is better left unfiltered.

#7 @Ninos Ego
7 years ago

Why get_the_content() is better unfiltered but the_content() already has an filter? If someone wants to have raw content, he can use $post->post_content.

#8 @dd32
2 years ago

#53207 was marked as a duplicate.

Note: See TracTickets for help on using tickets.