diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 93ba372e8a..bfa9a53f9f 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -10,11 +10,11 @@ * Display the permalink for the current post. * * @since 1.2.0 - * @since 4.4.0 Added `$id` parameter. + * @since 4.4.0 Added the `$post` parameter. * - * @param int|WP_Post $id Optional. Post ID or post object. Default current post. + * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`. */ -function the_permalink( $id = 0 ) { +function the_permalink( $post = 0 ) { /** * Filter the display of the permalink for the current post. * @@ -22,7 +22,7 @@ function the_permalink( $id = 0 ) { * * @param string $permalink The permalink for the current post. */ - echo esc_url( apply_filters( 'the_permalink', get_permalink( $id ) ) ); + echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ) ) ); } /** @@ -94,12 +94,13 @@ function permalink_anchor( $mode = 'id' ) { * * @see get_permalink() * - * @param int|WP_Post $id Optional. Post ID or post object. Default current post. + * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`. * @param bool $leavename Optional. Whether to keep post name or page name. Default false. + * * @return string|false The permalink URL or false if post does not exist. */ -function get_the_permalink( $id = 0, $leavename = false ) { - return get_permalink( $id, $leavename ); +function get_the_permalink( $post = 0, $leavename = false ) { + return get_permalink( $post, $leavename ); } /** @@ -107,11 +108,11 @@ function get_the_permalink( $id = 0, $leavename = false ) { * * @since 1.0.0 * - * @param int|WP_Post $id Optional. Post ID or post object. Default current post. + * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`. * @param bool $leavename Optional. Whether to keep post name or page name. Default false. * @return string|false The permalink URL or false if post does not exist. */ -function get_permalink( $id = 0, $leavename = false ) { +function get_permalink( $post = 0, $leavename = false ) { $rewritecode = array( '%year%', '%monthnum%', @@ -126,11 +127,10 @@ function get_permalink( $id = 0, $leavename = false ) { $leavename? '' : '%pagename%', ); - if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) { - $post = $id; + if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) { $sample = true; } else { - $post = get_post($id); + $post = get_post( $post ); $sample = false; }