From 9a0bbee93ca2b88a14e2054c4cfd391c5123ce22 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 8 Feb 2010 16:23:32 +0000 Subject: [PATCH] Rename get_post_link() to get_post_permalink() to avoid conflict with bbPress. Props scribu. fixes #12172 git-svn-id: https://develop.svn.wordpress.org/trunk@13023 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/link-template.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 0e9232c8bd..340335f1ea 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -107,7 +107,7 @@ function get_permalink($id = 0, $leavename = false) { elseif ( $post->post_type == 'attachment' ) return get_attachment_link($post->ID); elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) - return get_post_link($post); + return get_post_permalink($post); $permalink = get_option('permalink_structure'); @@ -171,7 +171,7 @@ function get_permalink($id = 0, $leavename = false) { * @param bool $sample Optional, defaults to false. Is it a sample permalink. * @return string */ -function get_post_link( $id = 0, $leavename = false, $sample = false ) { +function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { global $wp_rewrite; $post = &get_post($id); @@ -183,15 +183,17 @@ function get_post_link( $id = 0, $leavename = false, $sample = false ) { $slug = $post->post_name; - if ( !empty($post_link) && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) { + $draft_or_pending = 'draft' == $post->post_status || 'pending' == $post->post_status; + + if ( !empty($post_link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { $post_link = ( $leavename ) ? $post_link : str_replace("%$post->post_type%", $slug, $post_link); $post_link = home_url( user_trailingslashit($post_link) ); } else { $post_type = get_post_type_object($post->post_type); - if ( $post_type->query_var && ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) ) - $post_link = "?$post_type->query_var=$slug"; + if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) + $post_link = add_query_arg($post_type->query_var, $slug, ''); else - $post_link = "?post_type=$post->post_type&p=$post->ID"; + $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); $post_link = home_url($post_link); }