From c2b5aeebb0a3afdea3c09f4ac804ea497cdee47f Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Sat, 10 Oct 2015 05:41:29 +0000 Subject: [PATCH] Template: Rename the `$id` parameters in `the_permalink()`, `get_the_permalink()`, and `get_permalink()` to `$post`. In all three cases, the functions can accept a post ID, a `WP_Post` object, or a falsey value, which defaults to the value of the global `$post`. Switching to `$post` in this context allows the parameters to better self-document and removes ambiguity in the code they are subsequently used in. Props chriscct7 for the initial patch. See #34234. Built from https://develop.svn.wordpress.org/trunk@35001 git-svn-id: http://core.svn.wordpress.org/trunk@34966 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 24 ++++++++++++------------ wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 93ba372e8a..bfa9a53f9f 100644 --- a/wp-includes/link-template.php +++ b/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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 46a25bec82..bf1b5b0d1e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35000'; +$wp_version = '4.4-alpha-35001'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.