[wp-trac] [WordPress Trac] #12240: Let plugins filter post permalink before core replacements
WordPress Trac
wp-trac at lists.automattic.com
Tue Feb 16 05:47:26 UTC 2010
#12240: Let plugins filter post permalink before core replacements
--------------------------+-------------------------------------------------
Reporter: shidouhikari | Owner: ryan
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.3
Component: Permalinks | Version: 2.9.1
Severity: normal | Keywords: permalink, filter, hook, get_permalink, post_link
--------------------------+-------------------------------------------------
Comment(by shidouhikari):
Replying to [comment:1 filosofo]
I couldn't find the 'option_permalink_structure' filter, could you point
me where it is?
The idea is not just have the 'permalink_structure' option value, it is to
be able to convert a rewrite tag into a value *before* core is able to do
it.
For example, let's say I wanna use %category% in the permalink, but a
specific one, not the one with lowest ID.
If there was a filter after 'permalink_structure' option value is loaded
and before WordPress starts parsing it for rewrite tags, I could use the
filter and replace %category% for the category I want, instead of letting
WordPress do it on its way.
Since there is no such filter, when the available filter is called it's
too late, because in the final permalink I don't know exactly where
%category% was, to do what I wanted. I'd need to find out what's
"category" in the final permalink (which would be harder and may break
with newer WordPress versions) and do a str_replace over it.
A note about this exemple: since, during rewrite rules parsing, any
category is accepted for %category%, it would require no rewrite rule
changes for it to work.
Another example of its use is to achieve better performance when custom
permalinks are used. Instead of letting WordPress to all the parsing and
replacement, to later just throw away its work and return the actual
custom permalink, we could just use the first filter to add it, and
Wordpress would be saved from doing its work without need.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12240#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list