WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 3 months 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: needs-patch good-first-bug
Focuses: docs Cc:

Description

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

Attachments (4)

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 6 months ago.
Rephrasing what sanitize_title() does
33756.4.diff (1.9 KB) - added by gma992 6 months ago.
Rephrased again, special characters are replaced too.

Download all attachments as: .zip

Change History (21)

@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
22 months ago

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

#7 follow-up: @psdtohtmlguru
19 months ago

@DrewAPicture Can i have this ticket please?

#8 in reply to: ↑ 7 @swissspidy
19 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
19 months ago

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

#10 @DrewAPicture
19 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
12 months ago

@psdtohtmlguru, still interested in making a patch?

#12 @psdtohtmlguru
12 months ago

@SergeyBiryukov Yes, i will submit soon.

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

#13 @swissspidy
12 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
7 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 7 months ago by sjmur (previous) (diff)

@gma992
6 months ago

Rephrasing what sanitize_title() does

#15 follow-up: @gma992
6 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
6 months ago

Rephrased again, special characters are replaced too.

#16 in reply to: ↑ 15 @shulard
5 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.


3 months ago

Note: See TracTickets for help on using tickets.