mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 08:33:35 +01:00
Make the $post
param optional in get_post_field()
.
When `$post` is `null`, the current post object will be returned. Props sebastian.pisula. Fixes #35683. git-svn-id: https://develop.svn.wordpress.org/trunk@36481 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ef99ae21be
commit
2c73fd9531
@ -494,16 +494,17 @@ function get_post_ancestors( $post ) {
|
|||||||
* supported values are found within those functions.
|
* supported values are found within those functions.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 4.5.0 The `$post` parameter was made optional.
|
||||||
*
|
*
|
||||||
* @see sanitize_post_field()
|
* @see sanitize_post_field()
|
||||||
*
|
*
|
||||||
* @param string $field Post field name.
|
* @param string $field Post field name.
|
||||||
* @param int|WP_Post $post Post ID or post object.
|
* @param int|WP_Post $post Optional. Post ID or post object. Defaults to current post.
|
||||||
* @param string $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db',
|
* @param string $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db',
|
||||||
* or 'display'. Default 'display'.
|
* or 'display'. Default 'display'.
|
||||||
* @return string The value of the post field on success, empty string on failure.
|
* @return string The value of the post field on success, empty string on failure.
|
||||||
*/
|
*/
|
||||||
function get_post_field( $field, $post, $context = 'display' ) {
|
function get_post_field( $field, $post = null, $context = 'display' ) {
|
||||||
$post = get_post( $post );
|
$post = get_post( $post );
|
||||||
|
|
||||||
if ( !$post )
|
if ( !$post )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user