_wp_get_allowed_postdata()
Returns only allowed post data fields.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
Array|WP_Error. Array of post data on success, WP_Error on failure.
Usage
_wp_get_allowed_postdata( $post_data );
- $post_data(array|WP_Error|null)
- The array of post data to process, or an error object.
Default: $_POST superglobal
Changelog
| Since 5.0.1 | Introduced. |
_wp_get_allowed_postdata() wp get allowed postdata code WP 6.9
function _wp_get_allowed_postdata( $post_data = null ) {
if ( empty( $post_data ) ) {
$post_data = $_POST;
}
// Pass through errors.
if ( is_wp_error( $post_data ) ) {
return $post_data;
}
return array_diff_key( $post_data, array_flip( array( 'meta_input', 'file', 'guid' ) ) );
}