Filters preview post meta retrieval to get values from the autosave.
Description
Filters revisioned meta keys only.
Parameters
$value
mixedrequired- Meta value to filter.
$object_id
intrequired- Object ID.
$meta_key
stringrequired- Meta key to filter a value for.
$single
boolrequired- Whether to return a single value. Default false.
Source
function _wp_preview_meta_filter( $value, $object_id, $meta_key, $single ) {
$post = get_post();
if (
empty( $post ) ||
$post->ID !== $object_id ||
! in_array( $meta_key, wp_post_revision_meta_keys( $post->post_type ), true ) ||
'revision' === $post->post_type
) {
return $value;
}
$preview = wp_get_post_autosave( $post->ID );
if ( false === $preview ) {
return $value;
}
return get_post_meta( $preview->ID, $meta_key, $single );
}
Changelog
Version | Description |
---|---|
6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.