WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 7 days ago

#33756 assigned defect (bug)

Improve docs for sanitize_title()

Reported by: ericlewis Owned by: psdtohtmlguru
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: good-first-bug has-patch
Focuses: docs Cc:

Description

It's not immediately clear what sanitize_title() does. Adding doc modifications.

Attachments (5)

33756.diff (1.4 KB) - added by ericlewis 2 years ago.
33756.2.diff (1.5 KB) - added by swissspidy 2 years ago.
33756.3.diff (1.9 KB) - added by gma992 8 months ago.
Rephrasing what sanitize_title() does
33756.4.diff (1.9 KB) - added by gma992 8 months ago.
Rephrased again, special characters are replaced too.
33756.5.diff (846 bytes) - added by ebinnion 7 days ago.
5th attempt at solution

Download all attachments as: .zip

Change History (23)

@ericlewis
2 years ago

@swissspidy
2 years ago

#1 @swissspidy
2 years ago

After looking at the PHP Documentation Standards I made some small adjustments to your patch, adding/removing newlines and backticks where necessary.

#2 @DrewAPicture
2 years ago

  • Owner set to DrewAPicture
  • Status changed from new to reviewing

#3 @wonderboymusic
2 years ago

Sanitizes a string for use as a slug in a URL. is incomplete. Also sanitizes for use as HTML id or class attribute value. There may be other uses...

#4 @DrewAPicture
2 years ago

  • Owner changed from DrewAPicture to swissspidy

See comment:3 for other use cases we need to cover.

#5 @DrewAPicture
2 years ago

  • Milestone changed from 4.4 to Future Release

Still some work left here. Let's move it off the milestone until there's a consensus on the best way to document the intent vs the actual usage of these functions. I'd probably suggest going the route of describing the literal characters removed or accepted for any of these formatting functions – since they tend to get used in all sorts of contexts unrelated to the original intent.

#6 @swissspidy
2 years ago

  • Keywords needs-patch good-first-bug added; has-patch removed
  • Owner swissspidy deleted

#7 follow-up: @psdtohtmlguru
21 months ago

@DrewAPicture Can i have this ticket please?

#8 in reply to: ↑ 7 @swissspidy
21 months ago

Replying to psdtohtmlguru:

@DrewAPicture Can i have this ticket please?

A ticket does not belong to anybody, so feel free to submit a patch as you like :)

#9 @DrewAPicture
21 months ago

  • Owner set to DrewAPicture
  • Status changed from reviewing to accepted

#10 @DrewAPicture
21 months ago

  • Owner changed from DrewAPicture to psdtohtmlguru
  • Status changed from accepted to assigned

Assigning to mark the good-first-bug as "claimed".

#11 @SergeyBiryukov
14 months ago

@psdtohtmlguru, still interested in making a patch?

#12 @psdtohtmlguru
14 months ago

@SergeyBiryukov Yes, i will submit soon.

Last edited 14 months ago by psdtohtmlguru (previous) (diff)

#13 @swissspidy
14 months ago

There's a tutorial for working with patches in the handbook: https://make.wordpress.org/core/handbook/tutorials/working-with-patches/

After creating a patch file you can upload it here to this ticket.

#14 @sjmur
9 months ago

Interested in taking this and finishing it. What are we trying to say at this point? Not sure on the language from reading comments.

`

Last edited 9 months ago by sjmur (previous) (diff)

@gma992
8 months ago

Rephrasing what sanitize_title() does

#15 follow-up: @gma992
8 months ago

@wonderboymusic

Sanitizes a string for use as a slug in a URL. is incomplete. Also sanitizes for use as HTML id or class attribute value. There may be other uses...

Not sure if I'm missing something here, but basically sanitize_title() strip tags, removes accents and replace special characters, right? I'm not really sure what you mean with id or class attribute value.

@gma992
8 months ago

Rephrased again, special characters are replaced too.

#16 in reply to: ↑ 15 @shulard
7 months ago

Maybe it's just that the sanitize_title function is sometimes used to generate an id or class from a string to ensure that non authorized characters are not used... Maybe useful only when generating attributes from inputed text.

Replying to gma992:

@wonderboymusic

Sanitizes a string for use as a slug in a URL. is incomplete. Also sanitizes for use as HTML id or class attribute value. There may be other uses...

Not sure if I'm missing something here, but basically sanitize_title() strip tags, removes accents and replace special characters, right? I'm not really sure what you mean with id or class attribute value.

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


5 months ago

@ebinnion
7 days ago

5th attempt at solution

#18 @ebinnion
7 days ago

  • Keywords has-patch added; needs-patch removed

@tim1602 and I worked on another possible solution at contributor day at WordCamp DFW 2017.

Since some of the pushback in early patches seemed to be that we weren't handling all of the cases of sanitize_title(), for example how it's used in URLs in some cases, and attributes in others... It seemed like it might be best to stay ambiguous and then mention URLs and attributes as examples.

We also tried to expand on the long description by mentioning the sanitize_title filter and the default output.

Note: See TracTickets for help on using tickets.