[wp-trac] [WordPress Trac] #21266: Enhancements for page numbers links API

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 13 20:59:17 UTC 2012


#21266: Enhancements for page numbers links API
-------------------------+-----------------------------
 Reporter:  sirzooro     |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Permalinks   |    Version:  3.4.1
 Severity:  normal       |   Keywords:  has-patch
-------------------------+-----------------------------
 Currently WordPress provides few functions to create links with page
 numbers embedded. Unfortunately they have some limitations:[[BR]]
 - `get_pagenum_link()` - works on `$_SERVER['REQUEST_URI']` only;[[BR]]
 - `get_comments_pagenum_link()` - works on current post only;[[BR]]
 - `_wp_link_page()` - works on current post only, returns HTML code and is
 private.

 Because of these limitations in the past I have reimplemented these
 functions in my SEO plugin. Now I decided that it will be better if WP
 core will provide needed functionality.

 Attached path introduces following changes for functions:[[BR]]
 - `get_pagenum_link()` - added new `$url` param, which can be used to pass
 any URL to function;[[BR]]
 - `get_comments_pagenum_link()` - added two new params: `$post` and
 `$add_anchor`. The former one allows to pass any post object to function,
 the latter one tells function if it should append `#comments` at the end
 of URL;
 - `get_post_page_link()` - new function. I moved code from
 `_wp_link_page()` here and modified it so it can work on any post.
 Additionally it calls new filter `get_post_page_link` before returning
 value.[[BR]]

 Additionally these functions passes new argument(s) to filter at the end,
 so it will be easier for plugins to generate different pagination URLs.

 I also modified `_wp_link_page()` function (now it calls
 `get_post_page_link()`) and removed `@access private` from
 `wp_link_pages()` (as I checked, it is called from themes code only).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21266>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list