[wp-meta] [Making WordPress.org] #3688: Permalink for methods are wrong when using sub-namespaces
Making WordPress.org
noreply at wordpress.org
Wed Jun 27 11:28:41 UTC 2018
#3688: Permalink for methods are wrong when using sub-namespaces
---------------------------+-----------------------
Reporter: keesiemeijer | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone:
Component: Developer Hub | Keywords: has-patch
---------------------------+-----------------------
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.
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/3688>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list