Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#31568 closed enhancement (fixed)

Add a 2nd parameter to 'editable_slug' filter for context

Reported by: MikeSchinkel Owned by: wonderboymusic
Priority: normal Milestone: 4.4
Component: General Version: 4.2
Severity: normal Keywords: has-patch
Cc: Focuses: administration

Description

I am finding cases where I ideally would prefer to know the explicit context for an editable slug rather than have to depend on global context, which in certain cases could be wrong.

The 'editable_slug' filter processes the slugs for $post and $tag objects where it is used in core so the attached patch adds in a 2nd parameter when calling apply_filters( 'editable_slug', $slug ) in each of the seven (7) places in WP core where the filter is used.

The primary benefit of this patch will be to allow plugins and theme authors to write more robust code that will not fail during the edge cases where the global values are not consistent with the call that triggers the filter.

Attachments (2)

31568.diff​ (4.6 KB ) - added by MikeSchinkel 12 years ago.
Patch to add a 2nd parameter to editable_slug filter calls
31568.2.diff​ (4.4 KB ) - added by jesin 12 years ago.

Download all attachments as: .zip

Change History (7)

@MikeSchinkel
12 years ago

Patch to add a 2nd parameter to editable_slug filter calls

#1 @DrewAPicture
12 years ago

  • Component Rewrite Rules → Taxonomy
  • Keywords has-patch needs-docs added

Hi Mike,

Looks like you missed adding the new parameter to the hook doc, which is wp-admin/edit-tag-form.php. You'll also need to add @param and changeset entries to the hook doc for the new parameter. e.g.

@since 4.2.0 The `$tag` parameter was added.

and

@param object|WP_Post $tag Term or WP_Post object.
Last edited 12 years ago by DrewAPicture (previous) (diff)

#2 @DrewAPicture
12 years ago

  • Component Taxonomy → General

I guess I'll go with General since this hook is used all over the place.

@jesin
12 years ago

#3 @jesin
12 years ago

  • Keywords needs-docs removed

Patch 31568.diff​ seems to made from an old version of WordPress (rev 25569) and didn't apply for me.

Patch 31568.2.diff​ was created from the latest trunk and contains hook docs as per DrewAPicture's instructions.

#4 @wonderboymusic
11 years ago

  • Milestone Awaiting Review → 4.4

#5 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → closed

In 34319:

When applying the 'editable_slug' filter, add a second param that provides more context.

Props MikeSchinkel, jesin.
Fixes #31568.

Note: See TracTickets for help on using tickets.