Making WordPress.org

Opened 6 years ago

Closed 6 years ago

#3688 closed defect (bug) (fixed)

Permalink for methods are wrong when using sub-namespaces

Reported by: keesiemeijer's profile keesiemeijer Owned by: obenland's profile obenland
Milestone: Priority: normal
Component: Developer Hub Keywords: has-patch
Cc:

Description

The permalink for methods if left unfiltered by the 'post_type_link' are in this format:

/classes/class_name-method_name

With the post_type_link filter the slug is changed by splitting it by -. The part found after the first - is used as the method name. Formatted like this:

/reference/classes/class_name/method_name

If you use a namespace like this namespace MyProject\Sub\Level; the unfiltered permalink is:

/classes/myproject-sub-level-class_name-method_name

Now with the filter all methods with this namescpace have a permalink like this:

/reference/classes/myproject/sub

The following patch fixes this by using the (namespaced) parent post slug for the class name. The method name is found by subtracting the (namespaced) parent slug from the method slug.

reference/classes/myproject-sub-level-class_name/method_name

I know WordPress doesn't use namespaces (now) but we should provide basic support.

Attachments (1)

3688.patch (966 bytes) - added by keesiemeijer 6 years ago.
Fix method permalinks

Download all attachments as: .zip

Change History (2)

@keesiemeijer
6 years ago

Fix method permalinks

#1 @obenland
6 years ago

  • Owner set to obenland
  • Resolution set to fixed
  • Status changed from new to closed

In 7381:

DevHub: More flexible method permalink handling

Allows for the possiblity of more than one dash in a method's slug.

Props keesiemeijer.
Fixes #3688.

Note: See TracTickets for help on using tickets.