Add a 'pre_post_link' filter to get_permalink() before token replacement occurs. Fixes #12240

git-svn-id: http://svn.automattic.com/wordpress/trunk@13549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-02 11:57:32 +00:00
parent 4c7070fb41
commit 302fd434c9
1 changed files with 5 additions and 3 deletions

View File

@ -100,7 +100,8 @@ function get_permalink($id = 0, $leavename = false) {
$sample = false; $sample = false;
} }
if ( empty($post->ID) ) return false; if ( empty($post->ID) )
return false;
if ( $post->post_type == 'page' ) if ( $post->post_type == 'page' )
return get_page_link($post->ID, $leavename, $sample); return get_page_link($post->ID, $leavename, $sample);
@ -111,6 +112,8 @@ function get_permalink($id = 0, $leavename = false) {
$permalink = get_option('permalink_structure'); $permalink = get_option('permalink_structure');
$permalink = apply_filters('pre_post_link', $permalink, $post, $leavename);
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
$unixtime = strtotime($post->post_date); $unixtime = strtotime($post->post_date);
@ -154,11 +157,10 @@ function get_permalink($id = 0, $leavename = false) {
); );
$permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) ); $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
$permalink = user_trailingslashit($permalink, 'single'); $permalink = user_trailingslashit($permalink, 'single');
return apply_filters('post_link', $permalink, $post, $leavename);
} else { // if they're not using the fancy permalink option } else { // if they're not using the fancy permalink option
$permalink = home_url('?p=' . $post->ID); $permalink = home_url('?p=' . $post->ID);
return apply_filters('post_link', $permalink, $post, $leavename);
} }
return apply_filters('post_link', $permalink, $post, $leavename);
} }
/** /**