Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#31568 closed enhancement (fixed)

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

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


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 9 years ago.
Patch to add a 2nd parameter to editable_slug filter calls
31568.2.diff (4.4 KB) - added by jesin 9 years ago.

Download all attachments as: .zip

Change History (7)

9 years ago

Patch to add a 2nd parameter to editable_slug filter calls

#1 @DrewAPicture
9 years ago

  • Component changed from Rewrite Rules to 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.


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

#2 @DrewAPicture
9 years ago

  • Component changed from Taxonomy to General

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

9 years ago

#3 @jesin
9 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
9 years ago

  • Milestone changed from Awaiting Review to 4.4

#5 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to 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.