Permalink
Browse files

Add correct endpoing to draft URLs with query args

Before we added /liveblog/ to a permalink if the
blog had pretty permalinks. But if the post was
a draft it's URL isn't pretty, it's ?p=XX-style.

So, instead of checking whether the blog used
pretty permalinks we check if it has ?p=. There
shouldn't be any false positives, because if a URL
has a ? and it doesn't mean a separator between
path and query args it should be escaped.

Fixes #17.
  • Loading branch information...
1 parent 4221823 commit 0dccc810dd6be40c00e1b407dc97cb2d455d8d6f @nb nb committed Sep 18, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 liveblog.php
View
@@ -535,11 +535,11 @@ private static function add_default_plupload_settings() {
* @return string
*/
private static function get_entries_endpoint_url() {
- if ( get_option( 'permalink_structure' ) )
- $url = trailingslashit( trailingslashit( get_permalink( self::$post_id ) ) . self::url_endpoint ); // returns something like /2012/01/01/post/liveblog/
+ $post_permalink = get_permalink( self::$post_id );
+ if ( false !== strpos( $post_permalink, '?p=' ) )
+ $url = add_query_arg( self::url_endpoint, '', $post_permalink ) . '='; // returns something like ?p=1&liveblog=
else
- $url = add_query_arg( self::url_endpoint, '', get_permalink( self::$post_id ) ) . '='; // returns something like ?p=1&liveblog=
-
+ $url = trailingslashit( trailingslashit( $post_permalink ) . self::url_endpoint ); // returns something like /2012/01/01/post/liveblog/
return $url;
}

0 comments on commit 0dccc81

Please sign in to comment.