WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 6 months ago

#35385 new enhancement

Able to get raw content by calling get_the_archive_description

Reported by: wido Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: template Cc:

Description

Calling the get_the_archive_description the content will be passed to some filters by the sanitize_term_field function, one of them is wpautop.

To add some class to the p tag the only way is to perform a preg_replace but that can create issue with other callbacks hooked into 'get_the_archive_description'.

Would be great to have a param like $context as the get_term_field has to able to pass raw and retrieve only the text.

Attachments (3)

35385.diff (3.2 KB) - added by wido 14 months ago.
Introduce additional parameter to get the raw version of the post type archive description
35385-1.diff (3.2 KB) - added by wido 14 months ago.
Fix wrong generated diff from master
35385-2.diff (3.1 KB) - added by wido 14 months ago.
Change filter name and apply it only when the raw parameter is true.

Download all attachments as: .zip

Change History (10)

#1 @swissspidy
5 years ago

  • Component changed from General to Taxonomy
  • Focuses template added

#2 @chriscct7
5 years ago

  • Version trunk deleted

@wido
14 months ago

Introduce additional parameter to get the raw version of the post type archive description

#3 @wido
14 months ago

Instead of context I thought to introduce a boolean parameter which simply return the raw version of the description.
A filter has been added to be able to filter the description before it's returned.

I think a boolean introduce less complexity than a string since it's just a toggle action.

More over, I guess we could introduce a new function instead of passing a parameter, something like get_raw_post_type_archive_description which could be called by get_the_post_type_description, this way we do not introduce parameters making the function more clear and simple to call.

#4 @wido
14 months ago

  • Keywords has-patch has-unit-tests added

@wido
14 months ago

Fix wrong generated diff from master

@wido
14 months ago

Change filter name and apply it only when the raw parameter is true.

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


6 months ago

#6 follow-up: @markparnell
6 months ago

@wido I notice the patch introduces a boolean $raw parameter - perhaps it would be better to use a string $context as that can be extended later to accept additional values. Plus it's more consistent with get_term_field() which you referenced in your initial report.

#7 in reply to: ↑ 6 @wido
6 months ago

Replying to markparnell:

@wido I notice the patch introduces a boolean $raw parameter - perhaps it would be better to use a string $context as that can be extended later to accept additional values. Plus it's more consistent with get_term_field() which you referenced in your initial report.

Please have a look at https://core.trac.wordpress.org/ticket/35385#comment:3

Note: See TracTickets for help on using tickets.