diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 520d89bf01..00d1e0c098 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -4428,11 +4428,12 @@ function _page_traverse_name( $page_id, &$children, &$result ){ * Sub pages will be in the "directory" under the parent page post name. * * @since 1.5.0 + * @since 4.6.0 The $page parameter is optional. * - * @param WP_Post|object|int $page Page object or page ID. + * @param WP_Post|object|int $page Optional. Page ID or WP_Post object. Default is global $post. * @return string|false Page URI, false on error. */ -function get_page_uri( $page ) { +function get_page_uri( $page = 0 ) { if ( ! $page instanceof WP_Post ) { $page = get_post( $page ); } diff --git a/tests/phpunit/tests/post/getPageUri.php b/tests/phpunit/tests/post/getPageUri.php new file mode 100644 index 0000000000..604dd20f79 --- /dev/null +++ b/tests/phpunit/tests/post/getPageUri.php @@ -0,0 +1,17 @@ +post->create(array( + 'post_title' => 'Blood Orange announces summer tour dates', + 'post_name' => 'blood-orange-announces-summer-tour-dates', + )); + $post = get_post( $post_id ); + $this->go_to( get_permalink( $post_id ) ); + $this->assertEquals( 'blood-orange-announces-summer-tour-dates', get_page_uri() ); + } +}